diff --git a/Sources/TestKit2/Global+Types.swift b/Sources/TestKit2/Global+Types.swift index 82a92fe0..05e451c2 100644 --- a/Sources/TestKit2/Global+Types.swift +++ b/Sources/TestKit2/Global+Types.swift @@ -17,8 +17,8 @@ import CoreKit //=----------------------------------------------------------------------------= public let typesAsCoreInteger: [any CoreInteger.Type] = { - typesAsCoreIntegersAsSigned + - typesAsCoreIntegersAsUnsigned + typesAsCoreIntegerAsSigned + + typesAsCoreIntegerAsUnsigned }() public let typesAsCoreIntegerAsByte: [any CoreInteger.Type] = [ @@ -26,11 +26,11 @@ public let typesAsCoreIntegerAsByte: [any CoreInteger.Type] = [ U8.self, ] -public let typesAsCoreIntegersAsSigned: [any CoreIntegerAsSigned.Type] = [ +public let typesAsCoreIntegerAsSigned: [any CoreIntegerAsSigned.Type] = [ IX.self, I8.self, I16.self, I32.self, I64.self, ] -public let typesAsCoreIntegersAsUnsigned: [any CoreIntegerAsUnsigned.Type] = [ +public let typesAsCoreIntegerAsUnsigned: [any CoreIntegerAsUnsigned.Type] = [ UX.self, U8.self, U16.self, U32.self, U64.self, ] diff --git a/Tests/CoreKitTests/DataInteger+Addition.swift b/Tests/CoreKitTests/DataInteger+Addition.swift index 6e588394..3c72821b 100644 --- a/Tests/CoreKitTests/DataInteger+Addition.swift +++ b/Tests/CoreKitTests/DataInteger+Addition.swift @@ -24,7 +24,7 @@ import TestKit2 @Test( "DataInt/increment(by:plus:) - 0-by-0-plus-bit", Tag.List.tags(.exhaustive, .generic), - arguments: typesAsCoreIntegersAsUnsigned + arguments: typesAsCoreIntegerAsUnsigned ) func incrementByNonePlusBit(type: any CoreIntegerAsUnsigned.Type) throws { try whereIs(type) @@ -37,7 +37,7 @@ import TestKit2 @Test( "DataInt/decrement(by:plus:) - 0-by-0-plus-bit", Tag.List.tags(.exhaustive, .generic), - arguments: typesAsCoreIntegersAsUnsigned + arguments: typesAsCoreIntegerAsUnsigned ) func decrementByNonePlusBit(type: any CoreIntegerAsUnsigned.Type) throws { try whereIs(type) @@ -54,7 +54,7 @@ import TestKit2 @Test( "DataInt/decrement(by:plus:) - [bidirectional][uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func incrementByManyPlusBit(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -86,7 +86,7 @@ import TestKit2 @Test( "DataInt/decrement(by:plus:) - [bidirectional][uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func decrementByManyPlusBit(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -122,7 +122,7 @@ import TestKit2 @Test( "DataInt/increment(by:times:plus:) - [bidirectional][uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func incrementByManyTimesSomePlusSome(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -159,7 +159,7 @@ import TestKit2 @Test( "DataInt/decrement(by:times:plus:) - [bidirectional][uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func decrementByManyTimesSomePlusSome(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -200,7 +200,7 @@ import TestKit2 @Test( "DataInt/incrementSameSize(repeating:plus:) - [bidirectional][uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func incrementByRepsPlusBit(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -229,7 +229,7 @@ import TestKit2 @Test( "DataInt/decrementSameSize(repeating:plus:) - [bidirectional][uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func decrementByRepsPlusBit(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) diff --git a/Tests/CoreKitTests/DataInteger+Comparison.swift b/Tests/CoreKitTests/DataInteger+Comparison.swift index 232a16d1..ce81d4a9 100644 --- a/Tests/CoreKitTests/DataInteger+Comparison.swift +++ b/Tests/CoreKitTests/DataInteger+Comparison.swift @@ -23,7 +23,7 @@ import TestKit2 @Test( "DataInt/signum()", Tag.List.tags(.generic), - arguments: typesAsCoreIntegersAsUnsigned + arguments: typesAsCoreIntegerAsUnsigned ) func signum(_ type: any CoreIntegerAsUnsigned.Type) { whereIs(type) @@ -93,7 +93,7 @@ import TestKit2 @Test( "DataInt/compared(to:) - ignores body appendix extensions", Tag.List.tags(.generic), - arguments: typesAsCoreIntegersAsUnsigned + arguments: typesAsCoreIntegerAsUnsigned ) func comparisonIgnoresBodyAppendixExtensions(_ type: any CoreIntegerAsUnsigned.Type) { whereIs(type) diff --git a/Tests/CoreKitTests/DataInteger+Count.swift b/Tests/CoreKitTests/DataInteger+Count.swift index 20327016..fe839b74 100644 --- a/Tests/CoreKitTests/DataInteger+Count.swift +++ b/Tests/CoreKitTests/DataInteger+Count.swift @@ -20,7 +20,7 @@ import TestKit2 // MARK: Tests //=------------------------------------------------------------------------= - @Test("DataInt/size()", arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/size()", arguments: typesAsCoreIntegerAsUnsigned) func size(type: any CoreIntegerAsUnsigned.Type) { whereIs(type) @@ -48,7 +48,7 @@ import TestKit2 } } - @Test("DataInt/count(_:)", arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/count(_:)", arguments: typesAsCoreIntegerAsUnsigned) func count(type: any CoreIntegerAsUnsigned.Type) { whereIs(type) @@ -84,7 +84,7 @@ import TestKit2 } } - @Test("DataInt/ascending(_:)", arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/ascending(_:)", arguments: typesAsCoreIntegerAsUnsigned) func ascending(type: any CoreIntegerAsUnsigned.Type) { whereIs(type) @@ -134,7 +134,7 @@ import TestKit2 } } - @Test("DataInt/descending(_:)", arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/descending(_:)", arguments: typesAsCoreIntegerAsUnsigned) func descending(type: any CoreIntegerAsUnsigned.Type) { whereIs(type) diff --git a/Tests/CoreKitTests/DataInteger+Division.swift b/Tests/CoreKitTests/DataInteger+Division.swift index a0160965..d5617389 100644 --- a/Tests/CoreKitTests/DataInteger+Division.swift +++ b/Tests/CoreKitTests/DataInteger+Division.swift @@ -21,7 +21,7 @@ import TestKit2 // MARK: Tests x Many ÷ Some //=------------------------------------------------------------------------= - @Test("DataInt/division(_:) - 0-by-1 [uniform]", arguments: typesAsCoreIntegersAsUnsigned, fuzzers) + @Test("DataInt/division(_:) - 0-by-1 [uniform]", arguments: typesAsCoreIntegerAsUnsigned, fuzzers) func division01(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -34,7 +34,7 @@ import TestKit2 } } - @Test("DataInt/division(_:) - 1-by-1 [uniform]", arguments: typesAsCoreIntegersAsUnsigned, fuzzers) + @Test("DataInt/division(_:) - 1-by-1 [uniform]", arguments: typesAsCoreIntegerAsUnsigned, fuzzers) func division11(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -54,7 +54,7 @@ import TestKit2 } } - @Test("DataInt/division(_:) - X-by-1 [uniform]", arguments: typesAsCoreIntegersAsUnsigned, fuzzers) + @Test("DataInt/division(_:) - X-by-1 [uniform]", arguments: typesAsCoreIntegerAsUnsigned, fuzzers) func divisionX1(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) diff --git a/Tests/CoreKitTests/DataInteger+Elements.swift b/Tests/CoreKitTests/DataInteger+Elements.swift index 55c3f4dd..deea2219 100644 --- a/Tests/CoreKitTests/DataInteger+Elements.swift +++ b/Tests/CoreKitTests/DataInteger+Elements.swift @@ -21,7 +21,7 @@ import TestKit2 // MARK: Tests //=------------------------------------------------------------------------= - @Test("DataInt/buffer()", arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/buffer()", arguments: typesAsCoreIntegerAsUnsigned) func buffer(type: any CoreIntegerAsUnsigned.Type) throws { whereIs(type) @@ -75,7 +75,7 @@ import TestKit2 } } - @Test("DataInt/subscript(_:) - [uniform]", arguments: typesAsCoreIntegersAsUnsigned, fuzzers) + @Test("DataInt/subscript(_:) - [uniform]", arguments: typesAsCoreIntegerAsUnsigned, fuzzers) func element(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) { whereIs(type) diff --git a/Tests/CoreKitTests/DataInteger+Metadata.swift b/Tests/CoreKitTests/DataInteger+Metadata.swift index f47e4d97..c687d1fb 100644 --- a/Tests/CoreKitTests/DataInteger+Metadata.swift +++ b/Tests/CoreKitTests/DataInteger+Metadata.swift @@ -20,7 +20,7 @@ import TestKit2 // MARK: Tests //=------------------------------------------------------------------------= - @Test("DataInt.capacity", .tags(.generic), arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt.capacity", .tags(.generic), arguments: typesAsCoreIntegerAsUnsigned) func capacity(_ type: any CoreIntegerAsUnsigned.Type) throws { try whereIs(type) diff --git a/Tests/CoreKitTests/DataInteger+Multiplication.swift b/Tests/CoreKitTests/DataInteger+Multiplication.swift index 46216595..cd18d10c 100644 --- a/Tests/CoreKitTests/DataInteger+Multiplication.swift +++ b/Tests/CoreKitTests/DataInteger+Multiplication.swift @@ -25,7 +25,7 @@ import TestKit2 @Test( "DataInt/initialize(to:times:plus:) - none-by-none-plus-none", Tag.List.tags(.exhaustive, .generic), - arguments: typesAsCoreIntegersAsUnsigned + arguments: typesAsCoreIntegerAsUnsigned ) func multiplicationOfNoneByNonePlusNone(type: any CoreIntegerAsUnsigned.Type) throws { try whereIs(type) @@ -38,7 +38,7 @@ import TestKit2 @Test( "DataInt/initialize(to:times:plus:) - some-by-none-plus-some [uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func multiplicationOfSomeByNonePlusSome(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -55,7 +55,7 @@ import TestKit2 @Test( "DataInt/initialize(to:times:plus:) - some-by-some-plus-some [uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func multiplicationOfSomeBySomePlusSome(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -82,7 +82,7 @@ import TestKit2 @Test( "DataInt/initialize(to:times:plus:) - many-by-some-plus-some [uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func multiplicationOfManyBySomePlusSome(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -107,7 +107,7 @@ import TestKit2 @Test( "DataInt/initialize(to:times:plus:) - many-by-many-plus-some [uniform]", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func multiplicationOfManyByManyPlusSome(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) diff --git a/Tests/CoreKitTests/DataInteger+Partition.swift b/Tests/CoreKitTests/DataInteger+Partition.swift index e93a1d0a..d6a1ea31 100644 --- a/Tests/CoreKitTests/DataInteger+Partition.swift +++ b/Tests/CoreKitTests/DataInteger+Partition.swift @@ -20,7 +20,7 @@ import TestKit2 // MARK: Tests //=------------------------------------------------------------------------= - @Test("DataInt/split(at:)", .tags(.generic), arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/split(at:)", .tags(.generic), arguments: typesAsCoreIntegerAsUnsigned) func split(_ type: any CoreIntegerAsUnsigned.Type) { whereIs(type) @@ -68,7 +68,7 @@ import TestKit2 // MARK: Tests //=------------------------------------------------------------------------= - @Test("DataInt/body", .tags(.generic), arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/body", .tags(.generic), arguments: typesAsCoreIntegerAsUnsigned) func body(_ type: any CoreIntegerAsUnsigned.Type) { whereIs(type) @@ -92,7 +92,7 @@ import TestKit2 // MARK: Tests //=------------------------------------------------------------------------= - @Test("DataInt/normalized()", .tags(.generic), arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/normalized()", .tags(.generic), arguments: typesAsCoreIntegerAsUnsigned) func normalized(_ type: any CoreIntegerAsUnsigned.Type) { whereIs(type) @@ -150,7 +150,7 @@ import TestKit2 // MARK: Tests //=------------------------------------------------------------------------= - @Test("DataInt/prefix(_:)", .tags(.generic), arguments: typesAsCoreIntegersAsUnsigned) + @Test("DataInt/prefix(_:)", .tags(.generic), arguments: typesAsCoreIntegerAsUnsigned) func prefix(_ type: any CoreIntegerAsUnsigned.Type) { whereIs(type) diff --git a/Tests/CoreKitTests/DataInteger+Shift.swift b/Tests/CoreKitTests/DataInteger+Shift.swift index 1f5a36d7..24cd527a 100644 --- a/Tests/CoreKitTests/DataInteger+Shift.swift +++ b/Tests/CoreKitTests/DataInteger+Shift.swift @@ -24,7 +24,7 @@ import TestKit2 @Test( "DataInt/shift: upshift(major:minor:environment:)", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func upshift(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) @@ -58,7 +58,7 @@ import TestKit2 @Test( "DataInt/shift: downshift(major:minor:environment:)", Tag.List.tags(.generic, .random), - arguments: typesAsCoreIntegersAsUnsigned, fuzzers + arguments: typesAsCoreIntegerAsUnsigned, fuzzers ) func downshift(type: any CoreIntegerAsUnsigned.Type, randomness: consuming FuzzerInt) throws { try whereIs(type) diff --git a/Tests/DoubleIntKitTests/DoubleInt.swift b/Tests/DoubleIntKitTests/DoubleInt.swift index 5ad3f183..6de876c4 100644 --- a/Tests/DoubleIntKitTests/DoubleInt.swift +++ b/Tests/DoubleIntKitTests/DoubleInt.swift @@ -34,25 +34,6 @@ import TestKit2 // MARK: Metadata //=------------------------------------------------------------------------= - static let types: [any SystemsInteger.Type] = { - typesAsSigned + - typesAsUnsigned - }() - - static let typesAsSigned: [any SystemsIntegerAsSigned.Type] = [ - I8x2.self, - I8x4.self, - IXx2.self, - IXx4.self, - ] - - static let typesAsUnsigned: [any SystemsIntegerAsUnsigned.Type] = [ - U8x2.self, - U8x4.self, - UXx2.self, - UXx4.self, - ] - static let bases: [any SystemsInteger.Type] = { basesAsSigned + basesAsUnsigned @@ -91,7 +72,6 @@ import TestKit2 } } - @Test("DoubleInt: bitcasting", .tags(.generic, .random), arguments: Self.bases, fuzzers) func bitcasting(base: any SystemsInteger.Type, randomness: consuming FuzzerInt) throws { @@ -99,7 +79,7 @@ import TestKit2 func whereIs(_ base: B.Type) throws where B: SystemsInteger { typealias T = DoubleInt - for _ in 0 ..< 32 { + for _ in 0 ..< 8 { let low = T.Low .random(using: &randomness) let high = T.High.random(using: &randomness) let full = T(low: low, high: high) @@ -120,7 +100,7 @@ import TestKit2 func whereIs(_ base: B.Type) throws where B: SystemsInteger { typealias T = DoubleInt - for _ in 0 ..< 32 { + for _ in 0 ..< 8 { let low = T.Low .random(using: &randomness) let high = T.High.random(using: &randomness) diff --git a/Tests/DoubleIntKitTests/TripleInt+Addition.swift b/Tests/DoubleIntKitTests/TripleInt+Addition.swift index 9f8ca35c..dd6e3245 100644 --- a/Tests/DoubleIntKitTests/TripleInt+Addition.swift +++ b/Tests/DoubleIntKitTests/TripleInt+Addition.swift @@ -15,7 +15,7 @@ import TestKit // MARK: * Triple Int x Addition //*============================================================================* -extension TripleIntTests { +final class TripleIntTestsOnAddition: XCTestCase { //=------------------------------------------------------------------------= // MARK: Tests @@ -56,11 +56,11 @@ extension TripleIntTests { Test().same(Y(low: ~3, mid: ~5, high: ~0).plus(X(low: 4, high: 5)), F(Y(low: 0, mid: 0, high: 0), error: true)) } - for base in Self.basesAsSigned { + for base in TripleIntTests.basesAsSigned { whereTheBaseIsSigned(base) } - for base in Self.basesAsUnsigned { + for base in TripleIntTests.basesAsUnsigned { whereTheBaseIsUnsigned(base) } } @@ -100,11 +100,11 @@ extension TripleIntTests { Test().same(Y(low: ~3, mid: ~5, high: ~6).plus(Y(low: 4, mid: 5, high: 6)), F(Y(low: 0, mid: 0, high: 0), error: true)) } - for base in Self.basesAsSigned { + for base in TripleIntTests.basesAsSigned { whereTheBaseIsSigned(base) } - for base in Self.basesAsUnsigned { + for base in TripleIntTests.basesAsUnsigned { whereTheBaseIsUnsigned(base) } } diff --git a/Tests/DoubleIntKitTests/TripleInt+Bitwise.swift b/Tests/DoubleIntKitTests/TripleInt+Bitwise.swift index b4e512cf..8e4970fe 100644 --- a/Tests/DoubleIntKitTests/TripleInt+Bitwise.swift +++ b/Tests/DoubleIntKitTests/TripleInt+Bitwise.swift @@ -15,8 +15,8 @@ import TestKit // MARK: * Triple Int x Bitwise //*============================================================================* -extension TripleIntTests { - +final class TripleIntTestsOnBitwise: XCTestCase { + //=------------------------------------------------------------------------= // MARK: Tests //=------------------------------------------------------------------------= @@ -37,7 +37,7 @@ extension TripleIntTests { Test().complement(T(low: 0, mid: 0, high: B.msb), true, F(T(low: 0, mid: 0, high: B.msb), error: B.isSigned)) } - for base in Self.bases { + for base in TripleIntTests.bases { whereTheBaseIs(base) } } diff --git a/Tests/DoubleIntKitTests/TripleInt+Comparison.swift b/Tests/DoubleIntKitTests/TripleInt+Comparison.swift index 47ae3c0b..7d732d0c 100644 --- a/Tests/DoubleIntKitTests/TripleInt+Comparison.swift +++ b/Tests/DoubleIntKitTests/TripleInt+Comparison.swift @@ -15,8 +15,8 @@ import TestKit // MARK: * Triple Int x Comparison //*============================================================================* -extension TripleIntTests { - +final class TripleIntTestsOnComparison: XCTestCase { + //=------------------------------------------------------------------------= // MARK: Tests //=------------------------------------------------------------------------= @@ -141,7 +141,7 @@ extension TripleIntTests { Test().comparison(T(low: ~2, mid: ~2, high: ~2), b1, Signum.negative) } - for base in Self.bases { + for base in TripleIntTests.bases { whereTheBaseIs(base) } } diff --git a/Tests/DoubleIntKitTests/TripleInt+Division.swift b/Tests/DoubleIntKitTests/TripleInt+Division.swift index 1d3b484c..58244c7b 100644 --- a/Tests/DoubleIntKitTests/TripleInt+Division.swift +++ b/Tests/DoubleIntKitTests/TripleInt+Division.swift @@ -15,7 +15,7 @@ import TestKit // MARK: * Triple Int x Division //*============================================================================* -extension TripleIntTests { +final class TripleIntTestsOnDivision: XCTestCase { //=------------------------------------------------------------------------= // MARK: Tests @@ -38,7 +38,7 @@ extension TripleIntTests { Test().division3212MSB(Y(low: ~0, mid: ~0, high: B.msb - 1), X(low: ~0, high: B.msb), D(quotient: ~1 as B, remainder: X(low: ~2, high: 2))) // 1 } - for base in Self.basesAsUnsigned { + for base in TripleIntTests.basesAsUnsigned { whereTheBaseIs(base) } } diff --git a/Tests/DoubleIntKitTests/TripleInt+Subtraction.swift b/Tests/DoubleIntKitTests/TripleInt+Subtraction.swift index e9884e5c..149a3d7d 100644 --- a/Tests/DoubleIntKitTests/TripleInt+Subtraction.swift +++ b/Tests/DoubleIntKitTests/TripleInt+Subtraction.swift @@ -15,8 +15,8 @@ import TestKit // MARK: * Triple Int x Subtraction //*============================================================================* -extension TripleIntTests { - +final class TripleIntTestsOnSubtraction: XCTestCase { + //=------------------------------------------------------------------------= // MARK: Tests //=------------------------------------------------------------------------= @@ -56,11 +56,11 @@ extension TripleIntTests { Test().same(Y(low: 3, mid: 5, high: 0).minus(X(low: 4, high: 5)), F(Y(low: ~0, mid: ~0, high: ~0), error: true)) } - for base in Self.basesAsSigned { + for base in TripleIntTests.basesAsSigned { whereTheBaseIsSigned(base) } - for base in Self.basesAsUnsigned { + for base in TripleIntTests.basesAsUnsigned { whereTheBaseIsUnsigned(base) } } @@ -100,11 +100,11 @@ extension TripleIntTests { Test().same(Y(low: 3, mid: 5, high: 6).minus(Y(low: 4, mid: 5, high: 6)), F(Y(low: ~0, mid: ~0, high: ~0), error: true)) } - for base in Self.basesAsSigned { + for base in TripleIntTests.basesAsSigned { whereTheBaseIsSigned(base) } - for base in Self.basesAsUnsigned { + for base in TripleIntTests.basesAsUnsigned { whereTheBaseIsUnsigned(base) } } diff --git a/Tests/DoubleIntKitTests/TripleInt.swift b/Tests/DoubleIntKitTests/TripleInt.swift index f41b6fa9..2b852b4e 100644 --- a/Tests/DoubleIntKitTests/TripleInt.swift +++ b/Tests/DoubleIntKitTests/TripleInt.swift @@ -9,16 +9,15 @@ import CoreKit import DoubleIntKit -import TestKit +import RandomIntKit +import TestKit2 //*============================================================================* // MARK: * Triple Int //*============================================================================* -final class TripleIntTests: XCTestCase { - - typealias X3 = TripleInt where Base: SystemsInteger - +@Suite struct TripleIntTests { + typealias I8x3 = TripleInt typealias U8x3 = TripleInt @@ -34,11 +33,11 @@ final class TripleIntTests: XCTestCase { basesAsUnsigned }() - static let basesAsSigned: [any (SystemsInteger & SignedInteger).Type] = { + static let basesAsSigned: [any SystemsIntegerAsSigned.Type] = { typesAsCoreIntegerAsSigned }() - static let basesAsUnsigned: [any (SystemsInteger & UnsignedInteger).Type] = { + static let basesAsUnsigned: [any SystemsIntegerAsUnsigned.Type] = { typesAsCoreIntegerAsUnsigned }() @@ -46,131 +45,117 @@ final class TripleIntTests: XCTestCase { // MARK: Tests //=------------------------------------------------------------------------= - func testInvariants() { - func whereTheBaseIs(_ type: B.Type) where B: SystemsInteger { + @Test("TripleInt: invariants", .tags(.generic), arguments: Self.bases) + func invariants(base: any SystemsInteger.Type) throws { + + try whereIs(base) + func whereIs(_ type: B.Type) throws where B: SystemsInteger { typealias T = TripleInt - typealias M = TripleInt.Magnitude - Test().same(T.mode, B.mode) - Test().same(T.size, Count(3 * IX(size: B.self))) + #expect(T.mode == B.mode) + #expect(T.size == Count(3 * IX(size: B.self))) } + } + + @Test("TripleInt: layout", .tags(.generic), arguments: Self.bases) + func layout(base: any SystemsInteger.Type) throws { - for base in Self.bases { - whereTheBaseIs(base) + try whereIs(base) + func whereIs(_ base: B.Type) throws where B: SystemsInteger { + typealias T = TripleInt + typealias U = (B, B, B) + + #expect(MemoryLayout.size == 3 * MemoryLayout.size) + #expect(MemoryLayout.stride == 3 * MemoryLayout.stride) + #expect(MemoryLayout.alignment == 1 * MemoryLayout.alignment) + Ɣexpect(MemoryLayout.self, equals: MemoryLayout.self) } } - func testComponents() { - func whereTheBaseIs(_ type: B.Type) where B: SystemsInteger { + @Test("TripleInt: bitcasting", .tags(.generic, .random), arguments: Self.bases, fuzzers) + func bitcasting(base: any SystemsInteger.Type, randomness: consuming FuzzerInt) throws { + + try whereIs(base) + func whereIs(_ base: B.Type) throws where B: SystemsInteger { typealias T = TripleInt - Test().same(T( ).low, 0 as B.Magnitude) - Test().same(T( ).mid, 0 as B.Magnitude) - Test().same(T( ).high, 0 as B) - Test().same(T( ).low, 0 as B.Magnitude) - Test().same(T( ).mid, 0 as B.Magnitude) - Test().same(T( ).high, 0 as B) - Test().same(T(low: 0 ).low, 0 as B.Magnitude) - Test().same(T(low: 0 ).mid, 0 as B.Magnitude) - Test().same(T(low: 0 ).high, 0 as B) - Test().same(T(low: 1 ).low, 1 as B.Magnitude) - Test().same(T(low: 1 ).mid, 0 as B.Magnitude) - Test().same(T(low: 1 ).high, 0 as B) - Test().same(T(low: 0, mid: 0 ).low, 0 as B.Magnitude) - Test().same(T(low: 0, mid: 0 ).mid, 0 as B.Magnitude) - Test().same(T(low: 0, mid: 0 ).high, 0 as B) - Test().same(T(low: 1, mid: 2 ).low, 1 as B.Magnitude) - Test().same(T(low: 1, mid: 2 ).mid, 2 as B.Magnitude) - Test().same(T(low: 1, mid: 2 ).high, 0 as B) - Test().same(T(low: 0, mid: 0, high: 0).low, 0 as B.Magnitude) - Test().same(T(low: 0, mid: 0, high: 0).mid, 0 as B.Magnitude) - Test().same(T(low: 0, mid: 0, high: 0).high, 0 as B) - Test().same(T(low: 1, mid: 2, high: 3).low, 1 as B.Magnitude) - Test().same(T(low: 1, mid: 2, high: 3).mid, 2 as B.Magnitude) - Test().same(T(low: 1, mid: 2, high: 3).high, 3 as B) - - Test().same(T(low: 0, high: Doublet(low: 0, high: 0)).low, 0 as B.Magnitude) - Test().same(T(low: 0, high: Doublet(low: 0, high: 0)).mid, 0 as B.Magnitude) - Test().same(T(low: 0, high: Doublet(low: 0, high: 0)).high, 0 as B) - Test().same(T(low: 1, high: Doublet(low: 2, high: 3)).low, 1 as B.Magnitude) - Test().same(T(low: 1, high: Doublet(low: 2, high: 3)).mid, 2 as B.Magnitude) - Test().same(T(low: 1, high: Doublet(low: 2, high: 3)).high, 3 as B) - - Test().same(T(low: Doublet(low: 0, high: 0) ).low, 0 as B.Magnitude) - Test().same(T(low: Doublet(low: 0, high: 0) ).mid, 0 as B.Magnitude) - Test().same(T(low: Doublet(low: 0, high: 0) ).high, 0 as B) - Test().same(T(low: Doublet(low: 1, high: 2) ).low, 1 as B.Magnitude) - Test().same(T(low: Doublet(low: 1, high: 2) ).mid, 2 as B.Magnitude) - Test().same(T(low: Doublet(low: 1, high: 2) ).high, 0 as B) - Test().same(T(low: Doublet(low: 0, high: 0), high: 0).low, 0 as B.Magnitude) - Test().same(T(low: Doublet(low: 0, high: 0), high: 0).mid, 0 as B.Magnitude) - Test().same(T(low: Doublet(low: 0, high: 0), high: 0).high, 0 as B) - Test().same(T(low: Doublet(low: 1, high: 2), high: 3).low, 1 as B.Magnitude) - Test().same(T(low: Doublet(low: 1, high: 2), high: 3).mid, 2 as B.Magnitude) - Test().same(T(low: Doublet(low: 1, high: 2), high: 3).high, 3 as B) - - setters: do { - let rhs = T(low: 1, mid: 2, high: 3) - var lhs = T(low: 0, mid: 0, high: 0) + for _ in 0 ..< 8 { + let low = T.Low .random(using: &randomness) + let mid = T.Mid .random(using: &randomness) + let high = T.High.random(using: &randomness) + let full = T(low: low, mid: mid, high: high) - lhs.low = rhs.low - lhs.mid = rhs.mid - lhs.high = rhs.high + try #require(full == T(raw: T.Magnitude(raw: full))) + try #require(full == T(raw: T.Signitude(raw: full))) - Test().same(lhs, rhs) + try #require(full == T(raw: T.Magnitude(low: low, mid: mid, high: B.Magnitude(raw: high)))) + try #require(full == T(raw: T.Signitude(low: low, mid: mid, high: B.Signitude(raw: high)))) } - - components: do { - var low: B.Magnitude - var mid: B.Magnitude - var high: B - - (low, mid, high) = T(low: 0, mid: 0, high: 0).components() - Test().same(low, 0 as B.Magnitude) - Test().same(mid, 0 as B.Magnitude) - Test().same(high, 0 as B) - - (low, mid, high) = T(low: 1, mid: 2, high: 3).components() - Test().same(low, 1 as B.Magnitude) - Test().same(mid, 2 as B.Magnitude) - Test().same(high, 3 as B) - } - } - - for base in Self.bases { - whereTheBaseIs(base) } } - func testBitCast() { - func whereTheBaseIs(_ type: B.Type) where B: SystemsInteger { - typealias T = TripleInt - typealias S = T.Signitude - typealias M = T.Magnitude - - Test().same(M(raw: T(low: 1, mid: 2, high: 3)), M(low: 1, mid: 2, high: 3)) - Test().same(S(raw: T(low: 1, mid: 2, high: 3)), S(low: 1, mid: 2, high: 3)) - Test().same(M(raw: T(low: ~1, mid: ~2, high: ~3)), M(low: ~1, mid: ~2, high: ~3)) - Test().same(S(raw: T(low: ~1, mid: ~2, high: ~3)), S(low: ~1, mid: ~2, high: ~3)) - } + @Test("TripleInt: components", .tags(.generic, .random), arguments: Self.bases, fuzzers) + func components(base: any SystemsInteger.Type, randomness: consuming FuzzerInt) throws { - for base in Self.bases { - whereTheBaseIs(base) - } - } - - func testMemoryLayout() { - func whereTheBaseIs(_ type: B.Type) where B: SystemsInteger { + try whereIs(base) + func whereIs(_ base: B.Type) throws where B: SystemsInteger { typealias T = TripleInt - Test().same(MemoryLayout.self, MemoryLayout<(B, B, B)>.self) - Test().same(MemoryLayout.size, 3 * MemoryLayout.size) - Test().same(MemoryLayout.stride, 3 * MemoryLayout.stride) - Test().same(MemoryLayout.alignment, 1 * MemoryLayout.alignment) - } - - for base in Self.bases { - whereTheBaseIs(base) + for _ in 0 ..< 8 { + let low = T.Low .random(using: &randomness) + let mid = T.Mid .random(using: &randomness) + let high = T.High.random(using: &randomness) + + always: do { + try #require(T().low .isZero) + try #require(T().mid .isZero) + try #require(T().high.isZero) + } + + always: do { + try #require(T(low: low).low == low) + try #require(T(low: low).mid .isZero) + try #require(T(low: low).high.isZero) + } + + always: do { + try #require(T(low: low, mid: mid).low == low) + try #require(T(low: low, mid: mid).mid == mid) + try #require(T(low: low, mid: mid).high.isZero) + } + + always: do { + try #require(T(low: low, mid: mid, high: high).low == low ) + try #require(T(low: low, mid: mid, high: high).mid == mid ) + try #require(T(low: low, mid: mid, high: high).high == high) + } + + always: do { + try #require(T(low: Doublet(low: low, high: mid), high: high).low == low ) + try #require(T(low: Doublet(low: low, high: mid), high: high).mid == mid ) + try #require(T(low: Doublet(low: low, high: mid), high: high).high == high) + } + + always: do { + try #require(T(low: low, high: Doublet(low: mid, high: high)).low == low ) + try #require(T(low: low, high: Doublet(low: mid, high: high)).mid == mid ) + try #require(T(low: low, high: Doublet(low: mid, high: high)).high == high) + } + + getter: do { + try #require(T(low: low, mid: mid, high: high).components() == (low, mid, high)) + } + + setter: do { + var full = T() + full.low = low + full.mid = mid + full.high = high + try #require(full.low == low ) + try #require(full.mid == mid ) + try #require(full.high == high) + } + } } } }