forked from quic-go/quic-go
@@ -58,6 +58,13 @@ func MaxDuration(a, b time.Duration) time.Duration {
|
||||
return b
|
||||
}
|
||||
|
||||
func MinDuration(a, b time.Duration) time.Duration {
|
||||
if a > b {
|
||||
return b
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// AbsDuration returns the absolute value of a time duration
|
||||
func AbsDuration(d time.Duration) time.Duration {
|
||||
if d >= 0 {
|
||||
|
||||
@@ -33,6 +33,11 @@ var _ = Describe("Min / Max", func() {
|
||||
Expect(MaxDuration(time.Microsecond, time.Nanosecond)).To(Equal(time.Microsecond))
|
||||
Expect(MaxDuration(time.Nanosecond, time.Microsecond)).To(Equal(time.Microsecond))
|
||||
})
|
||||
|
||||
It("returns the minimum duration", func() {
|
||||
Expect(MinDuration(time.Microsecond, time.Nanosecond)).To(Equal(time.Nanosecond))
|
||||
Expect(MinDuration(time.Nanosecond, time.Microsecond)).To(Equal(time.Nanosecond))
|
||||
})
|
||||
})
|
||||
|
||||
Context("Min", func() {
|
||||
|
||||
Reference in New Issue
Block a user