utils: switch to standard library min and max functions (#4218)

These functions were added in Go 1.21.
This commit is contained in:
Marten Seemann
2023-12-28 12:19:13 +07:00
committed by GitHub
parent 18c591c75a
commit 22411e16d5
24 changed files with 44 additions and 78 deletions

View File

@@ -88,12 +88,12 @@ var _ = Describe("MTU Discoverer", func() {
const rep = 3000
var maxDiff protocol.ByteCount
for i := 0; i < rep; i++ {
max := protocol.ByteCount(rand.Intn(int(3000-startMTU))) + startMTU + 1
maxMTU := protocol.ByteCount(rand.Intn(int(3000-startMTU))) + startMTU + 1
currentMTU := startMTU
d := newMTUDiscoverer(rttStats, startMTU, func(s protocol.ByteCount) { currentMTU = s })
d.Start(max)
d.Start(maxMTU)
now := time.Now()
realMTU := protocol.ByteCount(rand.Intn(int(max-startMTU))) + startMTU
realMTU := protocol.ByteCount(rand.Intn(int(maxMTU-startMTU))) + startMTU
t := now.Add(mtuProbeDelay * rtt)
var count int
for d.ShouldSendProbe(t) {
@@ -112,7 +112,7 @@ var _ = Describe("MTU Discoverer", func() {
}
diff := realMTU - currentMTU
Expect(diff).To(BeNumerically(">=", 0))
maxDiff = utils.Max(maxDiff, diff)
maxDiff = max(maxDiff, diff)
}
Expect(maxDiff).To(BeEquivalentTo(maxMTUDiff))
})