From d13dc28dbe53298e9eab79ef4775934d8a9cb2a3 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Thu, 18 May 2023 18:42:29 -0700 Subject: [PATCH] [CollectionsTestSupport] Fix rare overflow in integer square root tests --- Tests/CollectionsTestSupportTests/UtilitiesTests.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/CollectionsTestSupportTests/UtilitiesTests.swift b/Tests/CollectionsTestSupportTests/UtilitiesTests.swift index b0038980..ae64f2b9 100644 --- a/Tests/CollectionsTestSupportTests/UtilitiesTests.swift +++ b/Tests/CollectionsTestSupportTests/UtilitiesTests.swift @@ -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) + } } } }