uquic/internal/utils/minmax_test.go
Gaukas Wang 4973374ea5
sync: quic-go 0.42.0
Signed-off-by: Gaukas Wang <i@gaukas.wang>
2024-04-23 22:34:55 -06:00

33 lines
787 B
Go

package utils
import (
"time"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Min / Max", func() {
It("returns the maximum time", func() {
a := time.Now()
b := a.Add(time.Second)
Expect(MaxTime(a, b)).To(Equal(b))
Expect(MaxTime(b, a)).To(Equal(b))
})
It("returns the minimum duration", func() {
a := time.Now()
b := a.Add(time.Second)
Expect(MinTime(a, b)).To(Equal(a))
Expect(MinTime(b, a)).To(Equal(a))
})
It("returns the minium non-zero duration", func() {
var a time.Duration
b := time.Second
Expect(MinNonZeroDuration(0, 0)).To(BeZero())
Expect(MinNonZeroDuration(a, b)).To(Equal(b))
Expect(MinNonZeroDuration(b, a)).To(Equal(b))
Expect(MinNonZeroDuration(time.Minute, time.Hour)).To(Equal(time.Minute))
})
})