Fix unit tests on Linux

This commit is contained in:
Christian Treffs 2019-08-22 13:55:05 +02:00
parent 2084e04257
commit f824505501
1 changed files with 7 additions and 6 deletions

View File

@ -12,12 +12,13 @@ class HashingTests: XCTestCase {
func makeComponent() -> Int {
let upperBound: Int = 44
let high = UInt(arc4random()) << UInt(upperBound)
let low = UInt(arc4random())
assert(high.leadingZeroBitCount < 64 - upperBound)
assert(high.trailingZeroBitCount >= upperBound)
assert(low.leadingZeroBitCount >= 32)
assert(low.trailingZeroBitCount <= 32)
let range = UInt32.min...UInt32.max
let high = UInt(UInt32.random(in: range)) << UInt(upperBound)
let low = UInt(UInt32.random(in: range))
XCTAssertTrue(high.leadingZeroBitCount < 64 - upperBound)
XCTAssertTrue(high.trailingZeroBitCount >= upperBound)
XCTAssertTrue(low.leadingZeroBitCount >= 32)
XCTAssertTrue(low.trailingZeroBitCount <= 32)
let rand: UInt = high | low
let cH = Int(bitPattern: rand)
return cH