Skip to content

Commit

Permalink
BigInt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Apr 9, 2022
1 parent 01deea7 commit 4b6ff62
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions IntegrationTests/TestSuites/Sources/PrimaryTests/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -853,4 +853,35 @@ try test("JSValueDecoder") {
}


try test("BigInt") {
func expectPassesThrough(signed value: Int64) throws {
let bigInt = JSBigInt(value)
try expectEqual(bigInt.description, value.description)
}

func expectPassesThrough(unsigned value: UInt64) throws {
let bigInt = JSBigInt(unsigned: value)
try expectEqual(bigInt.description, value.description)
}

try expectPassesThrough(signed: 0)
try expectPassesThrough(signed: 1 << 62)
try expectPassesThrough(signed: -2305)
for _ in 0 ..< 100 {
try expectPassesThrough(signed: .random(in: .min ... .max))
}
try expectPassesThrough(signed: .min)
try expectPassesThrough(signed: .max)

try expectPassesThrough(unsigned: 0)
try expectPassesThrough(unsigned: 1 << 62)
try expectPassesThrough(unsigned: 1 << 63)
try expectPassesThrough(unsigned: .min)
try expectPassesThrough(unsigned: .max)
try expectPassesThrough(unsigned: ~0)
for _ in 0 ..< 100 {
try expectPassesThrough(unsigned: .random(in: .min ... .max))
}
}

Expectation.wait(expectations)

0 comments on commit 4b6ff62

Please sign in to comment.