From 0d702901c93237bccfe376418b8fcc44da33a75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Bystr=C3=B6m=20Ericsson?= Date: Fri, 29 Nov 2024 15:43:34 +0100 Subject: [PATCH] Fix a unit test. The random distance limit was too low for arbitrary integer values of zero. --- Tests/UltimathnumTests/BinaryInteger+Shift.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/UltimathnumTests/BinaryInteger+Shift.swift b/Tests/UltimathnumTests/BinaryInteger+Shift.swift index d32fd2fa..dd246f68 100644 --- a/Tests/UltimathnumTests/BinaryInteger+Shift.swift +++ b/Tests/UltimathnumTests/BinaryInteger+Shift.swift @@ -224,13 +224,13 @@ import TestKit ) func distanceIsInfiniteCountOrShift( type: any BinaryInteger.Type, randomness: consuming FuzzerInt ) throws { - + try whereIs(type) func whereIs(_ type: T.Type) throws where T: BinaryInteger { for _ in 0 ..< 32 { let value = T.entropic(through: Shift.max(or: 255), using: &randomness) - let zeros = UX(raw: value.ascending(Bit.zero)) - let limit = UX.max - zeros + let zeros = UX(raw: value.ascending(Bit.zero)) + let limit = Swift.max(UX.msb, UX.max - zeros) let distance = Count(raw: UX.random(in: limit...UX.max, using: &randomness)) try #require(distance.isInfinite)