From 506ea363314afdf3396b9cf28223954e1bfb75aa Mon Sep 17 00:00:00 2001 From: Ben Rimmington Date: Sun, 19 Jan 2020 09:37:20 +0000 Subject: [PATCH] [BigIntTests] Update testFloatingPoint_random() --- Tests/BigIntTests/BigIntTests.swift | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Tests/BigIntTests/BigIntTests.swift b/Tests/BigIntTests/BigIntTests.swift index 9c826c9..ae8236f 100644 --- a/Tests/BigIntTests/BigIntTests.swift +++ b/Tests/BigIntTests/BigIntTests.swift @@ -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))) } }