[BigIntTests] Update testFloatingPoint_random()

This commit is contained in:
Ben Rimmington committed 2020-01-19 09:37:20 +00:00
1 parent 1b733de54a
commit 506ea36331
1 file changed
+22 -3
+22 -3
View File
@@ -175,9 +175,28 @@ final class BigIntTests: XCTestCase {
}
func testFloatingPoint_random() {
for _ in 0 ..< 1000 {
let random = Float64.random(in: -0x1p52 ... +0x1p52)
XCTAssertEqual(BigInt(random), BigInt(Int64(random)))
for _ in 0 ..< 100 {
let small = Float32.random(in: -10 ... +10)
XCTAssertEqual(BigInt(small), BigInt(Int64(small)))
let large = Float32.random(in: -0x1p23 ... +0x1p23)
XCTAssertEqual(BigInt(large), BigInt(Int64(large)))
}
for _ in 0 ..< 100 {
let small = Float64.random(in: -10 ... +10)
XCTAssertEqual(BigInt(small), BigInt(Int64(small)))
let large = Float64.random(in: -0x1p52 ... +0x1p52)
XCTAssertEqual(BigInt(large), BigInt(Int64(large)))
}
for _ in 0 ..< 100 {
let small = FloatXX.random(in: -10 ... +10)
XCTAssertEqual(BigInt(small), BigInt(Int64(small)))
let large = FloatXX.random(in: -0x1p52 ... +0x1p52)
XCTAssertEqual(BigInt(large), BigInt(Int64(large)))
}
}