Skip to content

Commit

Permalink
[Tests] Cleanup of BinaryInteger+Stdlib.swift.
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Oct 25, 2024
1 parent d5dc8f0 commit 1a3de4e
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions Tests/UltimathnumTests/BinaryInteger+Stdlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,37 @@ import TestKit2
// MARK: Tests
//=------------------------------------------------------------------------=

@Test("BinaryInteger/stdlib - uniform", arguments: typesAsCoreInteger, fuzzers)
func stdlib(_ type: any CoreInteger.Type, _ randomness: consuming FuzzerInt) {
whereIs(type)
@Test(
"BinaryInteger/stdlib: conversions",
Tag.List.tags(.generic, .random),
arguments: typesAsCoreInteger, fuzzers
) func conversions(type: any CoreInteger.Type, randomness: consuming FuzzerInt) throws {
try whereIs(type)

func whereIs<T>(_ type: T.Type) where T: CoreInteger {
func whereIs<T>(_ type: T.Type) throws where T: CoreInteger {
for _ in 0 ..< 16 {
var a = T.random(using: &randomness)
var b = T.random(using: &randomness)
let x = a
let y = b

#expect(a == x)
#expect(b == y)
#expect(T(a.stdlib) == x)
#expect(T(b.stdlib) == y)
#expect(T(a.stdlib()) == x)
#expect(T(b.stdlib()) == y)
try #require(a == x)
try #require(b == y)
try #require(T(a.stdlib) == x)
try #require(T(b.stdlib) == y)
try #require(T(a.stdlib()) == x)
try #require(T(b.stdlib()) == y)

a.stdlib ^= b.stdlib
b.stdlib ^= a.stdlib
a.stdlib ^= b.stdlib

#expect(a == y)
#expect(b == x)
#expect(T(a.stdlib) == y)
#expect(T(b.stdlib) == x)
#expect(T(a.stdlib()) == y)
#expect(T(b.stdlib()) == x)
try #require(a == y)
try #require(b == x)
try #require(T(a.stdlib) == y)
try #require(T(b.stdlib) == x)
try #require(T(a.stdlib()) == y)
try #require(T(b.stdlib()) == x)
}
}
}
Expand Down

0 comments on commit 1a3de4e

Please sign in to comment.