[CollectionsTestSupport] Fix rare overflow in integer square root tests

This commit is contained in:
Karoy Lorentey committed 2023-05-18 18:42:29 -07:00
1 parent 4b1aa5a640
commit d13dc28dbe
1 file changed
+4 -1
@@ -21,7 +21,10 @@ final class UtilitiesTests: CollectionTestCase {
withSome("i", in: 0 ..< Int.max, maxSamples: 100_000) { i in
let s = i._squareRoot()
expectLessThanOrEqual(s * s, i)
expectGreaterThan((s + 1) * (s + 1), i)
let next = (s + 1).multipliedReportingOverflow(by: s + 1)
if !next.overflow {
expectGreaterThan(next.partialValue, i)
}
}
}
}