From 7740703f495f7a9f8c72a15442bc635a8a5de010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Bystr=C3=B6m=20Ericsson?= Date: Mon, 11 Sep 2023 09:11:01 +0200 Subject: [PATCH] [NBKFlexibleWidthKit] Dropped NBKResizableWidthKit (#33) (#46). --- ...NBKResizableWidthKit-Benchmarks.xctestplan | 24 -- .swiftpm/NBKResizableWidthKit.xctestplan | 32 -- .swiftpm/Numberick-Benchmarks.xctestplan | 7 - .swiftpm/Numberick.xctestplan | 12 - .../xcschemes/Numberick-Benchmarks.xcscheme | 3 - .../xcshareddata/xcschemes/Numberick.xcscheme | 3 - Package.swift | 22 +- README.md | 8 - .../NBKFlexibleWidth+Addition+Digit.swift | 1 - .../NBKFlexibleWidth+Addition.swift | 1 - .../NBKFlexibleWidth+Bits.swift | 1 - .../NBKFlexibleWidth+Comparisons.swift | 1 - .../NBKFlexibleWidth+Complements.swift | 1 - .../NBKFlexibleWidth+Division+Digit.swift | 1 - .../NBKFlexibleWidth+Division.swift | 1 - .../NBKFlexibleWidth+Logic.swift | 1 - ...BKFlexibleWidth+Multiplication+Digit.swift | 1 - .../NBKFlexibleWidth+Multiplication.swift | 1 - .../NBKFlexibleWidth+Numbers.swift | 1 - .../NBKFlexibleWidth+Shifts.swift | 1 - .../NBKFlexibleWidth+Size.swift | 1 - .../NBKFlexibleWidth+Subtraction+Digit.swift | 1 - .../NBKFlexibleWidth+Subtraction.swift | 1 - .../NBKFlexibleWidth+Text.swift | 1 - .../NBKFlexibleWidth+Update.swift | 1 - .../NBKFlexibleWidth+Words.swift | 1 - .../NBKFlexibleWidth.swift | 1 - .../NBKResizableWidth+Addition+Digit.swift | 0 .../NBKResizableWidth+Addition.swift | 0 .../NBKResizableWidth+Bits.swift | 0 .../NBKResizableWidth+Comparisons.swift | 0 .../NBKResizableWidth+Complements.swift | 0 .../NBKResizableWidth+Division+Digit.swift | 0 .../NBKResizableWidth+Division.swift | 0 .../NBKResizableWidth+Literals.swift | 0 .../NBKResizableWidth+Logic.swift | 0 ...KResizableWidth+Multiplication+Digit.swift | 0 .../NBKResizableWidth+Multiplication.swift | 0 .../NBKResizableWidth+Numbers.swift | 0 .../NBKResizableWidth+Protocols.swift | 0 .../NBKResizableWidth+Shifts.swift | 0 .../NBKResizableWidth+Size.swift | 0 .../NBKResizableWidth+Subtraction+Digit.swift | 0 .../NBKResizableWidth+Subtraction.swift | 0 .../NBKResizableWidth+Text.swift | 2 + .../NBKResizableWidth+Uninitialized.swift | 0 .../NBKResizableWidth+Update.swift | 0 .../NBKResizableWidth+Words+Pointers.swift | 0 .../NBKResizableWidth+Words.swift | 0 .../NBKResizableWidth.swift | 0 .../NBKResizableWidth+Bits.swift | 124 -------- .../NBKResizableWidth+Comparisons.swift | 150 --------- .../NBKResizableWidth+Logic.swift | 117 -------- .../NBKResizableWidth+Shifts.swift | 152 ---------- .../NBKResizableWidth+Words.swift | 46 --- .../NBKResizableWidth.swift | 42 --- .../NBKResizableWidth+Bits.swift | 99 ------ .../NBKResizableWidth+Comparisons.swift | 284 ------------------ .../NBKResizableWidth+Logic.swift | 131 -------- .../NBKResizableWidth+Shifts.swift | 206 ------------- .../NBKResizableWidth+Words.swift | 176 ----------- .../NBKResizableWidth.swift | 42 --- 62 files changed, 3 insertions(+), 1698 deletions(-) delete mode 100644 .swiftpm/NBKResizableWidthKit-Benchmarks.xctestplan delete mode 100644 .swiftpm/NBKResizableWidthKit.xctestplan rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Addition+Digit.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Addition.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Bits.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Comparisons.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Complements.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Division+Digit.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Division.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Literals.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Logic.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Multiplication+Digit.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Multiplication.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Numbers.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Protocols.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Shifts.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Size.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Subtraction+Digit.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Subtraction.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Text.swift (98%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Uninitialized.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Update.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Words+Pointers.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth+Words.swift (100%) rename Sources/{ => NBKFlexibleWidthKit}/NBKResizableWidthKit/NBKResizableWidth.swift (100%) delete mode 100644 Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Bits.swift delete mode 100644 Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Comparisons.swift delete mode 100644 Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Logic.swift delete mode 100644 Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Shifts.swift delete mode 100644 Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Words.swift delete mode 100644 Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth.swift delete mode 100644 Tests/NBKResizableWidthKitTests/NBKResizableWidth+Bits.swift delete mode 100644 Tests/NBKResizableWidthKitTests/NBKResizableWidth+Comparisons.swift delete mode 100644 Tests/NBKResizableWidthKitTests/NBKResizableWidth+Logic.swift delete mode 100644 Tests/NBKResizableWidthKitTests/NBKResizableWidth+Shifts.swift delete mode 100644 Tests/NBKResizableWidthKitTests/NBKResizableWidth+Words.swift delete mode 100644 Tests/NBKResizableWidthKitTests/NBKResizableWidth.swift diff --git a/.swiftpm/NBKResizableWidthKit-Benchmarks.xctestplan b/.swiftpm/NBKResizableWidthKit-Benchmarks.xctestplan deleted file mode 100644 index c2f15441..00000000 --- a/.swiftpm/NBKResizableWidthKit-Benchmarks.xctestplan +++ /dev/null @@ -1,24 +0,0 @@ -{ - "configurations" : [ - { - "id" : "2BBD9A51-D890-4B97-AED4-B9962867DF57", - "name" : "Main", - "options" : { - - } - } - ], - "defaultOptions" : { - "codeCoverage" : false - }, - "testTargets" : [ - { - "target" : { - "containerPath" : "container:", - "identifier" : "NBKResizableWidthKitBenchmarks", - "name" : "NBKResizableWidthKitBenchmarks" - } - } - ], - "version" : 1 -} diff --git a/.swiftpm/NBKResizableWidthKit.xctestplan b/.swiftpm/NBKResizableWidthKit.xctestplan deleted file mode 100644 index 1f0eca5f..00000000 --- a/.swiftpm/NBKResizableWidthKit.xctestplan +++ /dev/null @@ -1,32 +0,0 @@ -{ - "configurations" : [ - { - "id" : "6FC9897F-2BF3-4836-8372-787CE5195F87", - "name" : "Main", - "options" : { - - } - } - ], - "defaultOptions" : { - "codeCoverage" : { - "targets" : [ - { - "containerPath" : "container:", - "identifier" : "NBKResizableWidthKit", - "name" : "NBKResizableWidthKit" - } - ] - } - }, - "testTargets" : [ - { - "target" : { - "containerPath" : "container:", - "identifier" : "NBKResizableWidthKitTests", - "name" : "NBKResizableWidthKitTests" - } - } - ], - "version" : 1 -} diff --git a/.swiftpm/Numberick-Benchmarks.xctestplan b/.swiftpm/Numberick-Benchmarks.xctestplan index 36ca600d..b7a219a1 100644 --- a/.swiftpm/Numberick-Benchmarks.xctestplan +++ b/.swiftpm/Numberick-Benchmarks.xctestplan @@ -42,13 +42,6 @@ "identifier" : "NBKFlexibleWidthKitBenchmarks", "name" : "NBKFlexibleWidthKitBenchmarks" } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "NBKResizableWidthKitBenchmarks", - "name" : "NBKResizableWidthKitBenchmarks" - } } ], "version" : 1 diff --git a/.swiftpm/Numberick.xctestplan b/.swiftpm/Numberick.xctestplan index a8c7369c..74306fdc 100644 --- a/.swiftpm/Numberick.xctestplan +++ b/.swiftpm/Numberick.xctestplan @@ -25,11 +25,6 @@ "containerPath" : "container:", "identifier" : "NBKFlexibleWidthKit", "name" : "NBKFlexibleWidthKit" - }, - { - "containerPath" : "container:", - "identifier" : "NBKResizableWidthKit", - "name" : "NBKResizableWidthKit" } ] } @@ -55,13 +50,6 @@ "identifier" : "NBKFlexibleWidthKitTests", "name" : "NBKFlexibleWidthKitTests" } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "NBKResizableWidthKitTests", - "name" : "NBKResizableWidthKitTests" - } } ], "version" : 1 diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Numberick-Benchmarks.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Numberick-Benchmarks.xcscheme index d829dc1f..8cf9cef5 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/Numberick-Benchmarks.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/Numberick-Benchmarks.xcscheme @@ -38,9 +38,6 @@ - - diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Numberick.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Numberick.xcscheme index e28d3bac..7e8b10d0 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/Numberick.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/Numberick.xcscheme @@ -76,9 +76,6 @@ - - diff --git a/Package.swift b/Package.swift index 444aa103..ca59bbb2 100644 --- a/Package.swift +++ b/Package.swift @@ -54,12 +54,6 @@ var package = Package( .library( name: "NBKFlexibleWidthKit", targets: ["NBKFlexibleWidthKit"]), - //=--------------------------------------= - // NBK x Resizable Width Kit - //=--------------------------------------= - .library( - name: "NBKResizableWidthKit", - targets: ["NBKResizableWidthKit"]), ], targets: [ //=--------------------------------------= @@ -101,7 +95,7 @@ var package = Package( //=--------------------------------------= .target( name: "NBKFlexibleWidthKit", - dependencies: ["NBKCoreKit", "NBKResizableWidthKit"]), + dependencies: ["NBKCoreKit"]), .testTarget( name: "NBKFlexibleWidthKitBenchmarks", @@ -110,20 +104,6 @@ var package = Package( .testTarget( name: "NBKFlexibleWidthKitTests", dependencies: ["NBKFlexibleWidthKit"]), - //=--------------------------------------= - // NBK x Resizable Width Kit - //=--------------------------------------= - .target( - name: "NBKResizableWidthKit", - dependencies: ["NBKCoreKit"]), - - .testTarget( - name: "NBKResizableWidthKitBenchmarks", - dependencies: ["NBKResizableWidthKit"]), - - .testTarget( - name: "NBKResizableWidthKitTests", - dependencies: ["NBKResizableWidthKit"]), ] ) diff --git a/README.md b/README.md index 7ca90095..859af472 100644 --- a/README.md +++ b/README.md @@ -105,10 +105,6 @@ Int256(5) % Int(5), UInt256(5) % UInt(5) 👨‍💻🛠️🚧🧱🧱🏗️🧱🧱🚧⏳ -## [NBKResizableWidthKit][RES/D] ([Sources][RES/S], [Tests][RES/T], [Benchmarks][RES/B]) - -👨‍💻🛠️🚧🧱🧱🏗️🧱🧱🚧⏳ - ## Acknowledgements This project is inspired by [**Int128**][Apple/Int128] and [**DoubleWidth**][Apple/DoubleWidth] by Apple. @@ -118,22 +114,18 @@ This project is inspired by [**Int128**][Apple/Int128] and [**DoubleWidth**][App [NBK/D]: https://oscbyspro.github.io/Numberick/documentation/numberick [DBL/D]: https://oscbyspro.github.io/Numberick/documentation/numberick/nbkdoublewidth [FLX/D]: https://oscbyspro.github.io/Numberick/documentation/numberick/nbkflexiblewidth -[RES/D]: https://oscbyspro.github.io/Numberick/documentation/numberick/nbkresizablewidth [COR/S]: Sources/NBKCoreKit [DBL/S]: Sources/NBKDoubleWidthKit [FLX/S]: Sources/NBKFlexibleWidthKit -[RES/S]: Sources/NBKResizableWidthKit [COR/T]: Tests/NBKCoreKitTests [DBL/T]: Tests/NBKDoubleWidthKitTests [FLX/T]: Tests/NBKFlexibleWidthKitTests -[RES/T]: Tests/NBKResizableWidthKitTests [COR/B]: Tests/NBKCoreKitBenchmarks [DBL/B]: Tests/NBKDoubleWidthKitBenchmarks [FLX/B]: Tests/NBKFlexibleWidthKitBenchmarks -[RES/B]: Tests/NBKResizableWidthKitBenchmarks diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Addition+Digit.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Addition+Digit.swift index cdc168a5..4b66a975 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Addition+Digit.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Addition+Digit.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Addition x Digit x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Addition.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Addition.swift index c0e35557..e61d899b 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Addition.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Addition.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Addition x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Bits.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Bits.swift index c024126e..2a021653 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Bits.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Bits.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Bits x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Comparisons.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Comparisons.swift index 551239cf..def8ce40 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Comparisons.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Comparisons.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Comparisons x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Complements.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Complements.swift index 39ff5c27..1c74ea10 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Complements.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Complements.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Complements x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Division+Digit.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Division+Digit.swift index e1e5d857..66f7e7b9 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Division+Digit.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Division+Digit.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Division x Digit x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Division.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Division.swift index 0ed355eb..f514fb7e 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Division.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Division.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Division x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Logic.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Logic.swift index 29caa943..3d70f1f5 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Logic.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Logic.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Logic x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Multiplication+Digit.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Multiplication+Digit.swift index 0486f3df..1d6e3038 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Multiplication+Digit.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Multiplication+Digit.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Multiplication x Digit x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Multiplication.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Multiplication.swift index 8fde35ce..fd0f5b21 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Multiplication.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Multiplication.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Multiplication x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Numbers.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Numbers.swift index ddff8df9..a50ff1f9 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Numbers.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Numbers.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Numbers x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Shifts.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Shifts.swift index 32a4f0e2..e60b8bb5 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Shifts.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Shifts.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Shifts x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Size.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Size.swift index b6d86c8d..c4b3bb2e 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Size.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Size.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Size x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Subtraction+Digit.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Subtraction+Digit.swift index 33881815..4bd5fc07 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Subtraction+Digit.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Subtraction+Digit.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Subtraction x Digit x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Subtraction.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Subtraction.swift index a443026b..b1acf0e8 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Subtraction.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Subtraction.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Subtraction diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Text.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Text.swift index 9e5a8276..ca58a24e 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Text.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Text.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Text x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Update.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Update.swift index f68992f1..60c180d8 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Update.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Update.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Miscellaneous x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Words.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Words.swift index f5d15ca4..cf177d24 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Words.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth+Words.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width x Words x Signed diff --git a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth.swift b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth.swift index 95d59d74..adaf47ca 100644 --- a/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth.swift +++ b/Sources/NBKFlexibleWidthKit/NBKFlexibleWidth.swift @@ -8,7 +8,6 @@ //=----------------------------------------------------------------------------= import NBKCoreKit -import NBKResizableWidthKit //*============================================================================* // MARK: * NBK x Flexible Width diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Addition+Digit.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Addition+Digit.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Addition+Digit.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Addition+Digit.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Addition.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Addition.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Addition.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Addition.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Bits.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Bits.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Bits.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Bits.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Comparisons.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Comparisons.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Comparisons.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Comparisons.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Complements.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Complements.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Complements.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Complements.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Division+Digit.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Division+Digit.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Division+Digit.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Division+Digit.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Division.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Division.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Division.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Division.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Literals.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Literals.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Literals.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Literals.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Logic.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Logic.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Logic.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Logic.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Multiplication+Digit.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Multiplication+Digit.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Multiplication+Digit.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Multiplication+Digit.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Multiplication.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Multiplication.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Multiplication.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Multiplication.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Numbers.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Numbers.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Numbers.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Numbers.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Protocols.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Protocols.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Protocols.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Protocols.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Shifts.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Shifts.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Shifts.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Shifts.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Size.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Size.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Size.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Size.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Subtraction+Digit.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Subtraction+Digit.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Subtraction+Digit.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Subtraction+Digit.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Subtraction.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Subtraction.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Subtraction.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Subtraction.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Text.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Text.swift similarity index 98% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Text.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Text.swift index f729c255..2f986d6b 100644 --- a/Sources/NBKResizableWidthKit/NBKResizableWidth+Text.swift +++ b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Text.swift @@ -7,6 +7,8 @@ // See http://www.apache.org/licenses/LICENSE-2.0 for license information. //=----------------------------------------------------------------------------= +import NBKCoreKit + //*============================================================================* // MARK: * NBK x Resizable Width x Text //*============================================================================* diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Uninitialized.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Uninitialized.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Uninitialized.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Uninitialized.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Update.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Update.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Update.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Update.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Words+Pointers.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Words+Pointers.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Words+Pointers.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Words+Pointers.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth+Words.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Words.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth+Words.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth+Words.swift diff --git a/Sources/NBKResizableWidthKit/NBKResizableWidth.swift b/Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth.swift similarity index 100% rename from Sources/NBKResizableWidthKit/NBKResizableWidth.swift rename to Sources/NBKFlexibleWidthKit/NBKResizableWidthKit/NBKResizableWidth.swift diff --git a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Bits.swift b/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Bits.swift deleted file mode 100644 index a3a8c7d2..00000000 --- a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Bits.swift +++ /dev/null @@ -1,124 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if !DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Bits x UIntXR -//*============================================================================* - -final class NBKResizableWidthBenchmarksOnBitsAsUIntXR: XCTestCase { - - typealias T = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testInitBit() { - var abc = NBK.blackHoleIdentity(true ) - var xyz = NBK.blackHoleIdentity(false) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(T(bit: abc)) - NBK.blackHole(T(bit: xyz)) - - NBK.blackHoleInoutIdentity(&abc) - NBK.blackHoleInoutIdentity(&xyz) - } - } - - func testBitWidth() { - var abc = NBK.blackHoleIdentity( T(x64:[0, 0, 0, 0] as X)) - var xyz = NBK.blackHoleIdentity(~T(x64:[0, 0, 0, 0] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.bitWidth) - NBK.blackHole(xyz.bitWidth) - - NBK.blackHoleInoutIdentity(&abc) - NBK.blackHoleInoutIdentity(&xyz) - } - } - - func testNonzeroBitCount() { - var abc = NBK.blackHoleIdentity( T(x64:[0, 0, 0, 0] as X)) - var xyz = NBK.blackHoleIdentity(~T(x64:[0, 0, 0, 0] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.nonzeroBitCount) - NBK.blackHole(xyz.nonzeroBitCount) - - NBK.blackHoleInoutIdentity(&abc) - NBK.blackHoleInoutIdentity(&xyz) - } - } - - func testLeadingZeroBitCount() { - var abc = NBK.blackHoleIdentity( T(x64:[0, 0, 0, 0] as X)) - var xyz = NBK.blackHoleIdentity(~T(x64:[0, 0, 0, 0] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.leadingZeroBitCount) - NBK.blackHole(xyz.leadingZeroBitCount) - - NBK.blackHoleInoutIdentity(&abc) - NBK.blackHoleInoutIdentity(&xyz) - } - } - - func testTrailingZeroBitCount() { - var abc = NBK.blackHoleIdentity( T(x64:[0, 0, 0, 0] as X)) - var xyz = NBK.blackHoleIdentity(~T(x64:[0, 0, 0, 0] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.trailingZeroBitCount) - NBK.blackHole(xyz.trailingZeroBitCount) - - NBK.blackHoleInoutIdentity(&abc) - NBK.blackHoleInoutIdentity(&xyz) - } - } - - func testMostSignificantBit() { - var abc = NBK.blackHoleIdentity( T(x64:[0, 0, 0, 0] as X)) - var xyz = NBK.blackHoleIdentity(~T(x64:[0, 0, 0, 0] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.mostSignificantBit) - NBK.blackHole(xyz.mostSignificantBit) - - NBK.blackHoleInoutIdentity(&abc) - NBK.blackHoleInoutIdentity(&xyz) - } - } - - func testLeastSignificantBit() { - var abc = NBK.blackHoleIdentity( T(x64:[0, 0, 0, 0] as X)) - var xyz = NBK.blackHoleIdentity(~T(x64:[0, 0, 0, 0] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.leastSignificantBit) - NBK.blackHole(xyz.leastSignificantBit) - - NBK.blackHoleInoutIdentity(&abc) - NBK.blackHoleInoutIdentity(&xyz) - } - } -} - -#endif diff --git a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Comparisons.swift b/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Comparisons.swift deleted file mode 100644 index 81233d5b..00000000 --- a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Comparisons.swift +++ /dev/null @@ -1,150 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if !DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Comparisons x UIntXR -//*============================================================================* - -final class NBKResizableWidthBenchmarksOnComparisonsAsUIntXR: XCTestCase { - - typealias T = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testIsZero() { - var abc = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.isZero) - NBK.blackHoleInoutIdentity(&abc) - } - } - - func testIsLessThanZero() { - var abc = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.isLessThanZero) - NBK.blackHoleInoutIdentity(&abc) - } - } - - func testIsMoreThanZero() { - var abc = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.isMoreThanZero) - NBK.blackHoleInoutIdentity(&abc) - } - } - - func testIsPowerOf2() { - var abc = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.isPowerOf2) - NBK.blackHoleInoutIdentity(&abc) - } - } - - func testSignum() { - var abc = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.signum()) - NBK.blackHoleInoutIdentity(&abc) - } - } - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testIsEqualTo() { - var lhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs == rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testIsLessThan() { - var lhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs < rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testComparedTo() { - var lhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs.compared(to: rhs)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testComparedToAtIndex() { - var lhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[1, 2, 3, 0] as X)) - let xyz = NBK.blackHoleIdentity(1 as Int) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs.compared(to: rhs, at: xyz)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testComparedToDigit() { - var lhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - var rhs = NBK.blackHoleIdentity(UInt.max) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs.compared(to: rhs)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testComparedToDigitAtIndex() { - var lhs = NBK.blackHoleIdentity(T(x64:[0, 1, 2, 3] as X)) - var rhs = NBK.blackHoleIdentity(UInt( 3)) - let xyz = NBK.blackHoleIdentity(3 as Int) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs.compared(to: rhs, at: xyz)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } -} - -#endif diff --git a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Logic.swift b/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Logic.swift deleted file mode 100644 index c84d3acd..00000000 --- a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Logic.swift +++ /dev/null @@ -1,117 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if !DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Logic x UIntXR -//*============================================================================* - -final class NBKResizableWidthBenchmarksOnLogicAsUIntXR: XCTestCase { - - typealias T = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testNotInout() { - var abc = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(abc.formOnesComplement()) - NBK.blackHoleInoutIdentity(&abc) - } - } - - func testNot() { - var abc = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(~abc) - NBK.blackHoleInoutIdentity(&abc) - } - } - - func testAndInout() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[ 0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs &= rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testAnd() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[ 0, 1, 2, 3] as X)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs & rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testOrInout() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[ 0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs |= rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testOr() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[ 0, 1, 2, 3] as X)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs | rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testXorInout() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[ 0, 1, 2, 3] as X)) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(lhs ^= rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testXor() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(T(x64:[ 0, 1, 2, 3] as X)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs ^ rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } -} - -#endif diff --git a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Shifts.swift b/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Shifts.swift deleted file mode 100644 index c745d9be..00000000 --- a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Shifts.swift +++ /dev/null @@ -1,152 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if !DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Shifts x UIntXR -//*============================================================================* - -final class NBKResizableWidthBenchmarksOnShiftsAsUIntXR: XCTestCase { - - typealias T = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests x Left - //=------------------------------------------------------------------------= - - func testBitshiftingLeft() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(UInt.bitWidth * 3/2) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs << rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testBitshiftingLeftByWords() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity((words: 1, bits: UInt.bitWidth/2)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs.bitshiftedLeft(words: rhs.words)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testBitshiftingLeftByWordsAndBits() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity((words: 1, bits: UInt.bitWidth/2)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs.bitshiftedLeft(words: rhs.words, bits: rhs.bits)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - //=------------------------------------------------------------------------= - // MARK: Tests x Right - //=------------------------------------------------------------------------= - - func testBitshiftingRight() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(UInt.bitWidth * 3/2) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs >> rhs) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testBitshiftingRightByWords() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity((words: 1, bits: UInt.bitWidth/2)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs.bitshiftedRight(words: rhs.words)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testBitshiftingRightByWordsAndBits() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity((words: 1, bits: UInt.bitWidth/2)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs.bitshiftedRight(words: rhs.words, bits: rhs.bits)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - //=------------------------------------------------------------------------= - // MARK: Tests x In Both Directions - //=------------------------------------------------------------------------= - - func testBitshiftingInBothDirectionsInout() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity(UInt.bitWidth * 3/2) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs.bitshiftLeft (by: rhs)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - - NBK.blackHole(lhs.bitshiftRight(by: rhs)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testBitshiftingInBothDirectionsByWordsInout() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity((words: 1, bits: UInt.bitWidth/2)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs.bitshiftLeft (words: rhs.words)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - - NBK.blackHole(lhs.bitshiftRight(words: rhs.words)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } - - func testBitshiftingInBothDirectionsByWordsAndBitsInout() { - var lhs = NBK.blackHoleIdentity(T(x64:[~0, ~1, ~2, ~3] as X)) - var rhs = NBK.blackHoleIdentity((words: 1, bits: UInt.bitWidth/2)) - - for _ in 0 ..< 1_000_000 { - NBK.blackHole(lhs.bitshiftLeft (words: rhs.words, bits: rhs.bits)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - - NBK.blackHole(lhs.bitshiftRight(words: rhs.words, bits: rhs.bits)) - NBK.blackHoleInoutIdentity(&lhs) - NBK.blackHoleInoutIdentity(&rhs) - } - } -} - -#endif diff --git a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Words.swift b/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Words.swift deleted file mode 100644 index 9461d00d..00000000 --- a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth+Words.swift +++ /dev/null @@ -1,46 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if !DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Words x UIntXR -//*============================================================================* - -final class NBKResizableWidthBenchmarksOnWordsAsUIntXR: XCTestCase { - - typealias T = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testFromWords() { - var abc = NBK.blackHoleIdentity([ 0, 0, 0, 0] as W) - var xyz = NBK.blackHoleIdentity([~0, ~0, ~0, ~0] as W) - - for _ in 0 ..< 5_000_000 { - NBK.blackHole(T(words: abc)) - NBK.blackHole(T(words: xyz)) - - NBK.blackHoleInoutIdentity(&abc) - NBK.blackHoleInoutIdentity(&xyz) - } - } -} - -#endif diff --git a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth.swift b/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth.swift deleted file mode 100644 index 3c57b0b3..00000000 --- a/Tests/NBKResizableWidthKitBenchmarks/NBKResizableWidth.swift +++ /dev/null @@ -1,42 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Initializers x UIntXR -//*============================================================================* - -extension NBKResizableWidth.Magnitude { - - //=------------------------------------------------------------------------= - // MARK: Details x Numbers - //=------------------------------------------------------------------------= - - static let min256 = Self(x64:[ 0, 0, 0, 0] as X) - static let max256 = Self(x64:[~0, ~0, ~0, ~0] as X) - - //=------------------------------------------------------------------------= - // MARK: Details x Limbs - //=------------------------------------------------------------------------= - - init(x32: [UInt32]) { - self.init(words: NBKChunkedInt(x32)) - } - - init(x64: [UInt64]) { - self.init(words: NBKChunkedInt(x64)) - } -} diff --git a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Bits.swift b/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Bits.swift deleted file mode 100644 index 790ff3ca..00000000 --- a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Bits.swift +++ /dev/null @@ -1,99 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Bits x UIntXR -//*============================================================================* - -final class NBKResizableWidthTestsOnBitsAsUIntXR: XCTestCase { - - typealias T = UIntXR - typealias M = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testInitBit() { - XCTAssertEqual(T(bit: false), T( )) - XCTAssertEqual(T(bit: true ), T(1)) - } - - func testBitWidth() { - XCTAssertEqual(T(words:[ 0, 0, 0, 0] as W).bitWidth, UInt.bitWidth * 4) - XCTAssertEqual(T(words:[~0, ~0, ~0, ~0] as W).bitWidth, UInt.bitWidth * 4) - } - - func testNonzeroBitCount() { - XCTAssertEqual(T(words:[ 0, 0, 0, 0] as W).nonzeroBitCount, 0) - XCTAssertEqual(T(words:[ 1, 1, 1, 1] as W).nonzeroBitCount, 4) - } - - func testLeadingZeroBitCount() { - XCTAssertEqual(T(words:[ 0, 0, 0, 0] as W).leadingZeroBitCount, UInt.bitWidth * 4) - XCTAssertEqual(T(words:[~0, ~0, ~0, ~0] as W).leadingZeroBitCount, UInt.bitWidth * 0) - - XCTAssertEqual(T(words:[ 2, 0, 0, 0] as W).leadingZeroBitCount, UInt.bitWidth * 4 - 2) - XCTAssertEqual(T(words:[ 0, 2, 0, 0] as W).leadingZeroBitCount, UInt.bitWidth * 3 - 2) - XCTAssertEqual(T(words:[ 0, 0, 2, 0] as W).leadingZeroBitCount, UInt.bitWidth * 2 - 2) - XCTAssertEqual(T(words:[ 0, 0, 0, 2] as W).leadingZeroBitCount, UInt.bitWidth * 1 - 2) - } - - func testTrailingZeroBitCount() { - XCTAssertEqual(T(words:[ 0, 0, 0, 0] as W).trailingZeroBitCount, UInt.bitWidth * 4) - XCTAssertEqual(T(words:[~0, ~0, ~0, ~0] as W).trailingZeroBitCount, UInt.bitWidth * 0) - - XCTAssertEqual(T(words:[ 2, 0, 0, 0] as W).trailingZeroBitCount, UInt.bitWidth * 0 + 1) - XCTAssertEqual(T(words:[ 0, 2, 0, 0] as W).trailingZeroBitCount, UInt.bitWidth * 1 + 1) - XCTAssertEqual(T(words:[ 0, 0, 2, 0] as W).trailingZeroBitCount, UInt.bitWidth * 2 + 1) - XCTAssertEqual(T(words:[ 0, 0, 0, 2] as W).trailingZeroBitCount, UInt.bitWidth * 3 + 1) - } - - func testMostSignificantBit() { - XCTAssertEqual(T(words:[ 0, 0, 0, 0] as W).mostSignificantBit, false) - XCTAssertEqual(T(words:[~0, ~0, ~0, ~0] as W).mostSignificantBit, true ) - - XCTAssertEqual(T(words:[~0, 0, 0, 0] as W).mostSignificantBit, false) - XCTAssertEqual(T(words:[ 0, ~0, 0, 0] as W).mostSignificantBit, false) - XCTAssertEqual(T(words:[ 0, 0, ~0, 0] as W).mostSignificantBit, false) - XCTAssertEqual(T(words:[ 0, 0, 0, ~0] as W).mostSignificantBit, true ) - - XCTAssertEqual(T(words:[~0, 1, 0, 0] as W).mostSignificantBit, false) - XCTAssertEqual(T(words:[ 0, ~0, 1, 0] as W).mostSignificantBit, false) - XCTAssertEqual(T(words:[ 0, 0, ~0, 1] as W).mostSignificantBit, false) - XCTAssertEqual(T(words:[ 1, 0, 0, ~0] as W).mostSignificantBit, true ) - } - - func testLeastSignificantBit() { - XCTAssertEqual(T(words:[ 0, 0, 0, 0] as W).leastSignificantBit, false) - XCTAssertEqual(T(words:[~0, ~0, ~0, ~0] as W).leastSignificantBit, true ) - - XCTAssertEqual(T(words:[~0, 0, 0, 0] as W).leastSignificantBit, true ) - XCTAssertEqual(T(words:[ 0, ~0, 0, 0] as W).leastSignificantBit, false) - XCTAssertEqual(T(words:[ 0, 0, ~0, 0] as W).leastSignificantBit, false) - XCTAssertEqual(T(words:[ 0, 0, 0, ~0] as W).leastSignificantBit, false) - - XCTAssertEqual(T(words:[~0, 1, 0, 0] as W).leastSignificantBit, true ) - XCTAssertEqual(T(words:[ 0, ~0, 1, 0] as W).leastSignificantBit, false) - XCTAssertEqual(T(words:[ 0, 0, ~0, 1] as W).leastSignificantBit, false) - XCTAssertEqual(T(words:[ 1, 0, 0, ~0] as W).leastSignificantBit, true ) - } -} - -#endif diff --git a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Comparisons.swift b/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Comparisons.swift deleted file mode 100644 index 49ce4961..00000000 --- a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Comparisons.swift +++ /dev/null @@ -1,284 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Comparisons x UIntXR -//*============================================================================* - -final class NBKResizableWidthTestsOnComparisonsAsUIntXR: XCTestCase { - - typealias T = UIntXR - typealias M = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testIsZero() { - XCTAssertTrue (T(words:[ 0] as W).isZero) - XCTAssertFalse(T(words:[ 1] as W).isZero) - XCTAssertFalse(T(words:[ 2] as W).isZero) - - XCTAssertFalse(T(words:[~0] as W).isZero) - XCTAssertFalse(T(words:[~1] as W).isZero) - XCTAssertFalse(T(words:[~2] as W).isZero) - } - - func testIsLessThanZero() { - XCTAssertFalse(T(words:[ 0] as W).isLessThanZero) - XCTAssertFalse(T(words:[ 1] as W).isLessThanZero) - XCTAssertFalse(T(words:[ 2] as W).isLessThanZero) - - XCTAssertFalse(T(words:[~0] as W).isLessThanZero) - XCTAssertFalse(T(words:[~1] as W).isLessThanZero) - XCTAssertFalse(T(words:[~2] as W).isLessThanZero) - } - - func testIsMoreThanZero() { - XCTAssertFalse(T(words:[ 0] as W).isMoreThanZero) - XCTAssertTrue (T(words:[ 1] as W).isMoreThanZero) - XCTAssertTrue (T(words:[ 2] as W).isMoreThanZero) - - XCTAssertTrue (T(words:[~0] as W).isMoreThanZero) - XCTAssertTrue (T(words:[~1] as W).isMoreThanZero) - XCTAssertTrue (T(words:[~2] as W).isMoreThanZero) - } - - func testIsOdd() { - XCTAssertFalse(T(words:[ 0] as W).isOdd) - XCTAssertTrue (T(words:[ 1] as W).isOdd) - XCTAssertFalse(T(words:[ 2] as W).isOdd) - - XCTAssertTrue (T(words:[~0] as W).isOdd) - XCTAssertFalse(T(words:[~1] as W).isOdd) - XCTAssertTrue (T(words:[~2] as W).isOdd) - } - - func testIsEven() { - XCTAssertTrue (T(words:[ 0] as W).isEven) - XCTAssertFalse(T(words:[ 1] as W).isEven) - XCTAssertTrue (T(words:[ 2] as W).isEven) - - XCTAssertFalse(T(words:[~0] as W).isEven) - XCTAssertTrue (T(words:[~1] as W).isEven) - XCTAssertFalse(T(words:[~2] as W).isEven) - } - - func testIsPowerOf2() { - XCTAssertFalse(T(words:[ 0] as W).isPowerOf2) - XCTAssertTrue (T(words:[ 1] as W).isPowerOf2) - XCTAssertTrue (T(words:[ 2] as W).isPowerOf2) - XCTAssertFalse(T(words:[ 3] as W).isPowerOf2) - XCTAssertTrue (T(words:[ 4] as W).isPowerOf2) - XCTAssertFalse(T(words:[ 5] as W).isPowerOf2) - XCTAssertFalse(T(words:[ 6] as W).isPowerOf2) - XCTAssertFalse(T(words:[ 7] as W).isPowerOf2) - - XCTAssertFalse(T(words:[ 0, 0, 0, 0] as W).isPowerOf2) - XCTAssertTrue (T(words:[ 1, 0, 0, 0] as W).isPowerOf2) - XCTAssertFalse(T(words:[ 1, 1, 0, 0] as W).isPowerOf2) - XCTAssertTrue (T(words:[ 0, 1, 0, 0] as W).isPowerOf2) - XCTAssertFalse(T(words:[ 0, 1, 1, 0] as W).isPowerOf2) - XCTAssertTrue (T(words:[ 0, 0, 1, 0] as W).isPowerOf2) - XCTAssertFalse(T(words:[ 0, 0, 1, 1] as W).isPowerOf2) - XCTAssertTrue (T(words:[ 0, 0, 0, 1] as W).isPowerOf2) - } - - func testSignum() { - NBKAssertSignum(T(words:[ 0] as W), Int(0)) - NBKAssertSignum(T(words:[ 1] as W), Int(1)) - NBKAssertSignum(T(words:[ 2] as W), Int(1)) - - NBKAssertSignum(T(words:[~0] as W), Int(1)) - NBKAssertSignum(T(words:[~1] as W), Int(1)) - NBKAssertSignum(T(words:[~2] as W), Int(1)) - } - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testHashing() { - var union = Set() - union.insert(T(words:[0, 0, 0, 0] as W)) - union.insert(T(words:[0, 0, 0, 0] as W)) - union.insert(T(words:[1, 0, 0, 0] as W)) - union.insert(T(words:[1, 0, 0, 0] as W)) - union.insert(T(words:[0, 1, 0, 0] as W)) - union.insert(T(words:[0, 1, 0, 0] as W)) - union.insert(T(words:[0, 0, 1, 0] as W)) - union.insert(T(words:[0, 0, 1, 0] as W)) - union.insert(T(words:[0, 0, 0, 1] as W)) - union.insert(T(words:[0, 0, 0, 1] as W)) - XCTAssertEqual(union.count, 5 as Int) - } - - func testComparing() { - NBKAssertComparisons(T(words:[0, 2, 3, 4] as W), T(words:[1, 2, 3, 4] as W), -Int(1)) - NBKAssertComparisons(T(words:[1, 0, 3, 4] as W), T(words:[1, 2, 3, 4] as W), -Int(1)) - NBKAssertComparisons(T(words:[1, 2, 0, 4] as W), T(words:[1, 2, 3, 4] as W), -Int(1)) - NBKAssertComparisons(T(words:[1, 2, 3, 0] as W), T(words:[1, 2, 3, 4] as W), -Int(1)) - NBKAssertComparisons(T(words:[0, 2, 3, 4] as W), T(words:[0, 2, 3, 4] as W), Int(0)) - NBKAssertComparisons(T(words:[1, 0, 3, 4] as W), T(words:[1, 0, 3, 4] as W), Int(0)) - NBKAssertComparisons(T(words:[1, 2, 0, 4] as W), T(words:[1, 2, 0, 4] as W), Int(0)) - NBKAssertComparisons(T(words:[1, 2, 3, 0] as W), T(words:[1, 2, 3, 0] as W), Int(0)) - NBKAssertComparisons(T(words:[1, 2, 3, 4] as W), T(words:[0, 2, 3, 4] as W), Int(1)) - NBKAssertComparisons(T(words:[1, 2, 3, 4] as W), T(words:[1, 0, 3, 4] as W), Int(1)) - NBKAssertComparisons(T(words:[1, 2, 3, 4] as W), T(words:[1, 2, 0, 4] as W), Int(1)) - NBKAssertComparisons(T(words:[1, 2, 3, 4] as W), T(words:[1, 2, 3, 0] as W), Int(1)) - } - - func testComparingAtIndex() { - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(0), Int(0)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(1), Int(0)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(2), Int(0)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(3), Int(0)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(4), Int(0)) - - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(0), -Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(1), -Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(2), -Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(3), -Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 0, 0, 0, 0, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(4), -Int(1)) - - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(0), Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(1), Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(2), Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(3), Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[0, 0, 0, 0] as W), Int(4), Int(1)) - - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(0), Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(1), Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(2), Int(0)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(3), -Int(1)) - NBKAssertComparisonsAtIndex(T(words:[0, 0, 1, 2, 3, 4, 0, 0] as W), T(words:[1, 2, 3, 4] as W), Int(4), -Int(1)) - } - - func testComparingByDigit() { - NBKAssertComparisonsByDigit(T(0), UInt(0), Int(0)) - NBKAssertComparisonsByDigit(T(1), UInt(1), Int(0)) - NBKAssertComparisonsByDigit(T(2), UInt(3), -Int(1)) - NBKAssertComparisonsByDigit(T(3), UInt(2), Int(1)) - - NBKAssertComparisonsByDigit(T(words:[0, 0, 0, 0]), UInt(1), -Int(1)) - NBKAssertComparisonsByDigit(T(words:[1, 0, 0, 0]), UInt(1), Int(0)) - NBKAssertComparisonsByDigit(T(words:[2, 0, 0, 0]), UInt(1), Int(1)) - - NBKAssertComparisonsByDigit(T(words:[0, 1, 0, 0]), UInt(1), Int(1)) - NBKAssertComparisonsByDigit(T(words:[1, 1, 0, 0]), UInt(1), Int(1)) - NBKAssertComparisonsByDigit(T(words:[2, 1, 0, 0]), UInt(1), Int(1)) - } - - func testComparingByDigitAtIndex() { - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(4), Int(0), Int(1)) - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(4), Int(1), Int(1)) - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(4), Int(2), Int(1)) - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(4), Int(3), Int(1)) - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(4), Int(4), -Int(1)) - - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(5), Int(0), Int(1)) - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(5), Int(1), Int(1)) - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(5), Int(2), Int(1)) - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(5), Int(3), -Int(1)) - NBKAssertComparisonsByDigitAtIndex(T(words:[1, 2, 3, 4]), UInt(5), Int(4), -Int(1)) - } - - //=------------------------------------------------------------------------= - // MARK: Tests x Miscellaneous - //=------------------------------------------------------------------------= - - func testOverloadsAreUnambiguous() { - func becauseThisCompilesSuccessfully(_ x: inout T) { - XCTAssertNotNil(x.signum()) - } - } - - func testOverloadsAreUnambiguousWhenUsingIntegerLiterals() { - func becauseThisCompilesSuccessfully(_ x: inout T) { - XCTAssertNotNil(x.compared(to: 0)) - XCTAssertNotNil(x.compared(to: 0, at: 0)) - } - } -} - -//*============================================================================* -// MARK: * NBK x Resizable Width x Comparisons x Assertions -//*============================================================================* - -private func NBKAssertSignum( -_ operand: T, _ signum: Int, -file: StaticString = #file, line: UInt = #line) { - XCTAssertEqual(Int(operand.signum() as Int), signum, file: file, line: line) - // TODO: stdlib implementation requires subtraction - // XCTAssertEqual(Int(operand.signum() as T ), signum, file: file, line: line) // stdlib -} - -private func NBKAssertComparisons( -_ lhs: T, _ rhs: T, _ signum: Int, -file: StaticString = #file, line: UInt = #line) { - XCTAssertEqual(lhs == rhs, signum == 0, file: file, line: line) - XCTAssertEqual(lhs != rhs, signum != 0, file: file, line: line) - - XCTAssertEqual(lhs < rhs, signum == -1, file: file, line: line) - XCTAssertEqual(lhs <= rhs, signum != 1, file: file, line: line) - - XCTAssertEqual(lhs > rhs, signum == 1, file: file, line: line) - XCTAssertEqual(lhs >= rhs, signum != -1, file: file, line: line) - - XCTAssertEqual(lhs.compared(to: rhs), signum, file: file, line: line) -} - -private func NBKAssertComparisonsAtIndex( -_ lhs: T, _ rhs: T, _ index: Int, _ signum: Int, -file: StaticString = #file, line: UInt = #line) { - //=------------------------------------------= - if index.isZero { - NBKAssertComparisons(lhs, rhs, signum, file: file, line: line) - } - //=------------------------------------------= - XCTAssertEqual(lhs.compared(to: rhs, at: index), signum, file: file, line: line) -} - -private func NBKAssertComparisonsByDigit( -_ lhs: T, _ rhs: T.Digit, _ signum: Int, -file: StaticString = #file, line: UInt = #line) { - XCTAssertEqual(lhs == rhs, signum == 0, file: file, line: line) - XCTAssertEqual(lhs != rhs, signum != 0, file: file, line: line) - - XCTAssertEqual(lhs < rhs, signum == -1, file: file, line: line) - XCTAssertEqual(lhs <= rhs, signum != 1, file: file, line: line) - - XCTAssertEqual(lhs > rhs, signum == 1, file: file, line: line) - XCTAssertEqual(lhs >= rhs, signum != -1, file: file, line: line) - - XCTAssertEqual(lhs.compared(to: rhs), signum, file: file, line: line) -} - -private func NBKAssertComparisonsByDigitAtIndex( -_ lhs: T, _ rhs: T.Digit, _ index: Int, _ signum: Int, -file: StaticString = #file, line: UInt = #line) { - //=------------------------------------------= - if index.isZero { - NBKAssertComparisonsByDigit(lhs, rhs, signum, file: file, line: line) - } - //=------------------------------------------= - XCTAssertEqual(lhs.compared(to: rhs, at: index), signum, file: file, line: line) -} - -#endif diff --git a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Logic.swift b/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Logic.swift deleted file mode 100644 index 40bf33ca..00000000 --- a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Logic.swift +++ /dev/null @@ -1,131 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Logic x UIntXR -//*============================================================================* - -final class NBKResizableWidthTestsOnLogicAsUIntXR: XCTestCase { - - typealias T = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testNot() { - NBKAssertNot(T(words:[ 0, 0, 0, 0] as W), T(words:[~0, ~0, ~0, ~0] as W)) - NBKAssertNot(T(words:[~0, ~0, ~0, ~0] as W), T(words:[ 0, 0, 0, 0] as W)) - - NBKAssertNot(T(words:[ 0, 1, 2, 3] as W), T(words:[~0, ~1, ~2, ~3] as W)) - NBKAssertNot(T(words:[~0, ~1, ~2, ~3] as W), T(words:[ 0, 1, 2, 3] as W)) - } - - func testAnd() { - NBKAssertAnd(T(words:[ 0, 1, 2, 3] as W), T(words:[ 0, 0, 0, 0] as W), T(words:[ 0, 0, 0, 0] as W)) - NBKAssertAnd(T(words:[ 3, 2, 1, 0] as W), T(words:[ 0, 0, 0, 0] as W), T(words:[ 0, 0, 0, 0] as W)) - - NBKAssertAnd(T(words:[ 0, 1, 2, 3] as W), T(words:[~0, ~0, ~0, ~0] as W), T(words:[ 0, 1, 2, 3] as W)) - NBKAssertAnd(T(words:[ 3, 2, 1, 0] as W), T(words:[~0, ~0, ~0, ~0] as W), T(words:[ 3, 2, 1, 0] as W)) - - NBKAssertAnd(T(words:[ 0, 1, 2, 3] as W), T(words:[ 1, 1, 1, 1] as W), T(words:[ 0, 1, 0, 1] as W)) - NBKAssertAnd(T(words:[ 3, 2, 1, 0] as W), T(words:[ 1, 1, 1, 1] as W), T(words:[ 1, 0, 1, 0] as W)) - } - - func testOr() { - NBKAssertOr (T(words:[ 0, 1, 2, 3] as W), T(words:[ 0, 0, 0, 0] as W), T(words:[ 0, 1, 2, 3] as W)) - NBKAssertOr (T(words:[ 3, 2, 1, 0] as W), T(words:[ 0, 0, 0, 0] as W), T(words:[ 3, 2, 1, 0] as W)) - - NBKAssertOr (T(words:[ 0, 1, 2, 3] as W), T(words:[~0, ~0, ~0, ~0] as W), T(words:[~0, ~0, ~0, ~0] as W)) - NBKAssertOr (T(words:[ 3, 2, 1, 0] as W), T(words:[~0, ~0, ~0, ~0] as W), T(words:[~0, ~0, ~0, ~0] as W)) - - NBKAssertOr (T(words:[ 0, 1, 2, 3] as W), T(words:[ 1, 1, 1, 1] as W), T(words:[ 1, 1, 3, 3] as W)) - NBKAssertOr (T(words:[ 3, 2, 1, 0] as W), T(words:[ 1, 1, 1, 1] as W), T(words:[ 3, 3, 1, 1] as W)) - } - - func testXor() { - NBKAssertXor(T(words:[ 0, 1, 2, 3] as W), T(words:[ 0, 0, 0, 0] as W), T(words:[ 0, 1, 2, 3] as W)) - NBKAssertXor(T(words:[ 3, 2, 1, 0] as W), T(words:[ 0, 0, 0, 0] as W), T(words:[ 3, 2, 1, 0] as W)) - - NBKAssertXor(T(words:[ 0, 1, 2, 3] as W), T(words:[~0, ~0, ~0, ~0] as W), T(words:[~0, ~1, ~2, ~3] as W)) - NBKAssertXor(T(words:[ 3, 2, 1, 0] as W), T(words:[~0, ~0, ~0, ~0] as W), T(words:[~3, ~2, ~1, ~0] as W)) - - NBKAssertXor(T(words:[ 0, 1, 2, 3] as W), T(words:[ 1, 1, 1, 1] as W), T(words:[ 1, 0, 3, 2] as W)) - NBKAssertXor(T(words:[ 3, 2, 1, 0] as W), T(words:[ 1, 1, 1, 1] as W), T(words:[ 2, 3, 0, 1] as W)) - } - - //=------------------------------------------------------------------------= - // MARK: Tests x Miscellaneous - //=------------------------------------------------------------------------= - - func testOperationsHaveUpsizingSemantics() { - NBKAssertAnd(T(words:[0 ] as W), T(words:[0, 0] as W), T(words:[0, 0] as W)) - NBKAssertAnd(T(words:[0, 0] as W), T(words:[0 ] as W), T(words:[0, 0] as W)) - - NBKAssertOr (T(words:[0 ] as W), T(words:[0, 0] as W), T(words:[0, 0] as W)) - NBKAssertOr (T(words:[0, 0] as W), T(words:[0 ] as W), T(words:[0, 0] as W)) - - NBKAssertXor(T(words:[0 ] as W), T(words:[0, 0] as W), T(words:[0, 0] as W)) - NBKAssertXor(T(words:[0, 0] as W), T(words:[0 ] as W), T(words:[0, 0] as W)) - } -} - -//*============================================================================* -// MARK: * NBK x Resizable Width x Logic x Assertions -//*============================================================================* - -private func NBKAssertNot( -_ operand: T, _ result: T, -file: StaticString = #file, line: UInt = #line) { - if operand.words.last != UInt.max { - XCTAssertEqual(~operand, result, file: file, line: line) - XCTAssertEqual(~result, operand, file: file, line: line) - } else { - XCTAssertEqual(~operand, result, file: file, line: line) - } -} - -private func NBKAssertAnd( -_ lhs: T, _ rhs: T, _ result: T, -file: StaticString = #file, line: UInt = #line) { - XCTAssertEqual( lhs & rhs, result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs &= rhs; return lhs }(), result, file: file, line: line) - XCTAssertEqual( rhs & lhs, result, file: file, line: line) - XCTAssertEqual({ var rhs = rhs; rhs &= lhs; return rhs }(), result, file: file, line: line) -} - -private func NBKAssertOr( -_ lhs: T, _ rhs: T, _ result: T, -file: StaticString = #file, line: UInt = #line) { - XCTAssertEqual( lhs | rhs, result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs |= rhs; return lhs }(), result, file: file, line: line) - XCTAssertEqual( rhs | lhs, result, file: file, line: line) - XCTAssertEqual({ var rhs = rhs; rhs |= lhs; return rhs }(), result, file: file, line: line) -} - -private func NBKAssertXor( -_ lhs: T, _ rhs: T, _ result: T, -file: StaticString = #file, line: UInt = #line) { - XCTAssertEqual( lhs ^ rhs, result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs ^= rhs; return lhs }(), result, file: file, line: line) - XCTAssertEqual( rhs ^ lhs, result, file: file, line: line) - XCTAssertEqual({ var rhs = rhs; rhs ^= lhs; return rhs }(), result, file: file, line: line) -} - -#endif diff --git a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Shifts.swift b/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Shifts.swift deleted file mode 100644 index a4a64ab7..00000000 --- a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Shifts.swift +++ /dev/null @@ -1,206 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Shifts x UIntXR -//*============================================================================* - -final class NBKResizableWidthTestsOnShiftsAsUIntXR: XCTestCase { - - typealias T = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests x Left - //=------------------------------------------------------------------------= - - func testBitshiftingLeftByBits() { - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 0, T(x64:[ 1, 2, 3, 4] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 1, T(x64:[ 2, 4, 6, 8] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 2, T(x64:[ 4, 8, 12, 16] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 3, T(x64:[ 8, 16, 24, 32] as X)) - } - - func testBitshiftingLeftByWords() { - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 0, T(x64:[ 1, 2, 3, 4] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 64, T(x64:[ 0, 1, 2, 3] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 128, T(x64:[ 0, 0, 1, 2] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 192, T(x64:[ 0, 0, 0, 1] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 256, T(x64:[ 0, 0, 0, 0] as X)) - } - - func testBitshiftingLeftByWordsAndBits() { - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 3, T(x64:[ 8, 16, 24, 32] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 67, T(x64:[ 0, 8, 16, 24] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 131, T(x64:[ 0, 0, 8, 16] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 195, T(x64:[ 0, 0, 0, 8] as X)) - NBKAssertShiftLeft(T(x64:[ 1, 2, 3, 4] as X), 259, T(x64:[ 0, 0, 0, 0] as X)) - } - - func testBitshiftingLeftSuchThatWordsSplit() { - NBKAssertShiftLeft(T(x64:[~0, 0, 0, 0] as X), 1, T(x64:[~1, 1, 0, 0] as X)) - NBKAssertShiftLeft(T(x64:[ 0, ~0, 0, 0] as X), 1, T(x64:[ 0, ~1, 1, 0] as X)) - NBKAssertShiftLeft(T(x64:[ 0, 0, ~0, 0] as X), 1, T(x64:[ 0, 0, ~1, 1] as X)) - NBKAssertShiftLeft(T(x64:[ 0, 0, 0, ~0] as X), 1, T(x64:[ 0, 0, 0, ~1] as X)) - } - - //=------------------------------------------------------------------------= - // MARK: Tests x Right - //=------------------------------------------------------------------------= - - func testBitshiftingRightByBits() { - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 0, T(x64:[ 8, 16, 24, 32] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 1, T(x64:[ 4, 8, 12, 16] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 2, T(x64:[ 2, 4, 6, 8] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 3, T(x64:[ 1, 2, 3, 4] as X)) - } - - func testBitshiftingRightByWords() { - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 0, T(x64:[ 8, 16, 24, 32] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 64, T(x64:[16, 24, 32, 0] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 128, T(x64:[24, 32, 0, 0] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 192, T(x64:[32, 0, 0, 0] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 256, T(x64:[ 0, 0, 0, 0] as X)) - } - - func testBitshiftingRightByWordsAndBits() { - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 3, T(x64:[ 1, 2, 3, 4] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 67, T(x64:[ 2, 3, 4, 0] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 131, T(x64:[ 3, 4, 0, 0] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 195, T(x64:[ 4, 0, 0, 0] as X)) - NBKAssertShiftRight(T(x64:[8, 16, 24, 32] as X), 259, T(x64:[ 0, 0, 0, 0] as X)) - } - - func testBitshiftingRightSuchThatWordsSplit() { - NBKAssertShiftRight(T(x64:[0, 0, 0, 7] as X), 1, T(x64:[ 0, 0, 1 << 63, 3] as X)) - NBKAssertShiftRight(T(x64:[0, 0, 7, 0] as X), 1, T(x64:[ 0, 1 << 63, 3, 0] as X)) - NBKAssertShiftRight(T(x64:[0, 7, 0, 0] as X), 1, T(x64:[ 1 << 63, 3, 0, 0] as X)) - NBKAssertShiftRight(T(x64:[7, 0, 0, 0] as X), 1, T(x64:[ 3, 0, 0, 0] as X)) - } - - func testBitshiftingRightIsUnsigned() { - NBKAssertShiftRight(T(x64:[0, 0, 0, 1 << 63] as X), 0, T(x64:[0, 0, 0, 1 << 63] as X)) - NBKAssertShiftRight(T(x64:[0, 0, 0, 1 << 63] as X), 64, T(x64:[0, 0, 1 << 63, 0] as X)) - NBKAssertShiftRight(T(x64:[0, 0, 0, 1 << 63] as X), 128, T(x64:[0, 1 << 63, 0, 0] as X)) - NBKAssertShiftRight(T(x64:[0, 0, 0, 1 << 63] as X), 192, T(x64:[1 << 63, 0, 0, 0] as X)) - NBKAssertShiftRight(T(x64:[0, 0, 0, 1 << 63] as X), 256, T(x64:[0, 0, 0, 0] as X)) - } - - //=------------------------------------------------------------------------= - // MARK: Tests x Miscellaneous - //=------------------------------------------------------------------------= - - func testBitshiftingIsSmart() { - XCTAssertEqual(T(x64:[1, 2, 3, 4] as X) << 1, T(x64:[2, 4, 6, 8] as X)) - XCTAssertEqual(T(x64:[1, 2, 3, 4] as X) >> -1, T(x64:[2, 4, 6, 8] as X)) - - XCTAssertEqual(T(x64:[1, 2, 3, 4] as X) << 64, T(x64:[0, 1, 2, 3] as X)) - XCTAssertEqual(T(x64:[1, 2, 3, 4] as X) >> -64, T(x64:[0, 1, 2, 3] as X)) - } - - func testBitshiftingRightDoesNotTrap() { - XCTAssertEqual(T(x64:[1, 2, 3, 4] as X) >> Int.max, T.zero) - XCTAssertEqual(T(x64:[1, 2, 3, 4] as X) << Int.min, T.zero) - } - - func testBitshiftingZeroDoesNotTrap() { - XCTAssertEqual(T(x64:[0, 0, 0, 0] as X) << Int.min, T.zero) - XCTAssertEqual(T(x64:[0, 0, 0, 0] as X) << Int.max, T.zero) - - XCTAssertEqual(T(x64:[0, 0, 0, 0] as X) >> Int.min, T.zero) - XCTAssertEqual(T(x64:[0, 0, 0, 0] as X) >> Int.max, T.zero) - } - - func testBitshiftingZeroDoesNotDoAnything() { - XCTAssertEqual(T(x64:[0, 0, 0, 0] as X) << (UInt.bitWidth + 0), T.zero) - XCTAssertEqual(T(x64:[0, 0, 0, 0] as X) << (UInt.bitWidth + 1), T.zero) - - XCTAssertEqual(T(x64:[0, 0, 0, 0] as X) >> (UInt.bitWidth + 0), T.zero) - XCTAssertEqual(T(x64:[0, 0, 0, 0] as X) >> (UInt.bitWidth + 1), T.zero) - } -} - -//*============================================================================* -// MARK: * NBK x Resizable Width x Shifts x Assertions -//*============================================================================* - -private func NBKAssertShiftLeft( -_ lhs: T, _ rhs: Int, _ result: T, -file: StaticString = #file, line: UInt = #line) { - //=------------------------------------------= - let (words, bits) = rhs.quotientAndRemainder(dividingBy: UInt.bitWidth) - //=------------------------------------------= - XCTAssertEqual( lhs << rhs, result, file: file, line: line) - XCTAssertEqual( lhs >> -rhs, result, file: file, line: line) - - XCTAssertEqual({ var lhs = lhs; lhs <<= rhs; return lhs }(), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs >>= -rhs; return lhs }(), result, file: file, line: line) - - XCTAssertEqual(lhs.bitshiftedLeftSmart(by: rhs), result, file: file, line: line) - XCTAssertEqual(lhs.bitshiftedRightSmart(by: -rhs), result, file: file, line: line) - - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftLeftSmart(by: rhs); return lhs }(), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftRightSmart(by: -rhs); return lhs }(), result, file: file, line: line) - //=------------------------------------------= - if 0 ..< lhs.bitWidth ~= rhs { - XCTAssertEqual(lhs.bitshiftedLeft(by: rhs), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftLeft(by: rhs); return lhs }(), result, file: file, line: line) - - XCTAssertEqual(lhs.bitshiftedLeft(words: words, bits: bits), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftLeft(words: words, bits: bits); return lhs }(), result, file: file, line: line) - } - //=------------------------------------------= - if 0 ..< lhs.bitWidth ~= rhs, bits.isZero { - XCTAssertEqual(lhs.bitshiftedLeft(words: words), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftLeft(words: words); return lhs }(), result, file: file, line: line) - } -} - -private func NBKAssertShiftRight( -_ lhs: T, _ rhs: Int, _ result: T, -file: StaticString = #file, line: UInt = #line) { - //=------------------------------------------= - let (words, bits) = rhs.quotientAndRemainder(dividingBy: UInt.bitWidth) - //=------------------------------------------= - XCTAssertEqual( lhs >> rhs, result, file: file, line: line) - XCTAssertEqual( lhs << -rhs, result, file: file, line: line) - - XCTAssertEqual({ var lhs = lhs; lhs >>= rhs; return lhs }(), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs <<= -rhs; return lhs }(), result, file: file, line: line) - - XCTAssertEqual(lhs.bitshiftedRightSmart(by: rhs), result, file: file, line: line) - XCTAssertEqual(lhs.bitshiftedLeftSmart(by: -rhs), result, file: file, line: line) - - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftRightSmart(by: rhs); return lhs }(), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftLeftSmart(by: -rhs); return lhs }(), result, file: file, line: line) - //=------------------------------------------= - if 0 ..< lhs.bitWidth ~= rhs { - XCTAssertEqual(lhs.bitshiftedRight(by: rhs), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftRight(by: rhs); return lhs }(), result, file: file, line: line) - - XCTAssertEqual(lhs.bitshiftedRight(words: words, bits: bits), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftRight(words: words, bits: bits); return lhs }(), result, file: file, line: line) - } - //=------------------------------------------= - if 0 ..< lhs.bitWidth ~= rhs, bits.isZero { - XCTAssertEqual(lhs.bitshiftedRight(words: words), result, file: file, line: line) - XCTAssertEqual({ var lhs = lhs; lhs.bitshiftRight(words: words); return lhs }(), result, file: file, line: line) - } -} - -#endif diff --git a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Words.swift b/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Words.swift deleted file mode 100644 index 1ba9b39c..00000000 --- a/Tests/NBKResizableWidthKitTests/NBKResizableWidth+Words.swift +++ /dev/null @@ -1,176 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -#if DEBUG - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Words x UIntXR -//*============================================================================* - -final class NBKResizableWidthTestsOnWordsAsUIntXR: XCTestCase { - - typealias T = UIntXR - typealias M = UIntXR - - //=------------------------------------------------------------------------= - // MARK: Tests - //=------------------------------------------------------------------------= - - func testWords() { - NBKAssertWords(T(words:[0 ]), [0 ]) - NBKAssertWords(T(words:[1 ]), [1 ]) - NBKAssertWords(T(words:[1, 2 ]), [1, 2 ]) - NBKAssertWords(T(words:[1, 2, 3 ]), [1, 2, 3 ]) - NBKAssertWords(T(words:[1, 2, 3, 4]), [1, 2, 3, 4]) - - NBKAssertWords(T(words:[0, 0, 0, 0]), [0, 0, 0, 0]) - NBKAssertWords(T(words:[1, 0, 0, 0]), [1, 0, 0, 0]) - NBKAssertWords(T(words:[1, 2, 0, 0]), [1, 2, 0, 0]) - NBKAssertWords(T(words:[1, 2, 3, 0]), [1, 2, 3, 0]) - NBKAssertWords(T(words:[1, 2, 3, 4]), [1, 2, 3, 4]) - } - - func testWordsX64() throws { - guard MemoryLayout.size == MemoryLayout.size else { throw XCTSkip() } - - NBKAssertWords(T(x64:[0 ] as X), [0 ]) - NBKAssertWords(T(x64:[1 ] as X), [1 ]) - NBKAssertWords(T(x64:[1, 2 ] as X), [1, 2 ]) - NBKAssertWords(T(x64:[1, 2, 3 ] as X), [1, 2, 3 ]) - NBKAssertWords(T(x64:[1, 2, 3, 4] as X), [1, 2, 3, 4]) - - NBKAssertWords(T(x64:[0, 0, 0, 0] as X), [0, 0, 0, 0]) - NBKAssertWords(T(x64:[1, 0, 0, 0] as X), [1, 0, 0, 0]) - NBKAssertWords(T(x64:[1, 2, 0, 0] as X), [1, 2, 0, 0]) - NBKAssertWords(T(x64:[1, 2, 3, 0] as X), [1, 2, 3, 0]) - NBKAssertWords(T(x64:[1, 2, 3, 4] as X), [1, 2, 3, 4]) - } - - func testWordsX32() throws { - guard MemoryLayout.size == MemoryLayout.size else { throw XCTSkip() } - - NBKAssertWords(T(x32:[0 ] as Y), [0 ]) - NBKAssertWords(T(x32:[1 ] as Y), [1 ]) - NBKAssertWords(T(x32:[1, 2 ] as Y), [1, 2 ]) - NBKAssertWords(T(x32:[1, 2, 3 ] as Y), [1, 2, 3 ]) - NBKAssertWords(T(x32:[1, 2, 3, 4 ] as Y), [1, 2, 3, 4 ]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 5 ] as Y), [1, 2, 3, 4, 5 ]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 5, 6 ] as Y), [1, 2, 3, 4, 5, 6 ]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 5, 6, 7 ] as Y), [1, 2, 3, 4, 5, 6, 7 ]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 5, 6, 7, 8] as Y), [1, 2, 3, 4, 5, 6, 7, 8]) - - NBKAssertWords(T(x32:[0, 0, 0, 0, 0, 0, 0, 0] as Y), [0, 0, 0, 0, 0, 0, 0, 0]) - NBKAssertWords(T(x32:[1, 0, 0, 0, 0, 0, 0, 0] as Y), [1, 0, 0, 0, 0, 0, 0, 0]) - NBKAssertWords(T(x32:[1, 2, 0, 0, 0, 0, 0, 0] as Y), [1, 2, 0, 0, 0, 0, 0, 0]) - NBKAssertWords(T(x32:[1, 2, 3, 0, 0, 0, 0, 0] as Y), [1, 2, 3, 0, 0, 0, 0, 0]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 0, 0, 0, 0] as Y), [1, 2, 3, 4, 0, 0, 0, 0]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 5, 0, 0, 0] as Y), [1, 2, 3, 4, 5, 0, 0, 0]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 5, 6, 0, 0] as Y), [1, 2, 3, 4, 5, 6, 0, 0]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 5, 6, 7, 0] as Y), [1, 2, 3, 4, 5, 6, 7, 0]) - NBKAssertWords(T(x32:[1, 2, 3, 4, 5, 6, 7, 8] as Y), [1, 2, 3, 4, 5, 6, 7, 8]) - } - - //=------------------------------------------------------------------------= - // MARK: Tests x Indices - //=------------------------------------------------------------------------= - - func testIndexOffsetByLimitedBy() { - NBKAssertIndexOffsetByLimitedBy(T.zero, 1, 2, 2, nil) - NBKAssertIndexOffsetByLimitedBy(T.zero, 1, 1, 2, 2) - NBKAssertIndexOffsetByLimitedBy(T.zero, 1, 0, 2, 1) - NBKAssertIndexOffsetByLimitedBy(T.zero, 1, -1, 2, 0) - NBKAssertIndexOffsetByLimitedBy(T.zero, 1, -2, 2, -1) - - NBKAssertIndexOffsetByLimitedBy(T.zero, 2, 2, 2, nil) - NBKAssertIndexOffsetByLimitedBy(T.zero, 2, 1, 2, nil) - NBKAssertIndexOffsetByLimitedBy(T.zero, 2, 0, 2, 2) - NBKAssertIndexOffsetByLimitedBy(T.zero, 2, -1, 2, nil) - NBKAssertIndexOffsetByLimitedBy(T.zero, 2, -2, 2, nil) - - NBKAssertIndexOffsetByLimitedBy(T.zero, 3, 2, 2, 5) - NBKAssertIndexOffsetByLimitedBy(T.zero, 3, 1, 2, 4) - NBKAssertIndexOffsetByLimitedBy(T.zero, 3, 0, 2, 3) - NBKAssertIndexOffsetByLimitedBy(T.zero, 3, -1, 2, 2) - NBKAssertIndexOffsetByLimitedBy(T.zero, 3, -2, 2, nil) - } - - //=------------------------------------------------------------------------= - // MARK: Tests x Elements - //=------------------------------------------------------------------------= - - func testFirstLastTail() { - NBKAssertFirstLastTail( T(words:[1, 2, 3, 4]), first: 1, last: 4, tail: 4) - NBKAssertFirstLastTail(~T(words:[1, 2, 3, 4]), first: ~1, last: ~4, tail: ~4) - } -} - -//*============================================================================* -// MARK: * NBK x Resizable Width x Words x Assertions -//*============================================================================* - -private func NBKAssertWords( -_ integer: T, _ words: [UInt], -file: StaticString = #file, line: UInt = #line) { - var integer: T = integer - var generic: some RandomAccessCollection & MutableCollection = integer - - XCTAssertEqual(Array(integer.words), Array(words), file: file, line: line) - XCTAssertEqual(Array(integer.words.reversed()), Array(words.reversed()), file: file, line: line) - - XCTAssertEqual(integer.withContiguousStorage({ Array($0) }), words, file: file, line: line) - XCTAssertEqual(integer.withContiguousMutableStorage({ Array($0) }), words, file: file, line: line) - - XCTAssertEqual(integer.withContiguousStorageIfAvailable({ Array($0) }), words, file: file, line: line) - XCTAssertEqual(integer.withContiguousMutableStorageIfAvailable({ Array($0) }), words, file: file, line: line) - - XCTAssertEqual(generic.withContiguousStorageIfAvailable({ Array($0) }), words, file: file, line: line) - XCTAssertEqual(generic.withContiguousMutableStorageIfAvailable({ Array($0) }), words, file: file, line: line) -} - -//=----------------------------------------------------------------------------= -// MARK: + Indices -//=----------------------------------------------------------------------------= - -private func NBKAssertIndexOffsetByLimitedBy( -_ integer: T, _ index: Int, _ distance: Int, _ limit: Int, _ expectation: Int?, -file: StaticString = #file, line: UInt = #line) { - //=------------------------------------------= - let wordsIndex = /*-*/(integer).index(index, offsetBy: distance, limitedBy: limit) - let arrayIndex = Array(integer).index(index, offsetBy: distance, limitedBy: limit) - //=------------------------------------------= - XCTAssertEqual(wordsIndex, expectation, file: file, line: line) - XCTAssertEqual(arrayIndex, expectation, file: file, line: line) -} - -//=----------------------------------------------------------------------------= -// MARK: + Elements -//=----------------------------------------------------------------------------= - -private func NBKAssertFirstLastTail( -_ integer: T, first: UInt, last: UInt, tail: T.Digit, -file: StaticString = #file, line: UInt = #line) { - //=------------------------------------------= - XCTAssertEqual(integer.first, first, file: file, line: line) - XCTAssertEqual(integer.last, last, file: file, line: line) - XCTAssertEqual(integer.tail, tail, file: file, line: line) - //=------------------------------------------= - XCTAssertEqual({ var x = T.zero; x.first = first; return x.first }(), first, file: file, line: line) - XCTAssertEqual({ var x = T.zero; x.last = last; return x.last }(), last, file: file, line: line) - XCTAssertEqual({ var x = T.zero; x.tail = tail; return x.tail }(), tail, file: file, line: line) -} - -#endif diff --git a/Tests/NBKResizableWidthKitTests/NBKResizableWidth.swift b/Tests/NBKResizableWidthKitTests/NBKResizableWidth.swift deleted file mode 100644 index 3c57b0b3..00000000 --- a/Tests/NBKResizableWidthKitTests/NBKResizableWidth.swift +++ /dev/null @@ -1,42 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Numberick open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -import NBKCoreKit -import NBKResizableWidthKit -import XCTest - -private typealias W = [UInt] -private typealias X = [UInt64] -private typealias Y = [UInt32] - -//*============================================================================* -// MARK: * NBK x Resizable Width x Initializers x UIntXR -//*============================================================================* - -extension NBKResizableWidth.Magnitude { - - //=------------------------------------------------------------------------= - // MARK: Details x Numbers - //=------------------------------------------------------------------------= - - static let min256 = Self(x64:[ 0, 0, 0, 0] as X) - static let max256 = Self(x64:[~0, ~0, ~0, ~0] as X) - - //=------------------------------------------------------------------------= - // MARK: Details x Limbs - //=------------------------------------------------------------------------= - - init(x32: [UInt32]) { - self.init(words: NBKChunkedInt(x32)) - } - - init(x64: [UInt64]) { - self.init(words: NBKChunkedInt(x64)) - } -}