forked from quic-go/quic-go
add protocol.{Min,Max}ProtocolNumber
This commit is contained in:
17
protocol/minmax.go
Normal file
17
protocol/minmax.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package protocol
|
||||
|
||||
// MaxPacketNumber returns the max packet number
|
||||
func MaxPacketNumber(a, b PacketNumber) PacketNumber {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// MinPacketNumber returns the min packet number
|
||||
func MinPacketNumber(a, b PacketNumber) PacketNumber {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
17
protocol/minmax_test.go
Normal file
17
protocol/minmax_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package protocol_test
|
||||
|
||||
import (
|
||||
"github.com/lucas-clemente/quic-go/protocol"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("minmax", func() {
|
||||
It("calculates packet number max", func() {
|
||||
Expect(protocol.MaxPacketNumber(1, 2)).To(Equal(protocol.PacketNumber(2)))
|
||||
})
|
||||
|
||||
It("calculates packet number min", func() {
|
||||
Expect(protocol.MinPacketNumber(1, 2)).To(Equal(protocol.PacketNumber(1)))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user