| ... | @@ -29,7 +29,7 @@ test "comptime_int set" { | ... | @@ -29,7 +29,7 @@ test "comptime_int set" { |
| 29 | const result = @as(Limb, s & maxInt(Limb)); | 29 | const result = @as(Limb, s & maxInt(Limb)); |
| 30 | s >>= @typeInfo(Limb).int.bits / 2; | 30 | s >>= @typeInfo(Limb).int.bits / 2; |
| 31 | s >>= @typeInfo(Limb).int.bits / 2; | 31 | s >>= @typeInfo(Limb).int.bits / 2; |
| 32 | try testing.expect(a.limbs[i] == result); | 32 | try testing.expectEqual(result, a.limbs[i]); |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| 35 | | 35 | |
| ... | @@ -37,37 +37,37 @@ test "comptime_int set negative" { | ... | @@ -37,37 +37,37 @@ test "comptime_int set negative" { |
| 37 | var a = try Managed.initSet(testing.allocator, -10); | 37 | var a = try Managed.initSet(testing.allocator, -10); |
| 38 | defer a.deinit(); | 38 | defer a.deinit(); |
| 39 | | 39 | |
| 40 | try testing.expect(a.limbs[0] == 10); | 40 | try testing.expectEqual(10, a.limbs[0]); |
| 41 | try testing.expect(a.isPositive() == false); | 41 | try testing.expectEqual(false, a.isPositive()); |
| 42 | } | 42 | } |
| 43 | | 43 | |
| 44 | test "int set unaligned small" { | 44 | test "int set unaligned small" { |
| 45 | var a = try Managed.initSet(testing.allocator, @as(u7, 45)); | 45 | var a = try Managed.initSet(testing.allocator, @as(u7, 45)); |
| 46 | defer a.deinit(); | 46 | defer a.deinit(); |
| 47 | | 47 | |
| 48 | try testing.expect(a.limbs[0] == 45); | 48 | try testing.expectEqual(45, a.limbs[0]); |
| 49 | try testing.expect(a.isPositive() == true); | 49 | try testing.expectEqual(true, a.isPositive()); |
| 50 | } | 50 | } |
| 51 | | 51 | |
| 52 | test "comptime_int to" { | 52 | test "comptime_int to" { |
| 53 | var a = try Managed.initSet(testing.allocator, 0xefffffff00000001eeeeeeefaaaaaaab); | 53 | var a = try Managed.initSet(testing.allocator, 0xefffffff00000001eeeeeeefaaaaaaab); |
| 54 | defer a.deinit(); | 54 | defer a.deinit(); |
| 55 | | 55 | |
| 56 | try testing.expect((try a.toInt(u128)) == 0xefffffff00000001eeeeeeefaaaaaaab); | 56 | try testing.expectEqual(0xefffffff00000001eeeeeeefaaaaaaab, try a.toInt(u128)); |
| 57 | } | 57 | } |
| 58 | | 58 | |
| 59 | test "sub-limb to" { | 59 | test "sub-limb to" { |
| 60 | var a = try Managed.initSet(testing.allocator, 10); | 60 | var a = try Managed.initSet(testing.allocator, 10); |
| 61 | defer a.deinit(); | 61 | defer a.deinit(); |
| 62 | | 62 | |
| 63 | try testing.expect((try a.toInt(u8)) == 10); | 63 | try testing.expectEqual(10, try a.toInt(u8)); |
| 64 | } | 64 | } |
| 65 | | 65 | |
| 66 | test "set negative minimum" { | 66 | test "set negative minimum" { |
| 67 | var a = try Managed.initSet(testing.allocator, @as(i64, minInt(i64))); | 67 | var a = try Managed.initSet(testing.allocator, @as(i64, minInt(i64))); |
| 68 | defer a.deinit(); | 68 | defer a.deinit(); |
| 69 | | 69 | |
| 70 | try testing.expect((try a.toInt(i64)) == minInt(i64)); | 70 | try testing.expectEqual(minInt(i64), try a.toInt(i64)); |
| 71 | } | 71 | } |
| 72 | | 72 | |
| 73 | test "set double-width maximum then zero" { | 73 | test "set double-width maximum then zero" { |
| ... | @@ -95,22 +95,22 @@ test "normalize" { | ... | @@ -95,22 +95,22 @@ test "normalize" { |
| 95 | a.limbs[2] = 3; | 95 | a.limbs[2] = 3; |
| 96 | a.limbs[3] = 0; | 96 | a.limbs[3] = 0; |
| 97 | a.normalize(4); | 97 | a.normalize(4); |
| 98 | try testing.expect(a.len() == 3); | 98 | try testing.expectEqual(3, a.len()); |
| 99 | | 99 | |
| 100 | a.limbs[0] = 1; | 100 | a.limbs[0] = 1; |
| 101 | a.limbs[1] = 2; | 101 | a.limbs[1] = 2; |
| 102 | a.limbs[2] = 3; | 102 | a.limbs[2] = 3; |
| 103 | a.normalize(3); | 103 | a.normalize(3); |
| 104 | try testing.expect(a.len() == 3); | 104 | try testing.expectEqual(3, a.len()); |
| 105 | | 105 | |
| 106 | a.limbs[0] = 0; | 106 | a.limbs[0] = 0; |
| 107 | a.limbs[1] = 0; | 107 | a.limbs[1] = 0; |
| 108 | a.normalize(2); | 108 | a.normalize(2); |
| 109 | try testing.expect(a.len() == 1); | 109 | try testing.expectEqual(1, a.len()); |
| 110 | | 110 | |
| 111 | a.limbs[0] = 0; | 111 | a.limbs[0] = 0; |
| 112 | a.normalize(1); | 112 | a.normalize(1); |
| 113 | try testing.expect(a.len() == 1); | 113 | try testing.expectEqual(1, a.len()); |
| 114 | } | 114 | } |
| 115 | | 115 | |
| 116 | test "normalize multi" { | 116 | test "normalize multi" { |
| ... | @@ -123,24 +123,24 @@ test "normalize multi" { | ... | @@ -123,24 +123,24 @@ test "normalize multi" { |
| 123 | a.limbs[2] = 0; | 123 | a.limbs[2] = 0; |
| 124 | a.limbs[3] = 0; | 124 | a.limbs[3] = 0; |
| 125 | a.normalize(4); | 125 | a.normalize(4); |
| 126 | try testing.expect(a.len() == 2); | 126 | try testing.expectEqual(2, a.len()); |
| 127 | | 127 | |
| 128 | a.limbs[0] = 1; | 128 | a.limbs[0] = 1; |
| 129 | a.limbs[1] = 2; | 129 | a.limbs[1] = 2; |
| 130 | a.limbs[2] = 3; | 130 | a.limbs[2] = 3; |
| 131 | a.normalize(3); | 131 | a.normalize(3); |
| 132 | try testing.expect(a.len() == 3); | 132 | try testing.expectEqual(3, a.len()); |
| 133 | | 133 | |
| 134 | a.limbs[0] = 0; | 134 | a.limbs[0] = 0; |
| 135 | a.limbs[1] = 0; | 135 | a.limbs[1] = 0; |
| 136 | a.limbs[2] = 0; | 136 | a.limbs[2] = 0; |
| 137 | a.limbs[3] = 0; | 137 | a.limbs[3] = 0; |
| 138 | a.normalize(4); | 138 | a.normalize(4); |
| 139 | try testing.expect(a.len() == 1); | 139 | try testing.expectEqual(1, a.len()); |
| 140 | | 140 | |
| 141 | a.limbs[0] = 0; | 141 | a.limbs[0] = 0; |
| 142 | a.normalize(1); | 142 | a.normalize(1); |
| 143 | try testing.expect(a.len() == 1); | 143 | try testing.expectEqual(1, a.len()); |
| 144 | } | 144 | } |
| 145 | | 145 | |
| 146 | test "parity" { | 146 | test "parity" { |
| ... | @@ -161,26 +161,26 @@ test "bitcount + sizeInBaseUpperBound" { | ... | @@ -161,26 +161,26 @@ test "bitcount + sizeInBaseUpperBound" { |
| 161 | defer a.deinit(); | 161 | defer a.deinit(); |
| 162 | | 162 | |
| 163 | try a.set(0b100); | 163 | try a.set(0b100); |
| 164 | try testing.expect(a.bitCountAbs() == 3); | 164 | try testing.expectEqual(3, a.bitCountAbs()); |
| 165 | try testing.expect(a.sizeInBaseUpperBound(2) >= 3); | 165 | try testing.expect(a.sizeInBaseUpperBound(2) >= 3); |
| 166 | try testing.expect(a.sizeInBaseUpperBound(10) >= 1); | 166 | try testing.expect(a.sizeInBaseUpperBound(10) >= 1); |
| 167 | | 167 | |
| 168 | a.negate(); | 168 | a.negate(); |
| 169 | try testing.expect(a.bitCountAbs() == 3); | 169 | try testing.expectEqual(3, a.bitCountAbs()); |
| 170 | try testing.expect(a.sizeInBaseUpperBound(2) >= 4); | 170 | try testing.expect(a.sizeInBaseUpperBound(2) >= 4); |
| 171 | try testing.expect(a.sizeInBaseUpperBound(10) >= 2); | 171 | try testing.expect(a.sizeInBaseUpperBound(10) >= 2); |
| 172 | | 172 | |
| 173 | try a.set(0xffffffff); | 173 | try a.set(0xffffffff); |
| 174 | try testing.expect(a.bitCountAbs() == 32); | 174 | try testing.expectEqual(32, a.bitCountAbs()); |
| 175 | try testing.expect(a.sizeInBaseUpperBound(2) >= 32); | 175 | try testing.expect(a.sizeInBaseUpperBound(2) >= 32); |
| 176 | try testing.expect(a.sizeInBaseUpperBound(10) >= 10); | 176 | try testing.expect(a.sizeInBaseUpperBound(10) >= 10); |
| 177 | | 177 | |
| 178 | try a.shiftLeft(&a, 5000); | 178 | try a.shiftLeft(&a, 5000); |
| 179 | try testing.expect(a.bitCountAbs() == 5032); | 179 | try testing.expectEqual(5032, a.bitCountAbs()); |
| 180 | try testing.expect(a.sizeInBaseUpperBound(2) >= 5032); | 180 | try testing.expect(a.sizeInBaseUpperBound(2) >= 5032); |
| 181 | a.setSign(false); | 181 | a.setSign(false); |
| 182 | | 182 | |
| 183 | try testing.expect(a.bitCountAbs() == 5032); | 183 | try testing.expectEqual(5032, a.bitCountAbs()); |
| 184 | try testing.expect(a.sizeInBaseUpperBound(2) >= 5033); | 184 | try testing.expect(a.sizeInBaseUpperBound(2) >= 5033); |
| 185 | } | 185 | } |
| 186 | | 186 | |
| ... | @@ -189,30 +189,30 @@ test "bitcount/to" { | ... | @@ -189,30 +189,30 @@ test "bitcount/to" { |
| 189 | defer a.deinit(); | 189 | defer a.deinit(); |
| 190 | | 190 | |
| 191 | try a.set(0); | 191 | try a.set(0); |
| 192 | try testing.expect(a.bitCountTwosComp() == 0); | 192 | try testing.expectEqual(0, a.bitCountTwosComp()); |
| 193 | | 193 | |
| 194 | try testing.expect((try a.toInt(u0)) == 0); | 194 | try testing.expectEqual(0, try a.toInt(u0)); |
| 195 | try testing.expect((try a.toInt(i0)) == 0); | 195 | try testing.expectEqual(0, try a.toInt(i0)); |
| 196 | | 196 | |
| 197 | try a.set(-1); | 197 | try a.set(-1); |
| 198 | try testing.expect(a.bitCountTwosComp() == 1); | 198 | try testing.expectEqual(1, a.bitCountTwosComp()); |
| 199 | try testing.expect((try a.toInt(i1)) == -1); | 199 | try testing.expectEqual(-1, try a.toInt(i1)); |
| 200 | | 200 | |
| 201 | try a.set(-8); | 201 | try a.set(-8); |
| 202 | try testing.expect(a.bitCountTwosComp() == 4); | 202 | try testing.expectEqual(4, a.bitCountTwosComp()); |
| 203 | try testing.expect((try a.toInt(i4)) == -8); | 203 | try testing.expectEqual(-8, try a.toInt(i4)); |
| 204 | | 204 | |
| 205 | try a.set(127); | 205 | try a.set(127); |
| 206 | try testing.expect(a.bitCountTwosComp() == 7); | 206 | try testing.expectEqual(7, a.bitCountTwosComp()); |
| 207 | try testing.expect((try a.toInt(u7)) == 127); | 207 | try testing.expectEqual(127, try a.toInt(u7)); |
| 208 | | 208 | |
| 209 | try a.set(-128); | 209 | try a.set(-128); |
| 210 | try testing.expect(a.bitCountTwosComp() == 8); | 210 | try testing.expectEqual(8, a.bitCountTwosComp()); |
| 211 | try testing.expect((try a.toInt(i8)) == -128); | 211 | try testing.expectEqual(-128, try a.toInt(i8)); |
| 212 | | 212 | |
| 213 | try a.set(-129); | 213 | try a.set(-129); |
| 214 | try testing.expect(a.bitCountTwosComp() == 9); | 214 | try testing.expectEqual(9, a.bitCountTwosComp()); |
| 215 | try testing.expect((try a.toInt(i9)) == -129); | 215 | try testing.expectEqual(-129, try a.toInt(i9)); |
| 216 | } | 216 | } |
| 217 | | 217 | |
| 218 | test "fits" { | 218 | test "fits" { |
| ... | @@ -248,7 +248,7 @@ test "string set" { | ... | @@ -248,7 +248,7 @@ test "string set" { |
| 248 | defer a.deinit(); | 248 | defer a.deinit(); |
| 249 | | 249 | |
| 250 | try a.setString(10, "120317241209124781241290847124"); | 250 | try a.setString(10, "120317241209124781241290847124"); |
| 251 | try testing.expect((try a.toInt(u128)) == 120317241209124781241290847124); | 251 | try testing.expectEqual(120317241209124781241290847124, try a.toInt(u128)); |
| 252 | } | 252 | } |
| 253 | | 253 | |
| 254 | test "string negative" { | 254 | test "string negative" { |
| ... | @@ -256,7 +256,7 @@ test "string negative" { | ... | @@ -256,7 +256,7 @@ test "string negative" { |
| 256 | defer a.deinit(); | 256 | defer a.deinit(); |
| 257 | | 257 | |
| 258 | try a.setString(10, "-1023"); | 258 | try a.setString(10, "-1023"); |
| 259 | try testing.expect((try a.toInt(i32)) == -1023); | 259 | try testing.expectEqual(-1023, try a.toInt(i32)); |
| 260 | } | 260 | } |
| 261 | | 261 | |
| 262 | test "string set number with underscores" { | 262 | test "string set number with underscores" { |
| ... | @@ -264,7 +264,7 @@ test "string set number with underscores" { | ... | @@ -264,7 +264,7 @@ test "string set number with underscores" { |
| 264 | defer a.deinit(); | 264 | defer a.deinit(); |
| 265 | | 265 | |
| 266 | try a.setString(10, "__1_2_0_3_1_7_2_4_1_2_0_____9_1__2__4_7_8_1_2_4_1_2_9_0_8_4_7_1_2_4___"); | 266 | try a.setString(10, "__1_2_0_3_1_7_2_4_1_2_0_____9_1__2__4_7_8_1_2_4_1_2_9_0_8_4_7_1_2_4___"); |
| 267 | try testing.expect((try a.toInt(u128)) == 120317241209124781241290847124); | 267 | try testing.expectEqual(120317241209124781241290847124, try a.toInt(u128)); |
| 268 | } | 268 | } |
| 269 | | 269 | |
| 270 | test "string set case insensitive number" { | 270 | test "string set case insensitive number" { |
| ... | @@ -272,7 +272,7 @@ test "string set case insensitive number" { | ... | @@ -272,7 +272,7 @@ test "string set case insensitive number" { |
| 272 | defer a.deinit(); | 272 | defer a.deinit(); |
| 273 | | 273 | |
| 274 | try a.setString(16, "aB_cD_eF"); | 274 | try a.setString(16, "aB_cD_eF"); |
| 275 | try testing.expect((try a.toInt(u32)) == 0xabcdef); | 275 | try testing.expectEqual(0xabcdef, try a.toInt(u32)); |
| 276 | } | 276 | } |
| 277 | | 277 | |
| 278 | test "string set base 36" { | 278 | test "string set base 36" { |
| ... | @@ -280,7 +280,7 @@ test "string set base 36" { | ... | @@ -280,7 +280,7 @@ test "string set base 36" { |
| 280 | defer a.deinit(); | 280 | defer a.deinit(); |
| 281 | | 281 | |
| 282 | try a.setString(36, "fifvthrv1mzt79ez9"); | 282 | try a.setString(36, "fifvthrv1mzt79ez9"); |
| 283 | try testing.expect((try a.to(u128)) == 123456789123456789123456789); | 283 | try testing.expectEqual(123456789123456789123456789, try a.to(u128)); |
| 284 | } | 284 | } |
| 285 | | 285 | |
| 286 | test "string set bad char error" { | 286 | test "string set bad char error" { |
| ... | @@ -314,11 +314,11 @@ fn testTwosComplementLimit(comptime T: type) !void { | ... | @@ -314,11 +314,11 @@ fn testTwosComplementLimit(comptime T: type) !void { |
| 314 | | 314 | |
| 315 | try a.setTwosCompIntLimit(.max, int_info.signedness, int_info.bits); | 315 | try a.setTwosCompIntLimit(.max, int_info.signedness, int_info.bits); |
| 316 | const max: T = maxInt(T); | 316 | const max: T = maxInt(T); |
| 317 | try testing.expect(max == try a.toInt(T)); | 317 | try testing.expectEqual(max, try a.toInt(T)); |
| 318 | | 318 | |
| 319 | try a.setTwosCompIntLimit(.min, int_info.signedness, int_info.bits); | 319 | try a.setTwosCompIntLimit(.min, int_info.signedness, int_info.bits); |
| 320 | const min: T = minInt(T); | 320 | const min: T = minInt(T); |
| 321 | try testing.expect(min == try a.toInt(T)); | 321 | try testing.expectEqual(min, try a.toInt(T)); |
| 322 | } | 322 | } |
| 323 | | 323 | |
| 324 | test "string to" { | 324 | test "string to" { |
| ... | @@ -400,12 +400,12 @@ test "clone" { | ... | @@ -400,12 +400,12 @@ test "clone" { |
| 400 | var b = try a.clone(); | 400 | var b = try a.clone(); |
| 401 | defer b.deinit(); | 401 | defer b.deinit(); |
| 402 | | 402 | |
| 403 | try testing.expect((try a.toInt(u32)) == 1234); | 403 | try testing.expectEqual(1234, try a.toInt(u32)); |
| 404 | try testing.expect((try b.toInt(u32)) == 1234); | 404 | try testing.expectEqual(1234, try b.toInt(u32)); |
| 405 | | 405 | |
| 406 | try a.set(77); | 406 | try a.set(77); |
| 407 | try testing.expect((try a.toInt(u32)) == 77); | 407 | try testing.expectEqual(77, try a.toInt(u32)); |
| 408 | try testing.expect((try b.toInt(u32)) == 1234); | 408 | try testing.expectEqual(1234, try b.toInt(u32)); |
| 409 | } | 409 | } |
| 410 | | 410 | |
| 411 | test "swap" { | 411 | test "swap" { |
| ... | @@ -414,20 +414,20 @@ test "swap" { | ... | @@ -414,20 +414,20 @@ test "swap" { |
| 414 | var b = try Managed.initSet(testing.allocator, 5678); | 414 | var b = try Managed.initSet(testing.allocator, 5678); |
| 415 | defer b.deinit(); | 415 | defer b.deinit(); |
| 416 | | 416 | |
| 417 | try testing.expect((try a.toInt(u32)) == 1234); | 417 | try testing.expectEqual(1234, try a.toInt(u32)); |
| 418 | try testing.expect((try b.toInt(u32)) == 5678); | 418 | try testing.expectEqual(5678, try b.toInt(u32)); |
| 419 | | 419 | |
| 420 | a.swap(&b); | 420 | a.swap(&b); |
| 421 | | 421 | |
| 422 | try testing.expect((try a.toInt(u32)) == 5678); | 422 | try testing.expectEqual(5678, try a.toInt(u32)); |
| 423 | try testing.expect((try b.toInt(u32)) == 1234); | 423 | try testing.expectEqual(1234, try b.toInt(u32)); |
| 424 | } | 424 | } |
| 425 | | 425 | |
| 426 | test "to negative" { | 426 | test "to negative" { |
| 427 | var a = try Managed.initSet(testing.allocator, -10); | 427 | var a = try Managed.initSet(testing.allocator, -10); |
| 428 | defer a.deinit(); | 428 | defer a.deinit(); |
| 429 | | 429 | |
| 430 | try testing.expect((try a.toInt(i32)) == -10); | 430 | try testing.expectEqual(-10, try a.toInt(i32)); |
| 431 | } | 431 | } |
| 432 | | 432 | |
| 433 | test "compare" { | 433 | test "compare" { |
| ... | @@ -436,8 +436,8 @@ test "compare" { | ... | @@ -436,8 +436,8 @@ test "compare" { |
| 436 | var b = try Managed.initSet(testing.allocator, 10); | 436 | var b = try Managed.initSet(testing.allocator, 10); |
| 437 | defer b.deinit(); | 437 | defer b.deinit(); |
| 438 | | 438 | |
| 439 | try testing.expect(a.orderAbs(b) == .gt); | 439 | try testing.expectEqual(.gt, a.orderAbs(b)); |
| 440 | try testing.expect(a.order(b) == .lt); | 440 | try testing.expectEqual(.lt, a.order(b)); |
| 441 | } | 441 | } |
| 442 | | 442 | |
| 443 | test "compare similar" { | 443 | test "compare similar" { |
| ... | @@ -446,8 +446,8 @@ test "compare similar" { | ... | @@ -446,8 +446,8 @@ test "compare similar" { |
| 446 | var b = try Managed.initSet(testing.allocator, 0xffffffffeeeeeeeeffffffffeeeeeeef); | 446 | var b = try Managed.initSet(testing.allocator, 0xffffffffeeeeeeeeffffffffeeeeeeef); |
| 447 | defer b.deinit(); | 447 | defer b.deinit(); |
| 448 | | 448 | |
| 449 | try testing.expect(a.orderAbs(b) == .lt); | 449 | try testing.expectEqual(.lt, a.orderAbs(b)); |
| 450 | try testing.expect(b.orderAbs(a) == .gt); | 450 | try testing.expectEqual(.gt, b.orderAbs(a)); |
| 451 | } | 451 | } |
| 452 | | 452 | |
| 453 | test "compare different limb size" { | 453 | test "compare different limb size" { |
| ... | @@ -456,8 +456,8 @@ test "compare different limb size" { | ... | @@ -456,8 +456,8 @@ test "compare different limb size" { |
| 456 | var b = try Managed.initSet(testing.allocator, 1); | 456 | var b = try Managed.initSet(testing.allocator, 1); |
| 457 | defer b.deinit(); | 457 | defer b.deinit(); |
| 458 | | 458 | |
| 459 | try testing.expect(a.orderAbs(b) == .gt); | 459 | try testing.expectEqual(.gt, a.orderAbs(b)); |
| 460 | try testing.expect(b.orderAbs(a) == .lt); | 460 | try testing.expectEqual(.lt, b.orderAbs(a)); |
| 461 | } | 461 | } |
| 462 | | 462 | |
| 463 | test "compare multi-limb" { | 463 | test "compare multi-limb" { |
| ... | @@ -466,8 +466,8 @@ test "compare multi-limb" { | ... | @@ -466,8 +466,8 @@ test "compare multi-limb" { |
| 466 | var b = try Managed.initSet(testing.allocator, 0x7777777799999999ffffeeeeffffeeeeffffeeeee); | 466 | var b = try Managed.initSet(testing.allocator, 0x7777777799999999ffffeeeeffffeeeeffffeeeee); |
| 467 | defer b.deinit(); | 467 | defer b.deinit(); |
| 468 | | 468 | |
| 469 | try testing.expect(a.orderAbs(b) == .gt); | 469 | try testing.expectEqual(.gt, a.orderAbs(b)); |
| 470 | try testing.expect(a.order(b) == .lt); | 470 | try testing.expectEqual(.lt, a.order(b)); |
| 471 | } | 471 | } |
| 472 | | 472 | |
| 473 | test "equality" { | 473 | test "equality" { |
| ... | @@ -485,10 +485,10 @@ test "abs" { | ... | @@ -485,10 +485,10 @@ test "abs" { |
| 485 | defer a.deinit(); | 485 | defer a.deinit(); |
| 486 | | 486 | |
| 487 | a.abs(); | 487 | a.abs(); |
| 488 | try testing.expect((try a.toInt(u32)) == 5); | 488 | try testing.expectEqual(5, try a.toInt(u32)); |
| 489 | | 489 | |
| 490 | a.abs(); | 490 | a.abs(); |
| 491 | try testing.expect((try a.toInt(u32)) == 5); | 491 | try testing.expectEqual(5, try a.toInt(u32)); |
| 492 | } | 492 | } |
| 493 | | 493 | |
| 494 | test "negate" { | 494 | test "negate" { |
| ... | @@ -496,10 +496,10 @@ test "negate" { | ... | @@ -496,10 +496,10 @@ test "negate" { |
| 496 | defer a.deinit(); | 496 | defer a.deinit(); |
| 497 | | 497 | |
| 498 | a.negate(); | 498 | a.negate(); |
| 499 | try testing.expect((try a.toInt(i32)) == -5); | 499 | try testing.expectEqual(-5, try a.toInt(i32)); |
| 500 | | 500 | |
| 501 | a.negate(); | 501 | a.negate(); |
| 502 | try testing.expect((try a.toInt(i32)) == 5); | 502 | try testing.expectEqual(5, try a.toInt(i32)); |
| 503 | } | 503 | } |
| 504 | | 504 | |
| 505 | test "add single-single" { | 505 | test "add single-single" { |
| ... | @@ -512,7 +512,7 @@ test "add single-single" { | ... | @@ -512,7 +512,7 @@ test "add single-single" { |
| 512 | defer c.deinit(); | 512 | defer c.deinit(); |
| 513 | try c.add(&a, &b); | 513 | try c.add(&a, &b); |
| 514 | | 514 | |
| 515 | try testing.expect((try c.toInt(u32)) == 55); | 515 | try testing.expectEqual(55, try c.toInt(u32)); |
| 516 | } | 516 | } |
| 517 | | 517 | |
| 518 | test "add multi-single" { | 518 | test "add multi-single" { |
| ... | @@ -525,10 +525,10 @@ test "add multi-single" { | ... | @@ -525,10 +525,10 @@ test "add multi-single" { |
| 525 | defer c.deinit(); | 525 | defer c.deinit(); |
| 526 | | 526 | |
| 527 | try c.add(&a, &b); | 527 | try c.add(&a, &b); |
| 528 | try testing.expect((try c.toInt(DoubleLimb)) == maxInt(Limb) + 2); | 528 | try testing.expectEqual(maxInt(Limb) + 2, try c.toInt(DoubleLimb)); |
| 529 | | 529 | |
| 530 | try c.add(&b, &a); | 530 | try c.add(&b, &a); |
| 531 | try testing.expect((try c.toInt(DoubleLimb)) == maxInt(Limb) + 2); | 531 | try testing.expectEqual(maxInt(Limb) + 2, try c.toInt(DoubleLimb)); |
| 532 | } | 532 | } |
| 533 | | 533 | |
| 534 | test "add multi-multi" { | 534 | test "add multi-multi" { |
| ... | @@ -546,7 +546,7 @@ test "add multi-multi" { | ... | @@ -546,7 +546,7 @@ test "add multi-multi" { |
| 546 | defer c.deinit(); | 546 | defer c.deinit(); |
| 547 | try c.add(&a, &b); | 547 | try c.add(&a, &b); |
| 548 | | 548 | |
| 549 | try testing.expect((try c.toInt(u128)) == op1 + op2); | 549 | try testing.expectEqual(op1 + op2, try c.toInt(u128)); |
| 550 | } | 550 | } |
| 551 | | 551 | |
| 552 | test "add zero-zero" { | 552 | test "add zero-zero" { |
| ... | @@ -559,7 +559,7 @@ test "add zero-zero" { | ... | @@ -559,7 +559,7 @@ test "add zero-zero" { |
| 559 | defer c.deinit(); | 559 | defer c.deinit(); |
| 560 | try c.add(&a, &b); | 560 | try c.add(&a, &b); |
| 561 | | 561 | |
| 562 | try testing.expect((try c.toInt(u32)) == 0); | 562 | try testing.expectEqual(0, try c.toInt(u32)); |
| 563 | } | 563 | } |
| 564 | | 564 | |
| 565 | test "add alias multi-limb nonzero-zero" { | 565 | test "add alias multi-limb nonzero-zero" { |
| ... | @@ -571,7 +571,7 @@ test "add alias multi-limb nonzero-zero" { | ... | @@ -571,7 +571,7 @@ test "add alias multi-limb nonzero-zero" { |
| 571 | | 571 | |
| 572 | try a.add(&a, &b); | 572 | try a.add(&a, &b); |
| 573 | | 573 | |
| 574 | try testing.expect((try a.toInt(u128)) == op1); | 574 | try testing.expectEqual(op1, try a.toInt(u128)); |
| 575 | } | 575 | } |
| 576 | | 576 | |
| 577 | test "add sign" { | 577 | test "add sign" { |
| ... | @@ -588,16 +588,16 @@ test "add sign" { | ... | @@ -588,16 +588,16 @@ test "add sign" { |
| 588 | defer neg_two.deinit(); | 588 | defer neg_two.deinit(); |
| 589 | | 589 | |
| 590 | try a.add(&one, &two); | 590 | try a.add(&one, &two); |
| 591 | try testing.expect((try a.toInt(i32)) == 3); | 591 | try testing.expectEqual(3, try a.toInt(i32)); |
| 592 | | 592 | |
| 593 | try a.add(&neg_one, &two); | 593 | try a.add(&neg_one, &two); |
| 594 | try testing.expect((try a.toInt(i32)) == 1); | 594 | try testing.expectEqual(1, try a.toInt(i32)); |
| 595 | | 595 | |
| 596 | try a.add(&one, &neg_two); | 596 | try a.add(&one, &neg_two); |
| 597 | try testing.expect((try a.toInt(i32)) == -1); | 597 | try testing.expectEqual(-1, try a.toInt(i32)); |
| 598 | | 598 | |
| 599 | try a.add(&neg_one, &neg_two); | 599 | try a.add(&neg_one, &neg_two); |
| 600 | try testing.expect((try a.toInt(i32)) == -3); | 600 | try testing.expectEqual(-3, try a.toInt(i32)); |
| 601 | } | 601 | } |
| 602 | | 602 | |
| 603 | test "add comptime scalar" { | 603 | test "add comptime scalar" { |
| ... | @@ -608,7 +608,7 @@ test "add comptime scalar" { | ... | @@ -608,7 +608,7 @@ test "add comptime scalar" { |
| 608 | defer b.deinit(); | 608 | defer b.deinit(); |
| 609 | try b.addScalar(&a, 5); | 609 | try b.addScalar(&a, 5); |
| 610 | | 610 | |
| 611 | try testing.expect((try b.toInt(u32)) == 55); | 611 | try testing.expectEqual(55, try b.toInt(u32)); |
| 612 | } | 612 | } |
| 613 | | 613 | |
| 614 | test "add scalar" { | 614 | test "add scalar" { |
| ... | @@ -619,7 +619,7 @@ test "add scalar" { | ... | @@ -619,7 +619,7 @@ test "add scalar" { |
| 619 | defer b.deinit(); | 619 | defer b.deinit(); |
| 620 | try b.addScalar(&a, @as(u32, 31)); | 620 | try b.addScalar(&a, @as(u32, 31)); |
| 621 | | 621 | |
| 622 | try testing.expect((try b.toInt(u32)) == 154); | 622 | try testing.expectEqual(154, try b.toInt(u32)); |
| 623 | } | 623 | } |
| 624 | | 624 | |
| 625 | test "addWrap single-single, unsigned" { | 625 | test "addWrap single-single, unsigned" { |
| ... | @@ -632,7 +632,7 @@ test "addWrap single-single, unsigned" { | ... | @@ -632,7 +632,7 @@ test "addWrap single-single, unsigned" { |
| 632 | const wrapped = try a.addWrap(&a, &b, .unsigned, 17); | 632 | const wrapped = try a.addWrap(&a, &b, .unsigned, 17); |
| 633 | | 633 | |
| 634 | try testing.expect(wrapped); | 634 | try testing.expect(wrapped); |
| 635 | try testing.expect((try a.toInt(u17)) == 9); | 635 | try testing.expectEqual(9, try a.toInt(u17)); |
| 636 | } | 636 | } |
| 637 | | 637 | |
| 638 | test "subWrap single-single, unsigned" { | 638 | test "subWrap single-single, unsigned" { |
| ... | @@ -645,7 +645,7 @@ test "subWrap single-single, unsigned" { | ... | @@ -645,7 +645,7 @@ test "subWrap single-single, unsigned" { |
| 645 | const wrapped = try a.subWrap(&a, &b, .unsigned, 17); | 645 | const wrapped = try a.subWrap(&a, &b, .unsigned, 17); |
| 646 | | 646 | |
| 647 | try testing.expect(wrapped); | 647 | try testing.expect(wrapped); |
| 648 | try testing.expect((try a.toInt(u17)) == 1); | 648 | try testing.expectEqual(1, try a.toInt(u17)); |
| 649 | } | 649 | } |
| 650 | | 650 | |
| 651 | test "addWrap multi-multi, unsigned, limb aligned" { | 651 | test "addWrap multi-multi, unsigned, limb aligned" { |
| ... | @@ -658,7 +658,7 @@ test "addWrap multi-multi, unsigned, limb aligned" { | ... | @@ -658,7 +658,7 @@ test "addWrap multi-multi, unsigned, limb aligned" { |
| 658 | const wrapped = try a.addWrap(&a, &b, .unsigned, @bitSizeOf(DoubleLimb)); | 658 | const wrapped = try a.addWrap(&a, &b, .unsigned, @bitSizeOf(DoubleLimb)); |
| 659 | | 659 | |
| 660 | try testing.expect(wrapped); | 660 | try testing.expect(wrapped); |
| 661 | try testing.expect((try a.toInt(DoubleLimb)) == maxInt(DoubleLimb) - 1); | 661 | try testing.expectEqual(maxInt(DoubleLimb) - 1, try a.toInt(DoubleLimb)); |
| 662 | } | 662 | } |
| 663 | | 663 | |
| 664 | test "subWrap single-multi, unsigned, limb aligned" { | 664 | test "subWrap single-multi, unsigned, limb aligned" { |
| ... | @@ -671,7 +671,7 @@ test "subWrap single-multi, unsigned, limb aligned" { | ... | @@ -671,7 +671,7 @@ test "subWrap single-multi, unsigned, limb aligned" { |
| 671 | const wrapped = try a.subWrap(&a, &b, .unsigned, @bitSizeOf(DoubleLimb)); | 671 | const wrapped = try a.subWrap(&a, &b, .unsigned, @bitSizeOf(DoubleLimb)); |
| 672 | | 672 | |
| 673 | try testing.expect(wrapped); | 673 | try testing.expect(wrapped); |
| 674 | try testing.expect((try a.toInt(DoubleLimb)) == maxInt(DoubleLimb) - 88); | 674 | try testing.expectEqual(maxInt(DoubleLimb) - 88, try a.toInt(DoubleLimb)); |
| 675 | } | 675 | } |
| 676 | | 676 | |
| 677 | test "addWrap single-single, signed" { | 677 | test "addWrap single-single, signed" { |
| ... | @@ -684,7 +684,7 @@ test "addWrap single-single, signed" { | ... | @@ -684,7 +684,7 @@ test "addWrap single-single, signed" { |
| 684 | const wrapped = try a.addWrap(&a, &b, .signed, @bitSizeOf(i21)); | 684 | const wrapped = try a.addWrap(&a, &b, .signed, @bitSizeOf(i21)); |
| 685 | | 685 | |
| 686 | try testing.expect(wrapped); | 686 | try testing.expect(wrapped); |
| 687 | try testing.expect((try a.toInt(i21)) == minInt(i21)); | 687 | try testing.expectEqual(minInt(i21), try a.toInt(i21)); |
| 688 | } | 688 | } |
| 689 | | 689 | |
| 690 | test "subWrap single-single, signed" { | 690 | test "subWrap single-single, signed" { |
| ... | @@ -697,7 +697,7 @@ test "subWrap single-single, signed" { | ... | @@ -697,7 +697,7 @@ test "subWrap single-single, signed" { |
| 697 | const wrapped = try a.subWrap(&a, &b, .signed, @bitSizeOf(i21)); | 697 | const wrapped = try a.subWrap(&a, &b, .signed, @bitSizeOf(i21)); |
| 698 | | 698 | |
| 699 | try testing.expect(wrapped); | 699 | try testing.expect(wrapped); |
| 700 | try testing.expect((try a.toInt(i21)) == maxInt(i21)); | 700 | try testing.expectEqual(maxInt(i21), try a.toInt(i21)); |
| 701 | } | 701 | } |
| 702 | | 702 | |
| 703 | test "addWrap multi-multi, signed, limb aligned" { | 703 | test "addWrap multi-multi, signed, limb aligned" { |
| ... | @@ -710,7 +710,7 @@ test "addWrap multi-multi, signed, limb aligned" { | ... | @@ -710,7 +710,7 @@ test "addWrap multi-multi, signed, limb aligned" { |
| 710 | const wrapped = try a.addWrap(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); | 710 | const wrapped = try a.addWrap(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 711 | | 711 | |
| 712 | try testing.expect(wrapped); | 712 | try testing.expect(wrapped); |
| 713 | try testing.expect((try a.toInt(SignedDoubleLimb)) == -2); | 713 | try testing.expectEqual(-2, try a.toInt(SignedDoubleLimb)); |
| 714 | } | 714 | } |
| 715 | | 715 | |
| 716 | test "subWrap single-multi, signed, limb aligned" { | 716 | test "subWrap single-multi, signed, limb aligned" { |
| ... | @@ -723,7 +723,7 @@ test "subWrap single-multi, signed, limb aligned" { | ... | @@ -723,7 +723,7 @@ test "subWrap single-multi, signed, limb aligned" { |
| 723 | const wrapped = try a.subWrap(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); | 723 | const wrapped = try a.subWrap(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 724 | | 724 | |
| 725 | try testing.expect(wrapped); | 725 | try testing.expect(wrapped); |
| 726 | try testing.expect((try a.toInt(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); | 726 | try testing.expectEqual(maxInt(SignedDoubleLimb), try a.toInt(SignedDoubleLimb)); |
| 727 | } | 727 | } |
| 728 | | 728 | |
| 729 | test "addWrap returns normalized result" { | 729 | test "addWrap returns normalized result" { |
| ... | @@ -763,7 +763,7 @@ test "addSat single-single, unsigned" { | ... | @@ -763,7 +763,7 @@ test "addSat single-single, unsigned" { |
| 763 | | 763 | |
| 764 | try a.addSat(&a, &b, .unsigned, 17); | 764 | try a.addSat(&a, &b, .unsigned, 17); |
| 765 | | 765 | |
| 766 | try testing.expect((try a.toInt(u17)) == maxInt(u17)); | 766 | try testing.expectEqual(maxInt(u17), try a.toInt(u17)); |
| 767 | } | 767 | } |
| 768 | | 768 | |
| 769 | test "subSat single-single, unsigned" { | 769 | test "subSat single-single, unsigned" { |
| ... | @@ -775,7 +775,7 @@ test "subSat single-single, unsigned" { | ... | @@ -775,7 +775,7 @@ test "subSat single-single, unsigned" { |
| 775 | | 775 | |
| 776 | try a.subSat(&a, &b, .unsigned, 17); | 776 | try a.subSat(&a, &b, .unsigned, 17); |
| 777 | | 777 | |
| 778 | try testing.expect((try a.toInt(u17)) == 0); | 778 | try testing.expectEqual(0, try a.toInt(u17)); |
| 779 | } | 779 | } |
| 780 | | 780 | |
| 781 | test "addSat multi-multi, unsigned, limb aligned" { | 781 | test "addSat multi-multi, unsigned, limb aligned" { |
| ... | @@ -787,7 +787,7 @@ test "addSat multi-multi, unsigned, limb aligned" { | ... | @@ -787,7 +787,7 @@ test "addSat multi-multi, unsigned, limb aligned" { |
| 787 | | 787 | |
| 788 | try a.addSat(&a, &b, .unsigned, @bitSizeOf(DoubleLimb)); | 788 | try a.addSat(&a, &b, .unsigned, @bitSizeOf(DoubleLimb)); |
| 789 | | 789 | |
| 790 | try testing.expect((try a.toInt(DoubleLimb)) == maxInt(DoubleLimb)); | 790 | try testing.expectEqual(maxInt(DoubleLimb), try a.toInt(DoubleLimb)); |
| 791 | } | 791 | } |
| 792 | | 792 | |
| 793 | test "subSat single-multi, unsigned, limb aligned" { | 793 | test "subSat single-multi, unsigned, limb aligned" { |
| ... | @@ -799,7 +799,7 @@ test "subSat single-multi, unsigned, limb aligned" { | ... | @@ -799,7 +799,7 @@ test "subSat single-multi, unsigned, limb aligned" { |
| 799 | | 799 | |
| 800 | try a.subSat(&a, &b, .unsigned, @bitSizeOf(DoubleLimb)); | 800 | try a.subSat(&a, &b, .unsigned, @bitSizeOf(DoubleLimb)); |
| 801 | | 801 | |
| 802 | try testing.expect((try a.toInt(DoubleLimb)) == 0); | 802 | try testing.expectEqual(0, try a.toInt(DoubleLimb)); |
| 803 | } | 803 | } |
| 804 | | 804 | |
| 805 | test "addSat single-single, signed" { | 805 | test "addSat single-single, signed" { |
| ... | @@ -811,7 +811,7 @@ test "addSat single-single, signed" { | ... | @@ -811,7 +811,7 @@ test "addSat single-single, signed" { |
| 811 | | 811 | |
| 812 | try a.addSat(&a, &b, .signed, @bitSizeOf(i14)); | 812 | try a.addSat(&a, &b, .signed, @bitSizeOf(i14)); |
| 813 | | 813 | |
| 814 | try testing.expect((try a.toInt(i14)) == maxInt(i14)); | 814 | try testing.expectEqual(maxInt(i14), try a.toInt(i14)); |
| 815 | } | 815 | } |
| 816 | | 816 | |
| 817 | test "subSat single-single, signed" { | 817 | test "subSat single-single, signed" { |
| ... | @@ -823,7 +823,7 @@ test "subSat single-single, signed" { | ... | @@ -823,7 +823,7 @@ test "subSat single-single, signed" { |
| 823 | | 823 | |
| 824 | try a.subSat(&a, &b, .signed, @bitSizeOf(i21)); | 824 | try a.subSat(&a, &b, .signed, @bitSizeOf(i21)); |
| 825 | | 825 | |
| 826 | try testing.expect((try a.toInt(i21)) == minInt(i21)); | 826 | try testing.expectEqual(minInt(i21), try a.toInt(i21)); |
| 827 | } | 827 | } |
| 828 | | 828 | |
| 829 | test "addSat multi-multi, signed, limb aligned" { | 829 | test "addSat multi-multi, signed, limb aligned" { |
| ... | @@ -835,7 +835,7 @@ test "addSat multi-multi, signed, limb aligned" { | ... | @@ -835,7 +835,7 @@ test "addSat multi-multi, signed, limb aligned" { |
| 835 | | 835 | |
| 836 | try a.addSat(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); | 836 | try a.addSat(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 837 | | 837 | |
| 838 | try testing.expect((try a.toInt(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); | 838 | try testing.expectEqual(maxInt(SignedDoubleLimb), try a.toInt(SignedDoubleLimb)); |
| 839 | } | 839 | } |
| 840 | | 840 | |
| 841 | test "subSat single-multi, signed, limb aligned" { | 841 | test "subSat single-multi, signed, limb aligned" { |
| ... | @@ -847,7 +847,7 @@ test "subSat single-multi, signed, limb aligned" { | ... | @@ -847,7 +847,7 @@ test "subSat single-multi, signed, limb aligned" { |
| 847 | | 847 | |
| 848 | try a.subSat(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); | 848 | try a.subSat(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 849 | | 849 | |
| 850 | try testing.expect((try a.toInt(SignedDoubleLimb)) == minInt(SignedDoubleLimb)); | 850 | try testing.expectEqual(minInt(SignedDoubleLimb), try a.toInt(SignedDoubleLimb)); |
| 851 | } | 851 | } |
| 852 | | 852 | |
| 853 | test "sub single-single" { | 853 | test "sub single-single" { |
| ... | @@ -860,7 +860,7 @@ test "sub single-single" { | ... | @@ -860,7 +860,7 @@ test "sub single-single" { |
| 860 | defer c.deinit(); | 860 | defer c.deinit(); |
| 861 | try c.sub(&a, &b); | 861 | try c.sub(&a, &b); |
| 862 | | 862 | |
| 863 | try testing.expect((try c.toInt(u32)) == 45); | 863 | try testing.expectEqual(45, try c.toInt(u32)); |
| 864 | } | 864 | } |
| 865 | | 865 | |
| 866 | test "sub multi-single" { | 866 | test "sub multi-single" { |
| ... | @@ -873,7 +873,7 @@ test "sub multi-single" { | ... | @@ -873,7 +873,7 @@ test "sub multi-single" { |
| 873 | defer c.deinit(); | 873 | defer c.deinit(); |
| 874 | try c.sub(&a, &b); | 874 | try c.sub(&a, &b); |
| 875 | | 875 | |
| 876 | try testing.expect((try c.toInt(Limb)) == maxInt(Limb)); | 876 | try testing.expectEqual(maxInt(Limb), try c.toInt(Limb)); |
| 877 | } | 877 | } |
| 878 | | 878 | |
| 879 | test "sub multi-multi" { | 879 | test "sub multi-multi" { |
| ... | @@ -890,7 +890,7 @@ test "sub multi-multi" { | ... | @@ -890,7 +890,7 @@ test "sub multi-multi" { |
| 890 | defer c.deinit(); | 890 | defer c.deinit(); |
| 891 | try c.sub(&a, &b); | 891 | try c.sub(&a, &b); |
| 892 | | 892 | |
| 893 | try testing.expect((try c.toInt(u128)) == op1 - op2); | 893 | try testing.expectEqual(op1 - op2, try c.toInt(u128)); |
| 894 | } | 894 | } |
| 895 | | 895 | |
| 896 | test "sub equal" { | 896 | test "sub equal" { |
| ... | @@ -903,7 +903,7 @@ test "sub equal" { | ... | @@ -903,7 +903,7 @@ test "sub equal" { |
| 903 | defer c.deinit(); | 903 | defer c.deinit(); |
| 904 | try c.sub(&a, &b); | 904 | try c.sub(&a, &b); |
| 905 | | 905 | |
| 906 | try testing.expect((try c.toInt(u32)) == 0); | 906 | try testing.expectEqual(0, try c.toInt(u32)); |
| 907 | } | 907 | } |
| 908 | | 908 | |
| 909 | test "sub sign" { | 909 | test "sub sign" { |
| ... | @@ -920,19 +920,19 @@ test "sub sign" { | ... | @@ -920,19 +920,19 @@ test "sub sign" { |
| 920 | defer neg_two.deinit(); | 920 | defer neg_two.deinit(); |
| 921 | | 921 | |
| 922 | try a.sub(&one, &two); | 922 | try a.sub(&one, &two); |
| 923 | try testing.expect((try a.toInt(i32)) == -1); | 923 | try testing.expectEqual(-1, try a.toInt(i32)); |
| 924 | | 924 | |
| 925 | try a.sub(&neg_one, &two); | 925 | try a.sub(&neg_one, &two); |
| 926 | try testing.expect((try a.toInt(i32)) == -3); | 926 | try testing.expectEqual(-3, try a.toInt(i32)); |
| 927 | | 927 | |
| 928 | try a.sub(&one, &neg_two); | 928 | try a.sub(&one, &neg_two); |
| 929 | try testing.expect((try a.toInt(i32)) == 3); | 929 | try testing.expectEqual(3, try a.toInt(i32)); |
| 930 | | 930 | |
| 931 | try a.sub(&neg_one, &neg_two); | 931 | try a.sub(&neg_one, &neg_two); |
| 932 | try testing.expect((try a.toInt(i32)) == 1); | 932 | try testing.expectEqual(1, try a.toInt(i32)); |
| 933 | | 933 | |
| 934 | try a.sub(&neg_two, &neg_one); | 934 | try a.sub(&neg_two, &neg_one); |
| 935 | try testing.expect((try a.toInt(i32)) == -1); | 935 | try testing.expectEqual(-1, try a.toInt(i32)); |
| 936 | } | 936 | } |
| 937 | | 937 | |
| 938 | test "mul single-single" { | 938 | test "mul single-single" { |
| ... | @@ -945,7 +945,7 @@ test "mul single-single" { | ... | @@ -945,7 +945,7 @@ test "mul single-single" { |
| 945 | defer c.deinit(); | 945 | defer c.deinit(); |
| 946 | try c.mul(&a, &b); | 946 | try c.mul(&a, &b); |
| 947 | | 947 | |
| 948 | try testing.expect((try c.toInt(u64)) == 250); | 948 | try testing.expectEqual(250, try c.toInt(u64)); |
| 949 | } | 949 | } |
| 950 | | 950 | |
| 951 | test "mul multi-single" { | 951 | test "mul multi-single" { |
| ... | @@ -958,7 +958,7 @@ test "mul multi-single" { | ... | @@ -958,7 +958,7 @@ test "mul multi-single" { |
| 958 | defer c.deinit(); | 958 | defer c.deinit(); |
| 959 | try c.mul(&a, &b); | 959 | try c.mul(&a, &b); |
| 960 | | 960 | |
| 961 | try testing.expect((try c.toInt(DoubleLimb)) == 2 * maxInt(Limb)); | 961 | try testing.expectEqual(2 * maxInt(Limb), try c.toInt(DoubleLimb)); |
| 962 | } | 962 | } |
| 963 | | 963 | |
| 964 | test "mul multi-multi" { | 964 | test "mul multi-multi" { |
| ... | @@ -977,7 +977,7 @@ test "mul multi-multi" { | ... | @@ -977,7 +977,7 @@ test "mul multi-multi" { |
| 977 | defer c.deinit(); | 977 | defer c.deinit(); |
| 978 | try c.mul(&a, &b); | 978 | try c.mul(&a, &b); |
| 979 | | 979 | |
| 980 | try testing.expect((try c.toInt(u256)) == op1 * op2); | 980 | try testing.expectEqual(op1 * op2, try c.toInt(u256)); |
| 981 | } | 981 | } |
| 982 | | 982 | |
| 983 | test "mul alias r with a" { | 983 | test "mul alias r with a" { |
| ... | @@ -988,7 +988,7 @@ test "mul alias r with a" { | ... | @@ -988,7 +988,7 @@ test "mul alias r with a" { |
| 988 | | 988 | |
| 989 | try a.mul(&a, &b); | 989 | try a.mul(&a, &b); |
| 990 | | 990 | |
| 991 | try testing.expect((try a.toInt(DoubleLimb)) == 2 * maxInt(Limb)); | 991 | try testing.expectEqual(2 * maxInt(Limb), try a.toInt(DoubleLimb)); |
| 992 | } | 992 | } |
| 993 | | 993 | |
| 994 | test "mul alias r with b" { | 994 | test "mul alias r with b" { |
| ... | @@ -999,7 +999,7 @@ test "mul alias r with b" { | ... | @@ -999,7 +999,7 @@ test "mul alias r with b" { |
| 999 | | 999 | |
| 1000 | try a.mul(&b, &a); | 1000 | try a.mul(&b, &a); |
| 1001 | | 1001 | |
| 1002 | try testing.expect((try a.toInt(DoubleLimb)) == 2 * maxInt(Limb)); | 1002 | try testing.expectEqual(2 * maxInt(Limb), try a.toInt(DoubleLimb)); |
| 1003 | } | 1003 | } |
| 1004 | | 1004 | |
| 1005 | test "mul alias r with a and b" { | 1005 | test "mul alias r with a and b" { |
| ... | @@ -1008,7 +1008,7 @@ test "mul alias r with a and b" { | ... | @@ -1008,7 +1008,7 @@ test "mul alias r with a and b" { |
| 1008 | | 1008 | |
| 1009 | try a.mul(&a, &a); | 1009 | try a.mul(&a, &a); |
| 1010 | | 1010 | |
| 1011 | try testing.expect((try a.toInt(DoubleLimb)) == maxInt(Limb) * maxInt(Limb)); | 1011 | try testing.expectEqual(maxInt(Limb) * maxInt(Limb), try a.toInt(DoubleLimb)); |
| 1012 | } | 1012 | } |
| 1013 | | 1013 | |
| 1014 | test "mul a*0" { | 1014 | test "mul a*0" { |
| ... | @@ -1021,7 +1021,7 @@ test "mul a*0" { | ... | @@ -1021,7 +1021,7 @@ test "mul a*0" { |
| 1021 | defer c.deinit(); | 1021 | defer c.deinit(); |
| 1022 | try c.mul(&a, &b); | 1022 | try c.mul(&a, &b); |
| 1023 | | 1023 | |
| 1024 | try testing.expect((try c.toInt(u32)) == 0); | 1024 | try testing.expectEqual(0, try c.toInt(u32)); |
| 1025 | } | 1025 | } |
| 1026 | | 1026 | |
| 1027 | test "mul 0*0" { | 1027 | test "mul 0*0" { |
| ... | @@ -1034,7 +1034,7 @@ test "mul 0*0" { | ... | @@ -1034,7 +1034,7 @@ test "mul 0*0" { |
| 1034 | defer c.deinit(); | 1034 | defer c.deinit(); |
| 1035 | try c.mul(&a, &b); | 1035 | try c.mul(&a, &b); |
| 1036 | | 1036 | |
| 1037 | try testing.expect((try c.toInt(u32)) == 0); | 1037 | try testing.expectEqual(0, try c.toInt(u32)); |
| 1038 | } | 1038 | } |
| 1039 | | 1039 | |
| 1040 | test "mul large" { | 1040 | test "mul large" { |
| ... | @@ -1068,7 +1068,7 @@ test "mulWrap single-single unsigned" { | ... | @@ -1068,7 +1068,7 @@ test "mulWrap single-single unsigned" { |
| 1068 | defer c.deinit(); | 1068 | defer c.deinit(); |
| 1069 | try c.mulWrap(&a, &b, .unsigned, 17); | 1069 | try c.mulWrap(&a, &b, .unsigned, 17); |
| 1070 | | 1070 | |
| 1071 | try testing.expect((try c.toInt(u17)) == 59836); | 1071 | try testing.expectEqual(59836, try c.toInt(u17)); |
| 1072 | } | 1072 | } |
| 1073 | | 1073 | |
| 1074 | test "mulWrap single-single signed" { | 1074 | test "mulWrap single-single signed" { |
| ... | @@ -1081,7 +1081,7 @@ test "mulWrap single-single signed" { | ... | @@ -1081,7 +1081,7 @@ test "mulWrap single-single signed" { |
| 1081 | defer c.deinit(); | 1081 | defer c.deinit(); |
| 1082 | try c.mulWrap(&a, &b, .signed, 17); | 1082 | try c.mulWrap(&a, &b, .signed, 17); |
| 1083 | | 1083 | |
| 1084 | try testing.expect((try c.toInt(i17)) == -59836); | 1084 | try testing.expectEqual(-59836, try c.toInt(i17)); |
| 1085 | } | 1085 | } |
| 1086 | | 1086 | |
| 1087 | test "mulWrap multi-multi unsigned" { | 1087 | test "mulWrap multi-multi unsigned" { |
| ... | @@ -1100,7 +1100,7 @@ test "mulWrap multi-multi unsigned" { | ... | @@ -1100,7 +1100,7 @@ test "mulWrap multi-multi unsigned" { |
| 1100 | defer c.deinit(); | 1100 | defer c.deinit(); |
| 1101 | try c.mulWrap(&a, &b, .unsigned, 65); | 1101 | try c.mulWrap(&a, &b, .unsigned, 65); |
| 1102 | | 1102 | |
| 1103 | try testing.expect((try c.toInt(u256)) == (op1 * op2) & ((1 << 65) - 1)); | 1103 | try testing.expectEqual((op1 * op2) & ((1 << 65) - 1), try c.toInt(u256)); |
| 1104 | } | 1104 | } |
| 1105 | | 1105 | |
| 1106 | test "mulWrap multi-multi signed" { | 1106 | test "mulWrap multi-multi signed" { |
| ... | @@ -1118,7 +1118,7 @@ test "mulWrap multi-multi signed" { | ... | @@ -1118,7 +1118,7 @@ test "mulWrap multi-multi signed" { |
| 1118 | defer c.deinit(); | 1118 | defer c.deinit(); |
| 1119 | try c.mulWrap(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); | 1119 | try c.mulWrap(&a, &b, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 1120 | | 1120 | |
| 1121 | try testing.expect((try c.toInt(SignedDoubleLimb)) == minInt(SignedDoubleLimb) + 2); | 1121 | try testing.expectEqual(minInt(SignedDoubleLimb) + 2, try c.toInt(SignedDoubleLimb)); |
| 1122 | } | 1122 | } |
| 1123 | | 1123 | |
| 1124 | test "mulWrap large" { | 1124 | test "mulWrap large" { |
| ... | @@ -1157,8 +1157,8 @@ test "div single-half no rem" { | ... | @@ -1157,8 +1157,8 @@ test "div single-half no rem" { |
| 1157 | defer r.deinit(); | 1157 | defer r.deinit(); |
| 1158 | try Managed.divTrunc(&q, &r, &a, &b); | 1158 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1159 | | 1159 | |
| 1160 | try testing.expect((try q.toInt(u32)) == 10); | 1160 | try testing.expectEqual(10, try q.toInt(u32)); |
| 1161 | try testing.expect((try r.toInt(u32)) == 0); | 1161 | try testing.expectEqual(0, try r.toInt(u32)); |
| 1162 | } | 1162 | } |
| 1163 | | 1163 | |
| 1164 | test "div single-half with rem" { | 1164 | test "div single-half with rem" { |
| ... | @@ -1173,8 +1173,8 @@ test "div single-half with rem" { | ... | @@ -1173,8 +1173,8 @@ test "div single-half with rem" { |
| 1173 | defer r.deinit(); | 1173 | defer r.deinit(); |
| 1174 | try Managed.divTrunc(&q, &r, &a, &b); | 1174 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1175 | | 1175 | |
| 1176 | try testing.expect((try q.toInt(u32)) == 9); | 1176 | try testing.expectEqual(9, try q.toInt(u32)); |
| 1177 | try testing.expect((try r.toInt(u32)) == 4); | 1177 | try testing.expectEqual(4, try r.toInt(u32)); |
| 1178 | } | 1178 | } |
| 1179 | | 1179 | |
| 1180 | test "div single-single no rem" { | 1180 | test "div single-single no rem" { |
| ... | @@ -1190,8 +1190,8 @@ test "div single-single no rem" { | ... | @@ -1190,8 +1190,8 @@ test "div single-single no rem" { |
| 1190 | defer r.deinit(); | 1190 | defer r.deinit(); |
| 1191 | try Managed.divTrunc(&q, &r, &a, &b); | 1191 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1192 | | 1192 | |
| 1193 | try testing.expect((try q.toInt(u32)) == 131072); | 1193 | try testing.expectEqual(131072, try q.toInt(u32)); |
| 1194 | try testing.expect((try r.toInt(u32)) == 0); | 1194 | try testing.expectEqual(0, try r.toInt(u32)); |
| 1195 | } | 1195 | } |
| 1196 | | 1196 | |
| 1197 | test "div single-single with rem" { | 1197 | test "div single-single with rem" { |
| ... | @@ -1206,8 +1206,8 @@ test "div single-single with rem" { | ... | @@ -1206,8 +1206,8 @@ test "div single-single with rem" { |
| 1206 | defer r.deinit(); | 1206 | defer r.deinit(); |
| 1207 | try Managed.divTrunc(&q, &r, &a, &b); | 1207 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1208 | | 1208 | |
| 1209 | try testing.expect((try q.toInt(u64)) == 131072); | 1209 | try testing.expectEqual(131072, try q.toInt(u64)); |
| 1210 | try testing.expect((try r.toInt(u64)) == 8589934592); | 1210 | try testing.expectEqual(8589934592, try r.toInt(u64)); |
| 1211 | } | 1211 | } |
| 1212 | | 1212 | |
| 1213 | test "div multi-single no rem" { | 1213 | test "div multi-single no rem" { |
| ... | @@ -1226,8 +1226,8 @@ test "div multi-single no rem" { | ... | @@ -1226,8 +1226,8 @@ test "div multi-single no rem" { |
| 1226 | defer r.deinit(); | 1226 | defer r.deinit(); |
| 1227 | try Managed.divTrunc(&q, &r, &a, &b); | 1227 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1228 | | 1228 | |
| 1229 | try testing.expect((try q.toInt(u64)) == op1 / op2); | 1229 | try testing.expectEqual(op1 / op2, try q.toInt(u64)); |
| 1230 | try testing.expect((try r.toInt(u64)) == 0); | 1230 | try testing.expectEqual(0, try r.toInt(u64)); |
| 1231 | } | 1231 | } |
| 1232 | | 1232 | |
| 1233 | test "div multi-single with rem" { | 1233 | test "div multi-single with rem" { |
| ... | @@ -1246,8 +1246,8 @@ test "div multi-single with rem" { | ... | @@ -1246,8 +1246,8 @@ test "div multi-single with rem" { |
| 1246 | defer r.deinit(); | 1246 | defer r.deinit(); |
| 1247 | try Managed.divTrunc(&q, &r, &a, &b); | 1247 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1248 | | 1248 | |
| 1249 | try testing.expect((try q.toInt(u64)) == op1 / op2); | 1249 | try testing.expectEqual(op1 / op2, try q.toInt(u64)); |
| 1250 | try testing.expect((try r.toInt(u64)) == 3); | 1250 | try testing.expectEqual(3, try r.toInt(u64)); |
| 1251 | } | 1251 | } |
| 1252 | | 1252 | |
| 1253 | test "div multi>2-single" { | 1253 | test "div multi>2-single" { |
| ... | @@ -1266,8 +1266,8 @@ test "div multi>2-single" { | ... | @@ -1266,8 +1266,8 @@ test "div multi>2-single" { |
| 1266 | defer r.deinit(); | 1266 | defer r.deinit(); |
| 1267 | try Managed.divTrunc(&q, &r, &a, &b); | 1267 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1268 | | 1268 | |
| 1269 | try testing.expect((try q.toInt(u128)) == op1 / op2); | 1269 | try testing.expectEqual(op1 / op2, try q.toInt(u128)); |
| 1270 | try testing.expect((try r.toInt(u32)) == 0x3e4e); | 1270 | try testing.expectEqual(0x3e4e, try r.toInt(u32)); |
| 1271 | } | 1271 | } |
| 1272 | | 1272 | |
| 1273 | test "div single-single q < r" { | 1273 | test "div single-single q < r" { |
| ... | @@ -1282,8 +1282,8 @@ test "div single-single q < r" { | ... | @@ -1282,8 +1282,8 @@ test "div single-single q < r" { |
| 1282 | defer r.deinit(); | 1282 | defer r.deinit(); |
| 1283 | try Managed.divTrunc(&q, &r, &a, &b); | 1283 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1284 | | 1284 | |
| 1285 | try testing.expect((try q.toInt(u64)) == 0); | 1285 | try testing.expectEqual(0, try q.toInt(u64)); |
| 1286 | try testing.expect((try r.toInt(u64)) == 0x0078f432); | 1286 | try testing.expectEqual(0x0078f432, try r.toInt(u64)); |
| 1287 | } | 1287 | } |
| 1288 | | 1288 | |
| 1289 | test "div single-single q == r" { | 1289 | test "div single-single q == r" { |
| ... | @@ -1298,8 +1298,8 @@ test "div single-single q == r" { | ... | @@ -1298,8 +1298,8 @@ test "div single-single q == r" { |
| 1298 | defer r.deinit(); | 1298 | defer r.deinit(); |
| 1299 | try Managed.divTrunc(&q, &r, &a, &b); | 1299 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1300 | | 1300 | |
| 1301 | try testing.expect((try q.toInt(u64)) == 1); | 1301 | try testing.expectEqual(1, try q.toInt(u64)); |
| 1302 | try testing.expect((try r.toInt(u64)) == 0); | 1302 | try testing.expectEqual(0, try r.toInt(u64)); |
| 1303 | } | 1303 | } |
| 1304 | | 1304 | |
| 1305 | test "div q=0 alias" { | 1305 | test "div q=0 alias" { |
| ... | @@ -1310,8 +1310,8 @@ test "div q=0 alias" { | ... | @@ -1310,8 +1310,8 @@ test "div q=0 alias" { |
| 1310 | | 1310 | |
| 1311 | try Managed.divTrunc(&a, &b, &a, &b); | 1311 | try Managed.divTrunc(&a, &b, &a, &b); |
| 1312 | | 1312 | |
| 1313 | try testing.expect((try a.toInt(u64)) == 0); | 1313 | try testing.expectEqual(0, try a.toInt(u64)); |
| 1314 | try testing.expect((try b.toInt(u64)) == 3); | 1314 | try testing.expectEqual(3, try b.toInt(u64)); |
| 1315 | } | 1315 | } |
| 1316 | | 1316 | |
| 1317 | test "div multi-multi q < r" { | 1317 | test "div multi-multi q < r" { |
| ... | @@ -1330,8 +1330,8 @@ test "div multi-multi q < r" { | ... | @@ -1330,8 +1330,8 @@ test "div multi-multi q < r" { |
| 1330 | defer r.deinit(); | 1330 | defer r.deinit(); |
| 1331 | try Managed.divTrunc(&q, &r, &a, &b); | 1331 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1332 | | 1332 | |
| 1333 | try testing.expect((try q.toInt(u128)) == 0); | 1333 | try testing.expectEqual(0, try q.toInt(u128)); |
| 1334 | try testing.expect((try r.toInt(u128)) == op1); | 1334 | try testing.expectEqual(op1, try r.toInt(u128)); |
| 1335 | } | 1335 | } |
| 1336 | | 1336 | |
| 1337 | test "div trunc single-single +/+" { | 1337 | test "div trunc single-single +/+" { |
| ... | @@ -1354,8 +1354,8 @@ test "div trunc single-single +/+" { | ... | @@ -1354,8 +1354,8 @@ test "div trunc single-single +/+" { |
| 1354 | const eq = @divTrunc(u, v); | 1354 | const eq = @divTrunc(u, v); |
| 1355 | const er = @mod(u, v); | 1355 | const er = @mod(u, v); |
| 1356 | | 1356 | |
| 1357 | try testing.expect((try q.toInt(i32)) == eq); | 1357 | try testing.expectEqual(eq, try q.toInt(i32)); |
| 1358 | try testing.expect((try r.toInt(i32)) == er); | 1358 | try testing.expectEqual(er, try r.toInt(i32)); |
| 1359 | } | 1359 | } |
| 1360 | | 1360 | |
| 1361 | test "div trunc single-single -/+" { | 1361 | test "div trunc single-single -/+" { |
| ... | @@ -1378,8 +1378,8 @@ test "div trunc single-single -/+" { | ... | @@ -1378,8 +1378,8 @@ test "div trunc single-single -/+" { |
| 1378 | const eq = -1; | 1378 | const eq = -1; |
| 1379 | const er = -2; | 1379 | const er = -2; |
| 1380 | | 1380 | |
| 1381 | try testing.expect((try q.toInt(i32)) == eq); | 1381 | try testing.expectEqual(eq, try q.toInt(i32)); |
| 1382 | try testing.expect((try r.toInt(i32)) == er); | 1382 | try testing.expectEqual(er, try r.toInt(i32)); |
| 1383 | } | 1383 | } |
| 1384 | | 1384 | |
| 1385 | test "div trunc single-single +/-" { | 1385 | test "div trunc single-single +/-" { |
| ... | @@ -1402,8 +1402,8 @@ test "div trunc single-single +/-" { | ... | @@ -1402,8 +1402,8 @@ test "div trunc single-single +/-" { |
| 1402 | const eq = -1; | 1402 | const eq = -1; |
| 1403 | const er = 2; | 1403 | const er = 2; |
| 1404 | | 1404 | |
| 1405 | try testing.expect((try q.toInt(i32)) == eq); | 1405 | try testing.expectEqual(eq, try q.toInt(i32)); |
| 1406 | try testing.expect((try r.toInt(i32)) == er); | 1406 | try testing.expectEqual(er, try r.toInt(i32)); |
| 1407 | } | 1407 | } |
| 1408 | | 1408 | |
| 1409 | test "div trunc single-single -/-" { | 1409 | test "div trunc single-single -/-" { |
| ... | @@ -1426,8 +1426,8 @@ test "div trunc single-single -/-" { | ... | @@ -1426,8 +1426,8 @@ test "div trunc single-single -/-" { |
| 1426 | const eq = 1; | 1426 | const eq = 1; |
| 1427 | const er = -2; | 1427 | const er = -2; |
| 1428 | | 1428 | |
| 1429 | try testing.expect((try q.toInt(i32)) == eq); | 1429 | try testing.expectEqual(eq, try q.toInt(i32)); |
| 1430 | try testing.expect((try r.toInt(i32)) == er); | 1430 | try testing.expectEqual(er, try r.toInt(i32)); |
| 1431 | } | 1431 | } |
| 1432 | | 1432 | |
| 1433 | test "divTrunc #15535" { | 1433 | test "divTrunc #15535" { |
| ... | @@ -1440,7 +1440,7 @@ test "divTrunc #15535" { | ... | @@ -1440,7 +1440,7 @@ test "divTrunc #15535" { |
| 1440 | var q = try Managed.init(testing.allocator); | 1440 | var q = try Managed.init(testing.allocator); |
| 1441 | defer q.deinit(); | 1441 | defer q.deinit(); |
| 1442 | try q.divTrunc(&r, &x, &x); | 1442 | try q.divTrunc(&r, &x, &x); |
| 1443 | try testing.expect(r.order(one) == std.math.Order.lt); | 1443 | try testing.expectEqual(std.math.Order.lt, r.order(one)); |
| 1444 | } | 1444 | } |
| 1445 | | 1445 | |
| 1446 | test "divFloor #10932" { | 1446 | test "divFloor #10932" { |
| ... | @@ -1463,8 +1463,8 @@ test "divFloor #10932" { | ... | @@ -1463,8 +1463,8 @@ test "divFloor #10932" { |
| 1463 | | 1463 | |
| 1464 | const ress = try res.toString(testing.allocator, 16, .lower); | 1464 | const ress = try res.toString(testing.allocator, 16, .lower); |
| 1465 | defer testing.allocator.free(ress); | 1465 | defer testing.allocator.free(ress); |
| 1466 | try testing.expect(std.mem.eql(u8, ress, "194bd136316c046d070b763396297bf8869a605030216b52597015902a172b2a752f62af1568dcd431602f03725bfa62b0be71ae86616210972c0126e173503011ca48c5747ff066d159c95e46b69cbb14c8fc0bd2bf0919f921be96463200000000000000000000000000000000000000000000000000000000000000000000000000000000")); | 1466 | try testing.expectEqualStrings("194bd136316c046d070b763396297bf8869a605030216b52597015902a172b2a752f62af1568dcd431602f03725bfa62b0be71ae86616210972c0126e173503011ca48c5747ff066d159c95e46b69cbb14c8fc0bd2bf0919f921be96463200000000000000000000000000000000000000000000000000000000000000000000000000000000", ress); |
| 1467 | try testing.expect((try mod.toInt(i32)) == 0); | 1467 | try testing.expectEqual(0, try mod.toInt(i32)); |
| 1468 | } | 1468 | } |
| 1469 | | 1469 | |
| 1470 | test "divFloor #11166" { | 1470 | test "divFloor #11166" { |
| ... | @@ -1487,11 +1487,11 @@ test "divFloor #11166" { | ... | @@ -1487,11 +1487,11 @@ test "divFloor #11166" { |
| 1487 | | 1487 | |
| 1488 | const ress = try res.toString(testing.allocator, 10, .lower); | 1488 | const ress = try res.toString(testing.allocator, 10, .lower); |
| 1489 | defer testing.allocator.free(ress); | 1489 | defer testing.allocator.free(ress); |
| 1490 | try testing.expect(std.mem.eql(u8, ress, "1000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); | 1490 | try testing.expectEqualStrings("1000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", ress); |
| 1491 | | 1491 | |
| 1492 | const mods = try mod.toString(testing.allocator, 10, .lower); | 1492 | const mods = try mod.toString(testing.allocator, 10, .lower); |
| 1493 | defer testing.allocator.free(mods); | 1493 | defer testing.allocator.free(mods); |
| 1494 | try testing.expect(std.mem.eql(u8, mods, "870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); | 1494 | try testing.expectEqualStrings("870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", mods); |
| 1495 | } | 1495 | } |
| 1496 | | 1496 | |
| 1497 | test "gcd #10932" { | 1497 | test "gcd #10932" { |
| ... | @@ -1511,7 +1511,7 @@ test "gcd #10932" { | ... | @@ -1511,7 +1511,7 @@ test "gcd #10932" { |
| 1511 | | 1511 | |
| 1512 | const ress = try res.toString(testing.allocator, 16, .lower); | 1512 | const ress = try res.toString(testing.allocator, 16, .lower); |
| 1513 | defer testing.allocator.free(ress); | 1513 | defer testing.allocator.free(ress); |
| 1514 | try testing.expect(std.mem.eql(u8, ress, "1a974a5c9734476ff5a3604bcc678a756beacfc21b4427d1f2c1f56f5d4e411a162c56136e20000000000000000000000000000000")); | 1514 | try testing.expectEqualStrings("1a974a5c9734476ff5a3604bcc678a756beacfc21b4427d1f2c1f56f5d4e411a162c56136e20000000000000000000000000000000", ress); |
| 1515 | } | 1515 | } |
| 1516 | | 1516 | |
| 1517 | test "bitAnd #10932" { | 1517 | test "bitAnd #10932" { |
| ... | @@ -1529,7 +1529,7 @@ test "bitAnd #10932" { | ... | @@ -1529,7 +1529,7 @@ test "bitAnd #10932" { |
| 1529 | | 1529 | |
| 1530 | try res.bitAnd(&a, &b); | 1530 | try res.bitAnd(&a, &b); |
| 1531 | | 1531 | |
| 1532 | try testing.expect((try res.toInt(i32)) == 0); | 1532 | try testing.expectEqual(0, try res.toInt(i32)); |
| 1533 | } | 1533 | } |
| 1534 | | 1534 | |
| 1535 | test "bit And #19235" { | 1535 | test "bit And #19235" { |
| ... | @@ -1542,7 +1542,7 @@ test "bit And #19235" { | ... | @@ -1542,7 +1542,7 @@ test "bit And #19235" { |
| 1542 | | 1542 | |
| 1543 | try r.bitAnd(&a, &b); | 1543 | try r.bitAnd(&a, &b); |
| 1544 | | 1544 | |
| 1545 | try testing.expect((try r.toInt(i128)) == 0x10000000000000000); | 1545 | try testing.expectEqual(0x10000000000000000, try r.toInt(i128)); |
| 1546 | } | 1546 | } |
| 1547 | | 1547 | |
| 1548 | test "div floor single-single +/+" { | 1548 | test "div floor single-single +/+" { |
| ... | @@ -1565,8 +1565,8 @@ test "div floor single-single +/+" { | ... | @@ -1565,8 +1565,8 @@ test "div floor single-single +/+" { |
| 1565 | const eq = 1; | 1565 | const eq = 1; |
| 1566 | const er = 2; | 1566 | const er = 2; |
| 1567 | | 1567 | |
| 1568 | try testing.expect((try q.toInt(i32)) == eq); | 1568 | try testing.expectEqual(eq, try q.toInt(i32)); |
| 1569 | try testing.expect((try r.toInt(i32)) == er); | 1569 | try testing.expectEqual(er, try r.toInt(i32)); |
| 1570 | } | 1570 | } |
| 1571 | | 1571 | |
| 1572 | test "div floor single-single -/+" { | 1572 | test "div floor single-single -/+" { |
| ... | @@ -1589,8 +1589,8 @@ test "div floor single-single -/+" { | ... | @@ -1589,8 +1589,8 @@ test "div floor single-single -/+" { |
| 1589 | const eq = -2; | 1589 | const eq = -2; |
| 1590 | const er = 1; | 1590 | const er = 1; |
| 1591 | | 1591 | |
| 1592 | try testing.expect((try q.toInt(i32)) == eq); | 1592 | try testing.expectEqual(eq, try q.toInt(i32)); |
| 1593 | try testing.expect((try r.toInt(i32)) == er); | 1593 | try testing.expectEqual(er, try r.toInt(i32)); |
| 1594 | } | 1594 | } |
| 1595 | | 1595 | |
| 1596 | test "div floor single-single +/-" { | 1596 | test "div floor single-single +/-" { |
| ... | @@ -1613,8 +1613,8 @@ test "div floor single-single +/-" { | ... | @@ -1613,8 +1613,8 @@ test "div floor single-single +/-" { |
| 1613 | const eq = -2; | 1613 | const eq = -2; |
| 1614 | const er = -1; | 1614 | const er = -1; |
| 1615 | | 1615 | |
| 1616 | try testing.expect((try q.toInt(i32)) == eq); | 1616 | try testing.expectEqual(eq, try q.toInt(i32)); |
| 1617 | try testing.expect((try r.toInt(i32)) == er); | 1617 | try testing.expectEqual(er, try r.toInt(i32)); |
| 1618 | } | 1618 | } |
| 1619 | | 1619 | |
| 1620 | test "div floor single-single -/-" { | 1620 | test "div floor single-single -/-" { |
| ... | @@ -1637,8 +1637,8 @@ test "div floor single-single -/-" { | ... | @@ -1637,8 +1637,8 @@ test "div floor single-single -/-" { |
| 1637 | const eq = 1; | 1637 | const eq = 1; |
| 1638 | const er = -2; | 1638 | const er = -2; |
| 1639 | | 1639 | |
| 1640 | try testing.expect((try q.toInt(i32)) == eq); | 1640 | try testing.expectEqual(eq, try q.toInt(i32)); |
| 1641 | try testing.expect((try r.toInt(i32)) == er); | 1641 | try testing.expectEqual(er, try r.toInt(i32)); |
| 1642 | } | 1642 | } |
| 1643 | | 1643 | |
| 1644 | test "div floor no remainder negative quotient" { | 1644 | test "div floor no remainder negative quotient" { |
| ... | @@ -1656,8 +1656,8 @@ test "div floor no remainder negative quotient" { | ... | @@ -1656,8 +1656,8 @@ test "div floor no remainder negative quotient" { |
| 1656 | defer r.deinit(); | 1656 | defer r.deinit(); |
| 1657 | try Managed.divFloor(&q, &r, &a, &b); | 1657 | try Managed.divFloor(&q, &r, &a, &b); |
| 1658 | | 1658 | |
| 1659 | try testing.expect((try q.toInt(i32)) == -0x80000000); | 1659 | try testing.expectEqual(-0x80000000, try q.toInt(i32)); |
| 1660 | try testing.expect((try r.toInt(i32)) == 0); | 1660 | try testing.expectEqual(0, try r.toInt(i32)); |
| 1661 | } | 1661 | } |
| 1662 | | 1662 | |
| 1663 | test "div floor negative close to zero" { | 1663 | test "div floor negative close to zero" { |
| ... | @@ -1675,8 +1675,8 @@ test "div floor negative close to zero" { | ... | @@ -1675,8 +1675,8 @@ test "div floor negative close to zero" { |
| 1675 | defer r.deinit(); | 1675 | defer r.deinit(); |
| 1676 | try Managed.divFloor(&q, &r, &a, &b); | 1676 | try Managed.divFloor(&q, &r, &a, &b); |
| 1677 | | 1677 | |
| 1678 | try testing.expect((try q.toInt(i32)) == -1); | 1678 | try testing.expectEqual(-1, try q.toInt(i32)); |
| 1679 | try testing.expect((try r.toInt(i32)) == 10); | 1679 | try testing.expectEqual(10, try r.toInt(i32)); |
| 1680 | } | 1680 | } |
| 1681 | | 1681 | |
| 1682 | test "div floor positive close to zero" { | 1682 | test "div floor positive close to zero" { |
| ... | @@ -1694,8 +1694,8 @@ test "div floor positive close to zero" { | ... | @@ -1694,8 +1694,8 @@ test "div floor positive close to zero" { |
| 1694 | defer r.deinit(); | 1694 | defer r.deinit(); |
| 1695 | try Managed.divFloor(&q, &r, &a, &b); | 1695 | try Managed.divFloor(&q, &r, &a, &b); |
| 1696 | | 1696 | |
| 1697 | try testing.expect((try q.toInt(i32)) == 0); | 1697 | try testing.expectEqual(0, try q.toInt(i32)); |
| 1698 | try testing.expect((try r.toInt(i32)) == 10); | 1698 | try testing.expectEqual(10, try r.toInt(i32)); |
| 1699 | } | 1699 | } |
| 1700 | | 1700 | |
| 1701 | test "div multi-multi with rem" { | 1701 | test "div multi-multi with rem" { |
| ... | @@ -1712,8 +1712,8 @@ test "div multi-multi with rem" { | ... | @@ -1712,8 +1712,8 @@ test "div multi-multi with rem" { |
| 1712 | defer r.deinit(); | 1712 | defer r.deinit(); |
| 1713 | try Managed.divTrunc(&q, &r, &a, &b); | 1713 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1714 | | 1714 | |
| 1715 | try testing.expect((try q.toInt(u128)) == 0xe38f38e39161aaabd03f0f1b); | 1715 | try testing.expectEqual(0xe38f38e39161aaabd03f0f1b, try q.toInt(u128)); |
| 1716 | try testing.expect((try r.toInt(u128)) == 0x28de0acacd806823638); | 1716 | try testing.expectEqual(0x28de0acacd806823638, try r.toInt(u128)); |
| 1717 | } | 1717 | } |
| 1718 | | 1718 | |
| 1719 | test "div multi-multi no rem" { | 1719 | test "div multi-multi no rem" { |
| ... | @@ -1730,8 +1730,8 @@ test "div multi-multi no rem" { | ... | @@ -1730,8 +1730,8 @@ test "div multi-multi no rem" { |
| 1730 | defer r.deinit(); | 1730 | defer r.deinit(); |
| 1731 | try Managed.divTrunc(&q, &r, &a, &b); | 1731 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1732 | | 1732 | |
| 1733 | try testing.expect((try q.toInt(u128)) == 0xe38f38e39161aaabd03f0f1b); | 1733 | try testing.expectEqual(0xe38f38e39161aaabd03f0f1b, try q.toInt(u128)); |
| 1734 | try testing.expect((try r.toInt(u128)) == 0); | 1734 | try testing.expectEqual(0, try r.toInt(u128)); |
| 1735 | } | 1735 | } |
| 1736 | | 1736 | |
| 1737 | test "div multi-multi (2 branch)" { | 1737 | test "div multi-multi (2 branch)" { |
| ... | @@ -1748,8 +1748,8 @@ test "div multi-multi (2 branch)" { | ... | @@ -1748,8 +1748,8 @@ test "div multi-multi (2 branch)" { |
| 1748 | defer r.deinit(); | 1748 | defer r.deinit(); |
| 1749 | try Managed.divTrunc(&q, &r, &a, &b); | 1749 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1750 | | 1750 | |
| 1751 | try testing.expect((try q.toInt(u128)) == 0x10000000000000000); | 1751 | try testing.expectEqual(0x10000000000000000, try q.toInt(u128)); |
| 1752 | try testing.expect((try r.toInt(u128)) == 0x44444443444444431111111111111111); | 1752 | try testing.expectEqual(0x44444443444444431111111111111111, try r.toInt(u128)); |
| 1753 | } | 1753 | } |
| 1754 | | 1754 | |
| 1755 | test "div multi-multi (3.1/3.3 branch)" { | 1755 | test "div multi-multi (3.1/3.3 branch)" { |
| ... | @@ -1766,8 +1766,8 @@ test "div multi-multi (3.1/3.3 branch)" { | ... | @@ -1766,8 +1766,8 @@ test "div multi-multi (3.1/3.3 branch)" { |
| 1766 | defer r.deinit(); | 1766 | defer r.deinit(); |
| 1767 | try Managed.divTrunc(&q, &r, &a, &b); | 1767 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1768 | | 1768 | |
| 1769 | try testing.expect((try q.toInt(u128)) == 0xfffffffffffffffffff); | 1769 | try testing.expectEqual(0xfffffffffffffffffff, try q.toInt(u128)); |
| 1770 | try testing.expect((try r.toInt(u256)) == 0x1111111111111111111110b12222222222222222282); | 1770 | try testing.expectEqual(0x1111111111111111111110b12222222222222222282, try r.toInt(u256)); |
| 1771 | } | 1771 | } |
| 1772 | | 1772 | |
| 1773 | test "div multi-single zero-limb trailing" { | 1773 | test "div multi-single zero-limb trailing" { |
| ... | @@ -1804,11 +1804,11 @@ test "div multi-multi zero-limb trailing (with rem)" { | ... | @@ -1804,11 +1804,11 @@ test "div multi-multi zero-limb trailing (with rem)" { |
| 1804 | defer r.deinit(); | 1804 | defer r.deinit(); |
| 1805 | try Managed.divTrunc(&q, &r, &a, &b); | 1805 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1806 | | 1806 | |
| 1807 | try testing.expect((try q.toInt(u128)) == 0x10000000000000000); | 1807 | try testing.expectEqual(0x10000000000000000, try q.toInt(u128)); |
| 1808 | | 1808 | |
| 1809 | const rs = try r.toString(testing.allocator, 16, .lower); | 1809 | const rs = try r.toString(testing.allocator, 16, .lower); |
| 1810 | defer testing.allocator.free(rs); | 1810 | defer testing.allocator.free(rs); |
| 1811 | try testing.expect(std.mem.eql(u8, rs, "4444444344444443111111111111111100000000000000000000000000000000")); | 1811 | try testing.expectEqualStrings("4444444344444443111111111111111100000000000000000000000000000000", rs); |
| 1812 | } | 1812 | } |
| 1813 | | 1813 | |
| 1814 | test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" { | 1814 | test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" { |
| ... | @@ -1825,11 +1825,11 @@ test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count | ... | @@ -1825,11 +1825,11 @@ test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count |
| 1825 | defer r.deinit(); | 1825 | defer r.deinit(); |
| 1826 | try Managed.divTrunc(&q, &r, &a, &b); | 1826 | try Managed.divTrunc(&q, &r, &a, &b); |
| 1827 | | 1827 | |
| 1828 | try testing.expect((try q.toInt(u128)) == 0x1); | 1828 | try testing.expectEqual(0x1, try q.toInt(u128)); |
| 1829 | | 1829 | |
| 1830 | const rs = try r.toString(testing.allocator, 16, .lower); | 1830 | const rs = try r.toString(testing.allocator, 16, .lower); |
| 1831 | defer testing.allocator.free(rs); | 1831 | defer testing.allocator.free(rs); |
| 1832 | try testing.expect(std.mem.eql(u8, rs, "444444434444444311111111111111110000000000000000")); | 1832 | try testing.expectEqualStrings("444444434444444311111111111111110000000000000000", rs); |
| 1833 | } | 1833 | } |
| 1834 | | 1834 | |
| 1835 | test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" { | 1835 | test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" { |
| ... | @@ -1848,11 +1848,11 @@ test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count | ... | @@ -1848,11 +1848,11 @@ test "div multi-multi zero-limb trailing (with rem) and dividend zero-limb count |
| 1848 | | 1848 | |
| 1849 | const qs = try q.toString(testing.allocator, 16, .lower); | 1849 | const qs = try q.toString(testing.allocator, 16, .lower); |
| 1850 | defer testing.allocator.free(qs); | 1850 | defer testing.allocator.free(qs); |
| 1851 | try testing.expect(std.mem.eql(u8, qs, "10000000000000000820820803105186f")); | 1851 | try testing.expectEqualStrings("10000000000000000820820803105186f", qs); |
| 1852 | | 1852 | |
| 1853 | const rs = try r.toString(testing.allocator, 16, .lower); | 1853 | const rs = try r.toString(testing.allocator, 16, .lower); |
| 1854 | defer testing.allocator.free(rs); | 1854 | defer testing.allocator.free(rs); |
| 1855 | try testing.expect(std.mem.eql(u8, rs, "4e11f2baa5896a321d463b543d0104e30000000000000000")); | 1855 | try testing.expectEqualStrings("4e11f2baa5896a321d463b543d0104e30000000000000000", rs); |
| 1856 | } | 1856 | } |
| 1857 | | 1857 | |
| 1858 | test "div multi-multi fuzz case #1" { | 1858 | test "div multi-multi fuzz case #1" { |
| ... | @@ -1872,11 +1872,11 @@ test "div multi-multi fuzz case #1" { | ... | @@ -1872,11 +1872,11 @@ test "div multi-multi fuzz case #1" { |
| 1872 | | 1872 | |
| 1873 | const qs = try q.toString(testing.allocator, 16, .lower); | 1873 | const qs = try q.toString(testing.allocator, 16, .lower); |
| 1874 | defer testing.allocator.free(qs); | 1874 | defer testing.allocator.free(qs); |
| 1875 | try testing.expect(std.mem.eql(u8, qs, "3ffffffffffffffffffffffffffff0000000000000000000000000000000000001ffffffffffffffffffffffffffff7fffffffe000000000000000000000000000180000000000000000000003fffffbfffffffdfffffffffffffeffff800000100101000000100000000020003fffffdfbfffffe3ffffffffffffeffff7fffc00800a100000017ffe000002000400007efbfff7fe9f00000037ffff3fff7fffa004006100000009ffe00000190038200bf7d2ff7fefe80400060000f7d7f8fbf9401fe38e0403ffc0bdffffa51102c300d7be5ef9df4e5060007b0127ad3fa69f97d0f820b6605ff617ddf7f32ad7a05c0d03f2e7bc78a6000e087a8bbcdc59e07a5a079128a7861f553ddebed7e8e56701756f9ead39b48cd1b0831889ea6ec1fddf643d0565b075ff07e6caea4e2854ec9227fd635ed60a2f5eef2893052ffd54718fa08604acbf6a15e78a467c4a3c53c0278af06c4416573f925491b195e8fd79302cb1aaf7caf4ecfc9aec1254cc969786363ac729f914c6ddcc26738d6b0facd54eba026580aba2eb6482a088b0d224a8852420b91ec1")); | 1875 | try testing.expectEqualStrings("3ffffffffffffffffffffffffffff0000000000000000000000000000000000001ffffffffffffffffffffffffffff7fffffffe000000000000000000000000000180000000000000000000003fffffbfffffffdfffffffffffffeffff800000100101000000100000000020003fffffdfbfffffe3ffffffffffffeffff7fffc00800a100000017ffe000002000400007efbfff7fe9f00000037ffff3fff7fffa004006100000009ffe00000190038200bf7d2ff7fefe80400060000f7d7f8fbf9401fe38e0403ffc0bdffffa51102c300d7be5ef9df4e5060007b0127ad3fa69f97d0f820b6605ff617ddf7f32ad7a05c0d03f2e7bc78a6000e087a8bbcdc59e07a5a079128a7861f553ddebed7e8e56701756f9ead39b48cd1b0831889ea6ec1fddf643d0565b075ff07e6caea4e2854ec9227fd635ed60a2f5eef2893052ffd54718fa08604acbf6a15e78a467c4a3c53c0278af06c4416573f925491b195e8fd79302cb1aaf7caf4ecfc9aec1254cc969786363ac729f914c6ddcc26738d6b0facd54eba026580aba2eb6482a088b0d224a8852420b91ec1", qs); |
| 1876 | | 1876 | |
| 1877 | const rs = try r.toString(testing.allocator, 16, .lower); | 1877 | const rs = try r.toString(testing.allocator, 16, .lower); |
| 1878 | defer testing.allocator.free(rs); | 1878 | defer testing.allocator.free(rs); |
| 1879 | try testing.expect(std.mem.eql(u8, rs, "310d1d4c414426b4836c2635bad1df3a424e50cbdd167ffccb4dfff57d36b4aae0d6ca0910698220171a0f3373c1060a046c2812f0027e321f72979daa5e7973214170d49e885de0c0ecc167837d44502430674a82522e5df6a0759548052420b91ec1")); | 1879 | try testing.expectEqualStrings("310d1d4c414426b4836c2635bad1df3a424e50cbdd167ffccb4dfff57d36b4aae0d6ca0910698220171a0f3373c1060a046c2812f0027e321f72979daa5e7973214170d49e885de0c0ecc167837d44502430674a82522e5df6a0759548052420b91ec1", rs); |
| 1880 | } | 1880 | } |
| 1881 | | 1881 | |
| 1882 | test "div multi-multi fuzz case #2" { | 1882 | test "div multi-multi fuzz case #2" { |
| ... | @@ -1896,11 +1896,11 @@ test "div multi-multi fuzz case #2" { | ... | @@ -1896,11 +1896,11 @@ test "div multi-multi fuzz case #2" { |
| 1896 | | 1896 | |
| 1897 | const qs = try q.toString(testing.allocator, 16, .lower); | 1897 | const qs = try q.toString(testing.allocator, 16, .lower); |
| 1898 | defer testing.allocator.free(qs); | 1898 | defer testing.allocator.free(qs); |
| 1899 | try testing.expect(std.mem.eql(u8, qs, "40100400fe3f8fe3f8fe3f8fe3f8fe3f8fe4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f91e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4992649926499264991e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4792e4b92e4b92e4b92e4b92a4a92a4a92a4")); | 1899 | try testing.expectEqualStrings("40100400fe3f8fe3f8fe3f8fe3f8fe3f8fe4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f93e4f91e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4992649926499264991e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4791e4792e4b92e4b92e4b92e4b92a4a92a4a92a4", qs); |
| 1900 | | 1900 | |
| 1901 | const rs = try r.toString(testing.allocator, 16, .lower); | 1901 | const rs = try r.toString(testing.allocator, 16, .lower); |
| 1902 | defer testing.allocator.free(rs); | 1902 | defer testing.allocator.free(rs); |
| 1903 | try testing.expect(std.mem.eql(u8, rs, "a900000000000000000000000000000000000000000000000000")); | 1903 | try testing.expectEqualStrings("a900000000000000000000000000000000000000000000000000", rs); |
| 1904 | } | 1904 | } |
| 1905 | | 1905 | |
| 1906 | test "truncate single unsigned" { | 1906 | test "truncate single unsigned" { |
| ... | @@ -1909,7 +1909,7 @@ test "truncate single unsigned" { | ... | @@ -1909,7 +1909,7 @@ test "truncate single unsigned" { |
| 1909 | | 1909 | |
| 1910 | try a.truncate(&a, .unsigned, 17); | 1910 | try a.truncate(&a, .unsigned, 17); |
| 1911 | | 1911 | |
| 1912 | try testing.expect((try a.toInt(u17)) == maxInt(u17)); | 1912 | try testing.expectEqual(maxInt(u17), try a.toInt(u17)); |
| 1913 | } | 1913 | } |
| 1914 | | 1914 | |
| 1915 | test "truncate single signed" { | 1915 | test "truncate single signed" { |
| ... | @@ -1918,7 +1918,7 @@ test "truncate single signed" { | ... | @@ -1918,7 +1918,7 @@ test "truncate single signed" { |
| 1918 | | 1918 | |
| 1919 | try a.truncate(&a, .signed, 17); | 1919 | try a.truncate(&a, .signed, 17); |
| 1920 | | 1920 | |
| 1921 | try testing.expect((try a.toInt(i17)) == minInt(i17)); | 1921 | try testing.expectEqual(minInt(i17), try a.toInt(i17)); |
| 1922 | } | 1922 | } |
| 1923 | | 1923 | |
| 1924 | test "truncate multi to single unsigned" { | 1924 | test "truncate multi to single unsigned" { |
| ... | @@ -1927,7 +1927,7 @@ test "truncate multi to single unsigned" { | ... | @@ -1927,7 +1927,7 @@ test "truncate multi to single unsigned" { |
| 1927 | | 1927 | |
| 1928 | try a.truncate(&a, .unsigned, 27); | 1928 | try a.truncate(&a, .unsigned, 27); |
| 1929 | | 1929 | |
| 1930 | try testing.expect((try a.toInt(u27)) == 0x2BC_DEF0); | 1930 | try testing.expectEqual(0x2BC_DEF0, try a.toInt(u27)); |
| 1931 | } | 1931 | } |
| 1932 | | 1932 | |
| 1933 | test "truncate multi to single signed" { | 1933 | test "truncate multi to single signed" { |
| ... | @@ -1936,7 +1936,7 @@ test "truncate multi to single signed" { | ... | @@ -1936,7 +1936,7 @@ test "truncate multi to single signed" { |
| 1936 | | 1936 | |
| 1937 | try a.truncate(&a, .signed, @bitSizeOf(i11)); | 1937 | try a.truncate(&a, .signed, @bitSizeOf(i11)); |
| 1938 | | 1938 | |
| 1939 | try testing.expect((try a.toInt(i11)) == minInt(i11)); | 1939 | try testing.expectEqual(minInt(i11), try a.toInt(i11)); |
| 1940 | } | 1940 | } |
| 1941 | | 1941 | |
| 1942 | test "truncate multi to multi unsigned" { | 1942 | test "truncate multi to multi unsigned" { |
| ... | @@ -1948,7 +1948,7 @@ test "truncate multi to multi unsigned" { | ... | @@ -1948,7 +1948,7 @@ test "truncate multi to multi unsigned" { |
| 1948 | | 1948 | |
| 1949 | try a.truncate(&a, .unsigned, bits - 1); | 1949 | try a.truncate(&a, .unsigned, bits - 1); |
| 1950 | | 1950 | |
| 1951 | try testing.expect((try a.toInt(Int)) == maxInt(Int)); | 1951 | try testing.expectEqual(maxInt(Int), try a.toInt(Int)); |
| 1952 | } | 1952 | } |
| 1953 | | 1953 | |
| 1954 | test "truncate multi to multi signed" { | 1954 | test "truncate multi to multi signed" { |
| ... | @@ -1957,7 +1957,7 @@ test "truncate multi to multi signed" { | ... | @@ -1957,7 +1957,7 @@ test "truncate multi to multi signed" { |
| 1957 | | 1957 | |
| 1958 | try a.truncate(&a, .signed, @bitSizeOf(Limb) + 1); | 1958 | try a.truncate(&a, .signed, @bitSizeOf(Limb) + 1); |
| 1959 | | 1959 | |
| 1960 | try testing.expect((try a.toInt(std.meta.Int(.signed, @bitSizeOf(Limb) + 1))) == -1 << @bitSizeOf(Limb)); | 1960 | try testing.expectEqual(-1 << @bitSizeOf(Limb), try a.toInt(std.meta.Int(.signed, @bitSizeOf(Limb) + 1))); |
| 1961 | } | 1961 | } |
| 1962 | | 1962 | |
| 1963 | test "truncate negative multi to single" { | 1963 | test "truncate negative multi to single" { |
| ... | @@ -1966,7 +1966,7 @@ test "truncate negative multi to single" { | ... | @@ -1966,7 +1966,7 @@ test "truncate negative multi to single" { |
| 1966 | | 1966 | |
| 1967 | try a.truncate(&a, .signed, @bitSizeOf(i17)); | 1967 | try a.truncate(&a, .signed, @bitSizeOf(i17)); |
| 1968 | | 1968 | |
| 1969 | try testing.expect((try a.toInt(i17)) == 0); | 1969 | try testing.expectEqual(0, try a.toInt(i17)); |
| 1970 | } | 1970 | } |
| 1971 | | 1971 | |
| 1972 | test "truncate multi unsigned many" { | 1972 | test "truncate multi unsigned many" { |
| ... | @@ -1978,7 +1978,7 @@ test "truncate multi unsigned many" { | ... | @@ -1978,7 +1978,7 @@ test "truncate multi unsigned many" { |
| 1978 | defer b.deinit(); | 1978 | defer b.deinit(); |
| 1979 | try b.truncate(&a, .signed, @bitSizeOf(i1)); | 1979 | try b.truncate(&a, .signed, @bitSizeOf(i1)); |
| 1980 | | 1980 | |
| 1981 | try testing.expect((try b.toInt(i1)) == 0); | 1981 | try testing.expectEqual(0, try b.toInt(i1)); |
| 1982 | } | 1982 | } |
| 1983 | | 1983 | |
| 1984 | test "truncate to mutable with fewer limbs" { | 1984 | test "truncate to mutable with fewer limbs" { |
| ... | @@ -2067,7 +2067,7 @@ test "saturate single signed positive" { | ... | @@ -2067,7 +2067,7 @@ test "saturate single signed positive" { |
| 2067 | | 2067 | |
| 2068 | try a.saturate(&a, .signed, 17); | 2068 | try a.saturate(&a, .signed, 17); |
| 2069 | | 2069 | |
| 2070 | try testing.expect((try a.toInt(i17)) == maxInt(i17)); | 2070 | try testing.expectEqual(maxInt(i17), try a.toInt(i17)); |
| 2071 | } | 2071 | } |
| 2072 | | 2072 | |
| 2073 | test "saturate single signed negative" { | 2073 | test "saturate single signed negative" { |
| ... | @@ -2076,7 +2076,7 @@ test "saturate single signed negative" { | ... | @@ -2076,7 +2076,7 @@ test "saturate single signed negative" { |
| 2076 | | 2076 | |
| 2077 | try a.saturate(&a, .signed, 17); | 2077 | try a.saturate(&a, .signed, 17); |
| 2078 | | 2078 | |
| 2079 | try testing.expect((try a.toInt(i17)) == minInt(i17)); | 2079 | try testing.expectEqual(minInt(i17), try a.toInt(i17)); |
| 2080 | } | 2080 | } |
| 2081 | | 2081 | |
| 2082 | test "saturate single signed" { | 2082 | test "saturate single signed" { |
| ... | @@ -2085,7 +2085,7 @@ test "saturate single signed" { | ... | @@ -2085,7 +2085,7 @@ test "saturate single signed" { |
| 2085 | | 2085 | |
| 2086 | try a.saturate(&a, .signed, 17); | 2086 | try a.saturate(&a, .signed, 17); |
| 2087 | | 2087 | |
| 2088 | try testing.expect((try a.toInt(i17)) == maxInt(i17) - 1); | 2088 | try testing.expectEqual(maxInt(i17) - 1, try a.toInt(i17)); |
| 2089 | } | 2089 | } |
| 2090 | | 2090 | |
| 2091 | test "saturate multi signed" { | 2091 | test "saturate multi signed" { |
| ... | @@ -2094,7 +2094,7 @@ test "saturate multi signed" { | ... | @@ -2094,7 +2094,7 @@ test "saturate multi signed" { |
| 2094 | | 2094 | |
| 2095 | try a.saturate(&a, .signed, @bitSizeOf(SignedDoubleLimb)); | 2095 | try a.saturate(&a, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 2096 | | 2096 | |
| 2097 | try testing.expect((try a.toInt(SignedDoubleLimb)) == maxInt(SignedDoubleLimb)); | 2097 | try testing.expectEqual(maxInt(SignedDoubleLimb), try a.toInt(SignedDoubleLimb)); |
| 2098 | } | 2098 | } |
| 2099 | | 2099 | |
| 2100 | test "saturate single unsigned" { | 2100 | test "saturate single unsigned" { |
| ... | @@ -2103,7 +2103,7 @@ test "saturate single unsigned" { | ... | @@ -2103,7 +2103,7 @@ test "saturate single unsigned" { |
| 2103 | | 2103 | |
| 2104 | try a.saturate(&a, .unsigned, 23); | 2104 | try a.saturate(&a, .unsigned, 23); |
| 2105 | | 2105 | |
| 2106 | try testing.expect((try a.toInt(u23)) == maxInt(u23)); | 2106 | try testing.expectEqual(maxInt(u23), try a.toInt(u23)); |
| 2107 | } | 2107 | } |
| 2108 | | 2108 | |
| 2109 | test "saturate multi unsigned zero" { | 2109 | test "saturate multi unsigned zero" { |
| ... | @@ -2121,7 +2121,7 @@ test "saturate multi unsigned" { | ... | @@ -2121,7 +2121,7 @@ test "saturate multi unsigned" { |
| 2121 | | 2121 | |
| 2122 | try a.saturate(&a, .unsigned, @bitSizeOf(DoubleLimb)); | 2122 | try a.saturate(&a, .unsigned, @bitSizeOf(DoubleLimb)); |
| 2123 | | 2123 | |
| 2124 | try testing.expect((try a.toInt(DoubleLimb)) == maxInt(DoubleLimb)); | 2124 | try testing.expectEqual(maxInt(DoubleLimb), try a.toInt(DoubleLimb)); |
| 2125 | } | 2125 | } |
| 2126 | | 2126 | |
| 2127 | test "shift-right single" { | 2127 | test "shift-right single" { |
| ... | @@ -2129,7 +2129,7 @@ test "shift-right single" { | ... | @@ -2129,7 +2129,7 @@ test "shift-right single" { |
| 2129 | defer a.deinit(); | 2129 | defer a.deinit(); |
| 2130 | try a.shiftRight(&a, 16); | 2130 | try a.shiftRight(&a, 16); |
| 2131 | | 2131 | |
| 2132 | try testing.expect((try a.toInt(u32)) == 0xffff); | 2132 | try testing.expectEqual(0xffff, try a.toInt(u32)); |
| 2133 | } | 2133 | } |
| 2134 | | 2134 | |
| 2135 | test "shift-right multi" { | 2135 | test "shift-right multi" { |
| ... | @@ -2137,7 +2137,7 @@ test "shift-right multi" { | ... | @@ -2137,7 +2137,7 @@ test "shift-right multi" { |
| 2137 | defer a.deinit(); | 2137 | defer a.deinit(); |
| 2138 | try a.shiftRight(&a, 67); | 2138 | try a.shiftRight(&a, 67); |
| 2139 | | 2139 | |
| 2140 | try testing.expect((try a.toInt(u64)) == 0x1fffe0001dddc222); | 2140 | try testing.expectEqual(0x1fffe0001dddc222, try a.toInt(u64)); |
| 2141 | | 2141 | |
| 2142 | try a.set(0xffff0000eeee1111dddd2222cccc3333); | 2142 | try a.set(0xffff0000eeee1111dddd2222cccc3333); |
| 2143 | try a.shiftRight(&a, 63); | 2143 | try a.shiftRight(&a, 63); |
| ... | @@ -2154,8 +2154,8 @@ test "shift-right multi" { | ... | @@ -2154,8 +2154,8 @@ test "shift-right multi" { |
| 2154 | ); | 2154 | ); |
| 2155 | defer testing.allocator.free(string); | 2155 | defer testing.allocator.free(string); |
| 2156 | try std.testing.expectEqualStrings( | 2156 | try std.testing.expectEqualStrings( |
| 2157 | string, | | |
| 2158 | "ffff0000eeee1111dddd2222cccc3333", | 2157 | "ffff0000eeee1111dddd2222cccc3333", |
| | 2158 | string, |
| 2159 | ); | 2159 | ); |
| 2160 | } | 2160 | } |
| 2161 | | 2161 | |
| ... | @@ -2164,7 +2164,7 @@ test "shift-left single" { | ... | @@ -2164,7 +2164,7 @@ test "shift-left single" { |
| 2164 | defer a.deinit(); | 2164 | defer a.deinit(); |
| 2165 | try a.shiftLeft(&a, 16); | 2165 | try a.shiftLeft(&a, 16); |
| 2166 | | 2166 | |
| 2167 | try testing.expect((try a.toInt(u64)) == 0xffff0000); | 2167 | try testing.expectEqual(0xffff0000, try a.toInt(u64)); |
| 2168 | } | 2168 | } |
| 2169 | | 2169 | |
| 2170 | test "shift-left multi" { | 2170 | test "shift-left multi" { |
| ... | @@ -2172,7 +2172,7 @@ test "shift-left multi" { | ... | @@ -2172,7 +2172,7 @@ test "shift-left multi" { |
| 2172 | defer a.deinit(); | 2172 | defer a.deinit(); |
| 2173 | try a.shiftLeft(&a, 67); | 2173 | try a.shiftLeft(&a, 67); |
| 2174 | | 2174 | |
| 2175 | try testing.expect((try a.toInt(u128)) == 0xffff0000eeee11100000000000000000); | 2175 | try testing.expectEqual(0xffff0000eeee11100000000000000000, try a.toInt(u128)); |
| 2176 | } | 2176 | } |
| 2177 | | 2177 | |
| 2178 | test "shift-right negative" { | 2178 | test "shift-right negative" { |
| ... | @@ -2182,43 +2182,43 @@ test "shift-right negative" { | ... | @@ -2182,43 +2182,43 @@ test "shift-right negative" { |
| 2182 | var arg = try Managed.initSet(testing.allocator, -20); | 2182 | var arg = try Managed.initSet(testing.allocator, -20); |
| 2183 | defer arg.deinit(); | 2183 | defer arg.deinit(); |
| 2184 | try a.shiftRight(&arg, 2); | 2184 | try a.shiftRight(&arg, 2); |
| 2185 | try testing.expect((try a.toInt(i32)) == -5); // -20 >> 2 == -5 | 2185 | try testing.expectEqual(-5, try a.toInt(i32)); // -20 >> 2 == -5 |
| 2186 | | 2186 | |
| 2187 | var arg2 = try Managed.initSet(testing.allocator, -5); | 2187 | var arg2 = try Managed.initSet(testing.allocator, -5); |
| 2188 | defer arg2.deinit(); | 2188 | defer arg2.deinit(); |
| 2189 | try a.shiftRight(&arg2, 10); | 2189 | try a.shiftRight(&arg2, 10); |
| 2190 | try testing.expect((try a.toInt(i32)) == -1); // -5 >> 10 == -1 | 2190 | try testing.expectEqual(-1, try a.toInt(i32)); // -5 >> 10 == -1 |
| 2191 | | 2191 | |
| 2192 | var arg3 = try Managed.initSet(testing.allocator, -10); | 2192 | var arg3 = try Managed.initSet(testing.allocator, -10); |
| 2193 | defer arg3.deinit(); | 2193 | defer arg3.deinit(); |
| 2194 | try a.shiftRight(&arg3, 1232); | 2194 | try a.shiftRight(&arg3, 1232); |
| 2195 | try testing.expect((try a.toInt(i32)) == -1); // -10 >> 1232 == -1 | 2195 | try testing.expectEqual(-1, try a.toInt(i32)); // -10 >> 1232 == -1 |
| 2196 | | 2196 | |
| 2197 | var arg4 = try Managed.initSet(testing.allocator, -5); | 2197 | var arg4 = try Managed.initSet(testing.allocator, -5); |
| 2198 | defer arg4.deinit(); | 2198 | defer arg4.deinit(); |
| 2199 | try a.shiftRight(&arg4, 2); | 2199 | try a.shiftRight(&arg4, 2); |
| 2200 | try testing.expect(try a.toInt(i32) == -2); // -5 >> 2 == -2 | 2200 | try testing.expectEqual(-2, try a.toInt(i32)); // -5 >> 2 == -2 |
| 2201 | | 2201 | |
| 2202 | var arg5 = try Managed.initSet(testing.allocator, -0xffff0000eeee1111dddd2222cccc3333); | 2202 | var arg5 = try Managed.initSet(testing.allocator, -0xffff0000eeee1111dddd2222cccc3333); |
| 2203 | defer arg5.deinit(); | 2203 | defer arg5.deinit(); |
| 2204 | try a.shiftRight(&arg5, 67); | 2204 | try a.shiftRight(&arg5, 67); |
| 2205 | try testing.expect(try a.toInt(i64) == -0x1fffe0001dddc223); | 2205 | try testing.expectEqual(-0x1fffe0001dddc223, try a.toInt(i64)); |
| 2206 | | 2206 | |
| 2207 | var arg6 = try Managed.initSet(testing.allocator, -0x1ffffffffffffffff); | 2207 | var arg6 = try Managed.initSet(testing.allocator, -0x1ffffffffffffffff); |
| 2208 | defer arg6.deinit(); | 2208 | defer arg6.deinit(); |
| 2209 | try a.shiftRight(&arg6, 1); | 2209 | try a.shiftRight(&arg6, 1); |
| 2210 | try a.shiftRight(&a, 1); | 2210 | try a.shiftRight(&a, 1); |
| 2211 | a.setSign(true); | 2211 | a.setSign(true); |
| 2212 | try testing.expect(try a.toInt(u64) == 0x8000000000000000); | 2212 | try testing.expectEqual(0x8000000000000000, try a.toInt(u64)); |
| 2213 | | 2213 | |
| 2214 | var arg7 = try Managed.initSet(testing.allocator, -32767); | 2214 | var arg7 = try Managed.initSet(testing.allocator, -32767); |
| 2215 | defer arg7.deinit(); | 2215 | defer arg7.deinit(); |
| 2216 | a.setSign(false); | 2216 | a.setSign(false); |
| 2217 | try a.shiftRight(&arg7, 4); | 2217 | try a.shiftRight(&arg7, 4); |
| 2218 | try testing.expect(try a.toInt(i16) == -2048); | 2218 | try testing.expectEqual(-2048, try a.toInt(i16)); |
| 2219 | a.setSign(true); | 2219 | a.setSign(true); |
| 2220 | try a.shiftRight(&arg7, 4); | 2220 | try a.shiftRight(&arg7, 4); |
| 2221 | try testing.expect(try a.toInt(i16) == -2048); | 2221 | try testing.expectEqual(-2048, try a.toInt(i16)); |
| 2222 | | 2222 | |
| 2223 | var arg8_limbs: [1]Limb = undefined; | 2223 | var arg8_limbs: [1]Limb = undefined; |
| 2224 | var arg8: Mutable = .{ | 2224 | var arg8: Mutable = .{ |
| ... | @@ -2235,7 +2235,7 @@ test "sat shift-left simple unsigned" { | ... | @@ -2235,7 +2235,7 @@ test "sat shift-left simple unsigned" { |
| 2235 | defer a.deinit(); | 2235 | defer a.deinit(); |
| 2236 | try a.shiftLeftSat(&a, 16, .unsigned, 21); | 2236 | try a.shiftLeftSat(&a, 16, .unsigned, 21); |
| 2237 | | 2237 | |
| 2238 | try testing.expect((try a.toInt(u64)) == 0x1fffff); | 2238 | try testing.expectEqual(0x1fffff, try a.toInt(u64)); |
| 2239 | } | 2239 | } |
| 2240 | | 2240 | |
| 2241 | test "sat shift-left simple unsigned no sat" { | 2241 | test "sat shift-left simple unsigned no sat" { |
| ... | @@ -2243,7 +2243,7 @@ test "sat shift-left simple unsigned no sat" { | ... | @@ -2243,7 +2243,7 @@ test "sat shift-left simple unsigned no sat" { |
| 2243 | defer a.deinit(); | 2243 | defer a.deinit(); |
| 2244 | try a.shiftLeftSat(&a, 16, .unsigned, 21); | 2244 | try a.shiftLeftSat(&a, 16, .unsigned, 21); |
| 2245 | | 2245 | |
| 2246 | try testing.expect((try a.toInt(u64)) == 0x10000); | 2246 | try testing.expectEqual(0x10000, try a.toInt(u64)); |
| 2247 | } | 2247 | } |
| 2248 | | 2248 | |
| 2249 | test "sat shift-left multi unsigned" { | 2249 | test "sat shift-left multi unsigned" { |
| ... | @@ -2251,7 +2251,7 @@ test "sat shift-left multi unsigned" { | ... | @@ -2251,7 +2251,7 @@ test "sat shift-left multi unsigned" { |
| 2251 | defer a.deinit(); | 2251 | defer a.deinit(); |
| 2252 | try a.shiftLeftSat(&a, @bitSizeOf(DoubleLimb) - 3, .unsigned, @bitSizeOf(DoubleLimb) - 1); | 2252 | try a.shiftLeftSat(&a, @bitSizeOf(DoubleLimb) - 3, .unsigned, @bitSizeOf(DoubleLimb) - 1); |
| 2253 | | 2253 | |
| 2254 | try testing.expect((try a.toInt(DoubleLimb)) == maxInt(DoubleLimb) >> 1); | 2254 | try testing.expectEqual(maxInt(DoubleLimb) >> 1, try a.toInt(DoubleLimb)); |
| 2255 | } | 2255 | } |
| 2256 | | 2256 | |
| 2257 | test "sat shift-left unsigned shift > bitcount" { | 2257 | test "sat shift-left unsigned shift > bitcount" { |
| ... | @@ -2259,7 +2259,7 @@ test "sat shift-left unsigned shift > bitcount" { | ... | @@ -2259,7 +2259,7 @@ test "sat shift-left unsigned shift > bitcount" { |
| 2259 | defer a.deinit(); | 2259 | defer a.deinit(); |
| 2260 | try a.shiftLeftSat(&a, 10, .unsigned, 10); | 2260 | try a.shiftLeftSat(&a, 10, .unsigned, 10); |
| 2261 | | 2261 | |
| 2262 | try testing.expect((try a.toInt(u10)) == maxInt(u10)); | 2262 | try testing.expectEqual(maxInt(u10), try a.toInt(u10)); |
| 2263 | } | 2263 | } |
| 2264 | | 2264 | |
| 2265 | test "sat shift-left unsigned zero" { | 2265 | test "sat shift-left unsigned zero" { |
| ... | @@ -2267,7 +2267,7 @@ test "sat shift-left unsigned zero" { | ... | @@ -2267,7 +2267,7 @@ test "sat shift-left unsigned zero" { |
| 2267 | defer a.deinit(); | 2267 | defer a.deinit(); |
| 2268 | try a.shiftLeftSat(&a, 1, .unsigned, 0); | 2268 | try a.shiftLeftSat(&a, 1, .unsigned, 0); |
| 2269 | | 2269 | |
| 2270 | try testing.expect((try a.toInt(u64)) == 0); | 2270 | try testing.expectEqual(0, try a.toInt(u64)); |
| 2271 | } | 2271 | } |
| 2272 | | 2272 | |
| 2273 | test "sat shift-left unsigned negative" { | 2273 | test "sat shift-left unsigned negative" { |
| ... | @@ -2275,7 +2275,7 @@ test "sat shift-left unsigned negative" { | ... | @@ -2275,7 +2275,7 @@ test "sat shift-left unsigned negative" { |
| 2275 | defer a.deinit(); | 2275 | defer a.deinit(); |
| 2276 | try a.shiftLeftSat(&a, 0, .unsigned, 0); | 2276 | try a.shiftLeftSat(&a, 0, .unsigned, 0); |
| 2277 | | 2277 | |
| 2278 | try testing.expect((try a.toInt(u64)) == 0); | 2278 | try testing.expectEqual(0, try a.toInt(u64)); |
| 2279 | } | 2279 | } |
| 2280 | | 2280 | |
| 2281 | test "sat shift-left signed simple negative" { | 2281 | test "sat shift-left signed simple negative" { |
| ... | @@ -2283,7 +2283,7 @@ test "sat shift-left signed simple negative" { | ... | @@ -2283,7 +2283,7 @@ test "sat shift-left signed simple negative" { |
| 2283 | defer a.deinit(); | 2283 | defer a.deinit(); |
| 2284 | try a.shiftLeftSat(&a, 3, .signed, 10); | 2284 | try a.shiftLeftSat(&a, 3, .signed, 10); |
| 2285 | | 2285 | |
| 2286 | try testing.expect((try a.toInt(i10)) == minInt(i10)); | 2286 | try testing.expectEqual(minInt(i10), try a.toInt(i10)); |
| 2287 | } | 2287 | } |
| 2288 | | 2288 | |
| 2289 | test "sat shift-left signed simple positive" { | 2289 | test "sat shift-left signed simple positive" { |
| ... | @@ -2291,7 +2291,7 @@ test "sat shift-left signed simple positive" { | ... | @@ -2291,7 +2291,7 @@ test "sat shift-left signed simple positive" { |
| 2291 | defer a.deinit(); | 2291 | defer a.deinit(); |
| 2292 | try a.shiftLeftSat(&a, 3, .signed, 10); | 2292 | try a.shiftLeftSat(&a, 3, .signed, 10); |
| 2293 | | 2293 | |
| 2294 | try testing.expect((try a.toInt(i10)) == maxInt(i10)); | 2294 | try testing.expectEqual(maxInt(i10), try a.toInt(i10)); |
| 2295 | } | 2295 | } |
| 2296 | | 2296 | |
| 2297 | test "sat shift-left signed multi positive" { | 2297 | test "sat shift-left signed multi positive" { |
| ... | @@ -2306,7 +2306,7 @@ test "sat shift-left signed multi positive" { | ... | @@ -2306,7 +2306,7 @@ test "sat shift-left signed multi positive" { |
| 2306 | defer a.deinit(); | 2306 | defer a.deinit(); |
| 2307 | try a.shiftLeftSat(&a, shift, .signed, @bitSizeOf(SignedDoubleLimb)); | 2307 | try a.shiftLeftSat(&a, shift, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 2308 | | 2308 | |
| 2309 | try testing.expect((try a.toInt(SignedDoubleLimb)) == x <<| shift); | 2309 | try testing.expectEqual(x <<| shift, try a.toInt(SignedDoubleLimb)); |
| 2310 | } | 2310 | } |
| 2311 | | 2311 | |
| 2312 | test "sat shift-left signed multi negative" { | 2312 | test "sat shift-left signed multi negative" { |
| ... | @@ -2321,7 +2321,7 @@ test "sat shift-left signed multi negative" { | ... | @@ -2321,7 +2321,7 @@ test "sat shift-left signed multi negative" { |
| 2321 | defer a.deinit(); | 2321 | defer a.deinit(); |
| 2322 | try a.shiftLeftSat(&a, shift, .signed, @bitSizeOf(SignedDoubleLimb)); | 2322 | try a.shiftLeftSat(&a, shift, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 2323 | | 2323 | |
| 2324 | try testing.expect((try a.toInt(SignedDoubleLimb)) == x <<| shift); | 2324 | try testing.expectEqual(x <<| shift, try a.toInt(SignedDoubleLimb)); |
| 2325 | } | 2325 | } |
| 2326 | | 2326 | |
| 2327 | test "bitNotWrap unsigned simple" { | 2327 | test "bitNotWrap unsigned simple" { |
| ... | @@ -2333,7 +2333,7 @@ test "bitNotWrap unsigned simple" { | ... | @@ -2333,7 +2333,7 @@ test "bitNotWrap unsigned simple" { |
| 2333 | | 2333 | |
| 2334 | try a.bitNotWrap(&a, .unsigned, 10); | 2334 | try a.bitNotWrap(&a, .unsigned, 10); |
| 2335 | | 2335 | |
| 2336 | try testing.expect((try a.toInt(u10)) == ~x); | 2336 | try testing.expectEqual(~x, try a.toInt(u10)); |
| 2337 | } | 2337 | } |
| 2338 | | 2338 | |
| 2339 | test "bitNotWrap unsigned multi" { | 2339 | test "bitNotWrap unsigned multi" { |
| ... | @@ -2342,7 +2342,7 @@ test "bitNotWrap unsigned multi" { | ... | @@ -2342,7 +2342,7 @@ test "bitNotWrap unsigned multi" { |
| 2342 | | 2342 | |
| 2343 | try a.bitNotWrap(&a, .unsigned, @bitSizeOf(DoubleLimb)); | 2343 | try a.bitNotWrap(&a, .unsigned, @bitSizeOf(DoubleLimb)); |
| 2344 | | 2344 | |
| 2345 | try testing.expect((try a.toInt(DoubleLimb)) == maxInt(DoubleLimb)); | 2345 | try testing.expectEqual(maxInt(DoubleLimb), try a.toInt(DoubleLimb)); |
| 2346 | } | 2346 | } |
| 2347 | | 2347 | |
| 2348 | test "bitNotWrap signed simple" { | 2348 | test "bitNotWrap signed simple" { |
| ... | @@ -2354,7 +2354,7 @@ test "bitNotWrap signed simple" { | ... | @@ -2354,7 +2354,7 @@ test "bitNotWrap signed simple" { |
| 2354 | | 2354 | |
| 2355 | try a.bitNotWrap(&a, .signed, 11); | 2355 | try a.bitNotWrap(&a, .signed, 11); |
| 2356 | | 2356 | |
| 2357 | try testing.expect((try a.toInt(i11)) == ~x); | 2357 | try testing.expectEqual(~x, try a.toInt(i11)); |
| 2358 | } | 2358 | } |
| 2359 | | 2359 | |
| 2360 | test "bitNotWrap signed multi" { | 2360 | test "bitNotWrap signed multi" { |
| ... | @@ -2363,7 +2363,7 @@ test "bitNotWrap signed multi" { | ... | @@ -2363,7 +2363,7 @@ test "bitNotWrap signed multi" { |
| 2363 | | 2363 | |
| 2364 | try a.bitNotWrap(&a, .signed, @bitSizeOf(SignedDoubleLimb)); | 2364 | try a.bitNotWrap(&a, .signed, @bitSizeOf(SignedDoubleLimb)); |
| 2365 | | 2365 | |
| 2366 | try testing.expect((try a.toInt(SignedDoubleLimb)) == -1); | 2366 | try testing.expectEqual(-1, try a.toInt(SignedDoubleLimb)); |
| 2367 | } | 2367 | } |
| 2368 | | 2368 | |
| 2369 | test "bitNotWrap more than two limbs" { | 2369 | test "bitNotWrap more than two limbs" { |
| ... | @@ -2400,7 +2400,7 @@ test "bitwise and simple" { | ... | @@ -2400,7 +2400,7 @@ test "bitwise and simple" { |
| 2400 | | 2400 | |
| 2401 | try a.bitAnd(&a, &b); | 2401 | try a.bitAnd(&a, &b); |
| 2402 | | 2402 | |
| 2403 | try testing.expect((try a.toInt(u64)) == 0xeeeeeeee00000000); | 2403 | try testing.expectEqual(0xeeeeeeee00000000, try a.toInt(u64)); |
| 2404 | } | 2404 | } |
| 2405 | | 2405 | |
| 2406 | test "bitwise and multi-limb" { | 2406 | test "bitwise and multi-limb" { |
| ... | @@ -2411,7 +2411,7 @@ test "bitwise and multi-limb" { | ... | @@ -2411,7 +2411,7 @@ test "bitwise and multi-limb" { |
| 2411 | | 2411 | |
| 2412 | try a.bitAnd(&a, &b); | 2412 | try a.bitAnd(&a, &b); |
| 2413 | | 2413 | |
| 2414 | try testing.expect((try a.toInt(u128)) == 0); | 2414 | try testing.expectEqual(0, try a.toInt(u128)); |
| 2415 | } | 2415 | } |
| 2416 | | 2416 | |
| 2417 | test "bitwise and negative-positive simple" { | 2417 | test "bitwise and negative-positive simple" { |
| ... | @@ -2422,7 +2422,7 @@ test "bitwise and negative-positive simple" { | ... | @@ -2422,7 +2422,7 @@ test "bitwise and negative-positive simple" { |
| 2422 | | 2422 | |
| 2423 | try a.bitAnd(&a, &b); | 2423 | try a.bitAnd(&a, &b); |
| 2424 | | 2424 | |
| 2425 | try testing.expect((try a.toInt(u64)) == 0x22222222); | 2425 | try testing.expectEqual(0x22222222, try a.toInt(u64)); |
| 2426 | } | 2426 | } |
| 2427 | | 2427 | |
| 2428 | test "bitwise and negative-positive multi-limb" { | 2428 | test "bitwise and negative-positive multi-limb" { |
| ... | @@ -2444,7 +2444,7 @@ test "bitwise and positive-negative simple" { | ... | @@ -2444,7 +2444,7 @@ test "bitwise and positive-negative simple" { |
| 2444 | | 2444 | |
| 2445 | try a.bitAnd(&a, &b); | 2445 | try a.bitAnd(&a, &b); |
| 2446 | | 2446 | |
| 2447 | try testing.expect((try a.toInt(u64)) == 0x1111111111111110); | 2447 | try testing.expectEqual(0x1111111111111110, try a.toInt(u64)); |
| 2448 | } | 2448 | } |
| 2449 | | 2449 | |
| 2450 | test "bitwise and positive-negative multi-limb" { | 2450 | test "bitwise and positive-negative multi-limb" { |
| ... | @@ -2466,7 +2466,7 @@ test "bitwise and negative-negative simple" { | ... | @@ -2466,7 +2466,7 @@ test "bitwise and negative-negative simple" { |
| 2466 | | 2466 | |
| 2467 | try a.bitAnd(&a, &b); | 2467 | try a.bitAnd(&a, &b); |
| 2468 | | 2468 | |
| 2469 | try testing.expect((try a.toInt(i128)) == -0xffffffff33333332); | 2469 | try testing.expectEqual(-0xffffffff33333332, try a.toInt(i128)); |
| 2470 | } | 2470 | } |
| 2471 | | 2471 | |
| 2472 | test "bitwise and negative-negative multi-limb" { | 2472 | test "bitwise and negative-negative multi-limb" { |
| ... | @@ -2477,7 +2477,7 @@ test "bitwise and negative-negative multi-limb" { | ... | @@ -2477,7 +2477,7 @@ test "bitwise and negative-negative multi-limb" { |
| 2477 | | 2477 | |
| 2478 | try a.bitAnd(&a, &b); | 2478 | try a.bitAnd(&a, &b); |
| 2479 | | 2479 | |
| 2480 | try testing.expect((try a.toInt(i128)) == -maxInt(Limb) * 2 - 2); | 2480 | try testing.expectEqual(-maxInt(Limb) * 2 - 2, try a.toInt(i128)); |
| 2481 | } | 2481 | } |
| 2482 | | 2482 | |
| 2483 | test "bitwise and negative overflow" { | 2483 | test "bitwise and negative overflow" { |
| ... | @@ -2488,7 +2488,7 @@ test "bitwise and negative overflow" { | ... | @@ -2488,7 +2488,7 @@ test "bitwise and negative overflow" { |
| 2488 | | 2488 | |
| 2489 | try a.bitAnd(&a, &b); | 2489 | try a.bitAnd(&a, &b); |
| 2490 | | 2490 | |
| 2491 | try testing.expect((try a.toInt(SignedDoubleLimb)) == -maxInt(Limb) - 1); | 2491 | try testing.expectEqual(-maxInt(Limb) - 1, try a.toInt(SignedDoubleLimb)); |
| 2492 | } | 2492 | } |
| 2493 | | 2493 | |
| 2494 | test "bitwise xor simple" { | 2494 | test "bitwise xor simple" { |
| ... | @@ -2499,7 +2499,7 @@ test "bitwise xor simple" { | ... | @@ -2499,7 +2499,7 @@ test "bitwise xor simple" { |
| 2499 | | 2499 | |
| 2500 | try a.bitXor(&a, &b); | 2500 | try a.bitXor(&a, &b); |
| 2501 | | 2501 | |
| 2502 | try testing.expect((try a.toInt(u64)) == 0x1111111133333333); | 2502 | try testing.expectEqual(0x1111111133333333, try a.toInt(u64)); |
| 2503 | } | 2503 | } |
| 2504 | | 2504 | |
| 2505 | test "bitwise xor multi-limb" { | 2505 | test "bitwise xor multi-limb" { |
| ... | @@ -2514,7 +2514,7 @@ test "bitwise xor multi-limb" { | ... | @@ -2514,7 +2514,7 @@ test "bitwise xor multi-limb" { |
| 2514 | | 2514 | |
| 2515 | try a.bitXor(&a, &b); | 2515 | try a.bitXor(&a, &b); |
| 2516 | | 2516 | |
| 2517 | try testing.expect((try a.toInt(DoubleLimb)) == x ^ y); | 2517 | try testing.expectEqual(x ^ y, try a.toInt(DoubleLimb)); |
| 2518 | } | 2518 | } |
| 2519 | | 2519 | |
| 2520 | test "bitwise xor single negative simple" { | 2520 | test "bitwise xor single negative simple" { |
| ... | @@ -2525,7 +2525,7 @@ test "bitwise xor single negative simple" { | ... | @@ -2525,7 +2525,7 @@ test "bitwise xor single negative simple" { |
| 2525 | | 2525 | |
| 2526 | try a.bitXor(&a, &b); | 2526 | try a.bitXor(&a, &b); |
| 2527 | | 2527 | |
| 2528 | try testing.expect((try a.toInt(i64)) == -0x2efed94fcb932ef9); | 2528 | try testing.expectEqual(-0x2efed94fcb932ef9, try a.toInt(i64)); |
| 2529 | } | 2529 | } |
| 2530 | | 2530 | |
| 2531 | test "bitwise xor single negative multi-limb" { | 2531 | test "bitwise xor single negative multi-limb" { |
| ... | @@ -2536,7 +2536,7 @@ test "bitwise xor single negative multi-limb" { | ... | @@ -2536,7 +2536,7 @@ test "bitwise xor single negative multi-limb" { |
| 2536 | | 2536 | |
| 2537 | try a.bitXor(&a, &b); | 2537 | try a.bitXor(&a, &b); |
| 2538 | | 2538 | |
| 2539 | try testing.expect((try a.toInt(i128)) == -0x6a50889abd8834a24db1f19650d3999a); | 2539 | try testing.expectEqual(-0x6a50889abd8834a24db1f19650d3999a, try a.toInt(i128)); |
| 2540 | } | 2540 | } |
| 2541 | | 2541 | |
| 2542 | test "bitwise xor single negative overflow" { | 2542 | test "bitwise xor single negative overflow" { |
| ... | @@ -2547,7 +2547,7 @@ test "bitwise xor single negative overflow" { | ... | @@ -2547,7 +2547,7 @@ test "bitwise xor single negative overflow" { |
| 2547 | | 2547 | |
| 2548 | try a.bitXor(&a, &b); | 2548 | try a.bitXor(&a, &b); |
| 2549 | | 2549 | |
| 2550 | try testing.expect((try a.toInt(SignedDoubleLimb)) == -(maxInt(Limb) + 1)); | 2550 | try testing.expectEqual(-(maxInt(Limb) + 1), try a.toInt(SignedDoubleLimb)); |
| 2551 | } | 2551 | } |
| 2552 | | 2552 | |
| 2553 | test "bitwise xor double negative simple" { | 2553 | test "bitwise xor double negative simple" { |
| ... | @@ -2558,7 +2558,7 @@ test "bitwise xor double negative simple" { | ... | @@ -2558,7 +2558,7 @@ test "bitwise xor double negative simple" { |
| 2558 | | 2558 | |
| 2559 | try a.bitXor(&a, &b); | 2559 | try a.bitXor(&a, &b); |
| 2560 | | 2560 | |
| 2561 | try testing.expect((try a.toInt(u64)) == 0xc39c47081a6eb759); | 2561 | try testing.expectEqual(0xc39c47081a6eb759, try a.toInt(u64)); |
| 2562 | } | 2562 | } |
| 2563 | | 2563 | |
| 2564 | test "bitwise xor double negative multi-limb" { | 2564 | test "bitwise xor double negative multi-limb" { |
| ... | @@ -2569,7 +2569,7 @@ test "bitwise xor double negative multi-limb" { | ... | @@ -2569,7 +2569,7 @@ test "bitwise xor double negative multi-limb" { |
| 2569 | | 2569 | |
| 2570 | try a.bitXor(&a, &b); | 2570 | try a.bitXor(&a, &b); |
| 2571 | | 2571 | |
| 2572 | try testing.expect((try a.toInt(u128)) == 0xa3492ec28e62c410dff92bf0549bf771); | 2572 | try testing.expectEqual(0xa3492ec28e62c410dff92bf0549bf771, try a.toInt(u128)); |
| 2573 | } | 2573 | } |
| 2574 | | 2574 | |
| 2575 | test "bitwise or simple" { | 2575 | test "bitwise or simple" { |
| ... | @@ -2580,7 +2580,7 @@ test "bitwise or simple" { | ... | @@ -2580,7 +2580,7 @@ test "bitwise or simple" { |
| 2580 | | 2580 | |
| 2581 | try a.bitOr(&a, &b); | 2581 | try a.bitOr(&a, &b); |
| 2582 | | 2582 | |
| 2583 | try testing.expect((try a.toInt(u64)) == 0xffffffff33333333); | 2583 | try testing.expectEqual(0xffffffff33333333, try a.toInt(u64)); |
| 2584 | } | 2584 | } |
| 2585 | | 2585 | |
| 2586 | test "bitwise or multi-limb" { | 2586 | test "bitwise or multi-limb" { |
| ... | @@ -2591,7 +2591,7 @@ test "bitwise or multi-limb" { | ... | @@ -2591,7 +2591,7 @@ test "bitwise or multi-limb" { |
| 2591 | | 2591 | |
| 2592 | try a.bitOr(&a, &b); | 2592 | try a.bitOr(&a, &b); |
| 2593 | | 2593 | |
| 2594 | try testing.expect((try a.toInt(DoubleLimb)) == (maxInt(Limb) + 1) + maxInt(Limb)); | 2594 | try testing.expectEqual((maxInt(Limb) + 1) + maxInt(Limb), try a.toInt(DoubleLimb)); |
| 2595 | } | 2595 | } |
| 2596 | | 2596 | |
| 2597 | test "bitwise or negative-positive simple" { | 2597 | test "bitwise or negative-positive simple" { |
| ... | @@ -2602,7 +2602,7 @@ test "bitwise or negative-positive simple" { | ... | @@ -2602,7 +2602,7 @@ test "bitwise or negative-positive simple" { |
| 2602 | | 2602 | |
| 2603 | try a.bitOr(&a, &b); | 2603 | try a.bitOr(&a, &b); |
| 2604 | | 2604 | |
| 2605 | try testing.expect((try a.toInt(i64)) == -0x1111111111111111); | 2605 | try testing.expectEqual(-0x1111111111111111, try a.toInt(i64)); |
| 2606 | } | 2606 | } |
| 2607 | | 2607 | |
| 2608 | test "bitwise or negative-positive multi-limb" { | 2608 | test "bitwise or negative-positive multi-limb" { |
| ... | @@ -2613,7 +2613,7 @@ test "bitwise or negative-positive multi-limb" { | ... | @@ -2613,7 +2613,7 @@ test "bitwise or negative-positive multi-limb" { |
| 2613 | | 2613 | |
| 2614 | try a.bitOr(&a, &b); | 2614 | try a.bitOr(&a, &b); |
| 2615 | | 2615 | |
| 2616 | try testing.expect((try a.toInt(SignedDoubleLimb)) == -maxInt(Limb)); | 2616 | try testing.expectEqual(-maxInt(Limb), try a.toInt(SignedDoubleLimb)); |
| 2617 | } | 2617 | } |
| 2618 | | 2618 | |
| 2619 | test "bitwise or positive-negative simple" { | 2619 | test "bitwise or positive-negative simple" { |
| ... | @@ -2624,7 +2624,7 @@ test "bitwise or positive-negative simple" { | ... | @@ -2624,7 +2624,7 @@ test "bitwise or positive-negative simple" { |
| 2624 | | 2624 | |
| 2625 | try a.bitOr(&a, &b); | 2625 | try a.bitOr(&a, &b); |
| 2626 | | 2626 | |
| 2627 | try testing.expect((try a.toInt(i64)) == -0x22222221); | 2627 | try testing.expectEqual(-0x22222221, try a.toInt(i64)); |
| 2628 | } | 2628 | } |
| 2629 | | 2629 | |
| 2630 | test "bitwise or positive-negative multi-limb" { | 2630 | test "bitwise or positive-negative multi-limb" { |
| ... | @@ -2635,7 +2635,7 @@ test "bitwise or positive-negative multi-limb" { | ... | @@ -2635,7 +2635,7 @@ test "bitwise or positive-negative multi-limb" { |
| 2635 | | 2635 | |
| 2636 | try a.bitOr(&a, &b); | 2636 | try a.bitOr(&a, &b); |
| 2637 | | 2637 | |
| 2638 | try testing.expect((try a.toInt(SignedDoubleLimb)) == -1); | 2638 | try testing.expectEqual(-1, try a.toInt(SignedDoubleLimb)); |
| 2639 | } | 2639 | } |
| 2640 | | 2640 | |
| 2641 | test "bitwise or negative-negative simple" { | 2641 | test "bitwise or negative-negative simple" { |
| ... | @@ -2646,7 +2646,7 @@ test "bitwise or negative-negative simple" { | ... | @@ -2646,7 +2646,7 @@ test "bitwise or negative-negative simple" { |
| 2646 | | 2646 | |
| 2647 | try a.bitOr(&a, &b); | 2647 | try a.bitOr(&a, &b); |
| 2648 | | 2648 | |
| 2649 | try testing.expect((try a.toInt(i128)) == -0xeeeeeeee00000001); | 2649 | try testing.expectEqual(-0xeeeeeeee00000001, try a.toInt(i128)); |
| 2650 | } | 2650 | } |
| 2651 | | 2651 | |
| 2652 | test "bitwise or negative-negative multi-limb" { | 2652 | test "bitwise or negative-negative multi-limb" { |
| ... | @@ -2657,7 +2657,7 @@ test "bitwise or negative-negative multi-limb" { | ... | @@ -2657,7 +2657,7 @@ test "bitwise or negative-negative multi-limb" { |
| 2657 | | 2657 | |
| 2658 | try a.bitOr(&a, &b); | 2658 | try a.bitOr(&a, &b); |
| 2659 | | 2659 | |
| 2660 | try testing.expect((try a.toInt(SignedDoubleLimb)) == -maxInt(Limb)); | 2660 | try testing.expectEqual(-maxInt(Limb), try a.toInt(SignedDoubleLimb)); |
| 2661 | } | 2661 | } |
| 2662 | | 2662 | |
| 2663 | test "var args" { | 2663 | test "var args" { |
| ... | @@ -2667,11 +2667,11 @@ test "var args" { | ... | @@ -2667,11 +2667,11 @@ test "var args" { |
| 2667 | var b = try Managed.initSet(testing.allocator, 6); | 2667 | var b = try Managed.initSet(testing.allocator, 6); |
| 2668 | defer b.deinit(); | 2668 | defer b.deinit(); |
| 2669 | try a.add(&a, &b); | 2669 | try a.add(&a, &b); |
| 2670 | try testing.expect((try a.toInt(u64)) == 11); | 2670 | try testing.expectEqual(11, try a.toInt(u64)); |
| 2671 | | 2671 | |
| 2672 | var c = try Managed.initSet(testing.allocator, 11); | 2672 | var c = try Managed.initSet(testing.allocator, 11); |
| 2673 | defer c.deinit(); | 2673 | defer c.deinit(); |
| 2674 | try testing.expect(a.order(c) == .eq); | 2674 | try testing.expectEqual(.eq, a.order(c)); |
| 2675 | | 2675 | |
| 2676 | var d = try Managed.initSet(testing.allocator, 14); | 2676 | var d = try Managed.initSet(testing.allocator, 14); |
| 2677 | defer d.deinit(); | 2677 | defer d.deinit(); |
| ... | @@ -2688,7 +2688,7 @@ test "gcd non-one small" { | ... | @@ -2688,7 +2688,7 @@ test "gcd non-one small" { |
| 2688 | | 2688 | |
| 2689 | try r.gcd(&a, &b); | 2689 | try r.gcd(&a, &b); |
| 2690 | | 2690 | |
| 2691 | try testing.expect((try r.toInt(u32)) == 1); | 2691 | try testing.expectEqual(1, try r.toInt(u32)); |
| 2692 | } | 2692 | } |
| 2693 | | 2693 | |
| 2694 | test "gcd non-one medium" { | 2694 | test "gcd non-one medium" { |
| ... | @@ -2701,7 +2701,7 @@ test "gcd non-one medium" { | ... | @@ -2701,7 +2701,7 @@ test "gcd non-one medium" { |
| 2701 | | 2701 | |
| 2702 | try r.gcd(&a, &b); | 2702 | try r.gcd(&a, &b); |
| 2703 | | 2703 | |
| 2704 | try testing.expect((try r.toInt(u32)) == 38); | 2704 | try testing.expectEqual(38, try r.toInt(u32)); |
| 2705 | } | 2705 | } |
| 2706 | | 2706 | |
| 2707 | test "gcd non-one large" { | 2707 | test "gcd non-one large" { |
| ... | @@ -2714,7 +2714,7 @@ test "gcd non-one large" { | ... | @@ -2714,7 +2714,7 @@ test "gcd non-one large" { |
| 2714 | | 2714 | |
| 2715 | try r.gcd(&a, &b); | 2715 | try r.gcd(&a, &b); |
| 2716 | | 2716 | |
| 2717 | try testing.expect((try r.toInt(u32)) == 4369); | 2717 | try testing.expectEqual(4369, try r.toInt(u32)); |
| 2718 | } | 2718 | } |
| 2719 | | 2719 | |
| 2720 | test "gcd large multi-limb result" { | 2720 | test "gcd large multi-limb result" { |
| ... | @@ -2730,7 +2730,7 @@ test "gcd large multi-limb result" { | ... | @@ -2730,7 +2730,7 @@ test "gcd large multi-limb result" { |
| 2730 | try r.gcd(&a, &b); | 2730 | try r.gcd(&a, &b); |
| 2731 | | 2731 | |
| 2732 | const answer = (try r.toInt(u256)); | 2732 | const answer = (try r.toInt(u256)); |
| 2733 | try testing.expect(answer == 0xf000000ff00000fff0000ffff000fffff00ffffff1); | 2733 | try testing.expectEqual(0xf000000ff00000fff0000ffff000fffff00ffffff1, answer); |
| 2734 | } | 2734 | } |
| 2735 | | 2735 | |
| 2736 | test "gcd one large" { | 2736 | test "gcd one large" { |
| ... | @@ -2743,7 +2743,7 @@ test "gcd one large" { | ... | @@ -2743,7 +2743,7 @@ test "gcd one large" { |
| 2743 | | 2743 | |
| 2744 | try r.gcd(&a, &b); | 2744 | try r.gcd(&a, &b); |
| 2745 | | 2745 | |
| 2746 | try testing.expect((try r.toInt(u64)) == 1); | 2746 | try testing.expectEqual(1, try r.toInt(u64)); |
| 2747 | } | 2747 | } |
| 2748 | | 2748 | |
| 2749 | test "mutable to managed" { | 2749 | test "mutable to managed" { |
| ... | @@ -2863,7 +2863,7 @@ test "regression test for 1 limb overflow with alias" { | ... | @@ -2863,7 +2863,7 @@ test "regression test for 1 limb overflow with alias" { |
| 2863 | try a.ensureAddCapacity(a.toConst(), b.toConst()); | 2863 | try a.ensureAddCapacity(a.toConst(), b.toConst()); |
| 2864 | try a.add(&a, &b); | 2864 | try a.add(&a, &b); |
| 2865 | | 2865 | |
| 2866 | try testing.expect(a.toConst().orderAgainstScalar(19740274219868223167) == .eq); | 2866 | try testing.expectEqual(.eq, a.toConst().orderAgainstScalar(19740274219868223167)); |
| 2867 | } | 2867 | } |
| 2868 | | 2868 | |
| 2869 | test "regression test for realloc with alias" { | 2869 | test "regression test for realloc with alias" { |
| ... | @@ -2877,7 +2877,7 @@ test "regression test for realloc with alias" { | ... | @@ -2877,7 +2877,7 @@ test "regression test for realloc with alias" { |
| 2877 | try a.ensureAddCapacity(a.toConst(), b.toConst()); | 2877 | try a.ensureAddCapacity(a.toConst(), b.toConst()); |
| 2878 | try a.add(&a, &b); | 2878 | try a.add(&a, &b); |
| 2879 | | 2879 | |
| 2880 | try testing.expect(a.toConst().orderAgainstScalar(14691098406862188148944207245954912110548093601382197697835) == .eq); | 2880 | try testing.expectEqual(.eq, a.toConst().orderAgainstScalar(14691098406862188148944207245954912110548093601382197697835)); |
| 2881 | } | 2881 | } |
| 2882 | | 2882 | |
| 2883 | test "big int popcount" { | 2883 | test "big int popcount" { |
| ... | @@ -2977,12 +2977,12 @@ test "big int conversion read/write twos complement" { | ... | @@ -2977,12 +2977,12 @@ test "big int conversion read/write twos complement" { |
| 2977 | // Writing to buffer and back should not change anything | 2977 | // Writing to buffer and back should not change anything |
| 2978 | a.toConst().writeTwosComplement(buffer1[0..abi_size], endian); | 2978 | a.toConst().writeTwosComplement(buffer1[0..abi_size], endian); |
| 2979 | m.readTwosComplement(buffer1[0..abi_size], 493, endian, .unsigned); | 2979 | m.readTwosComplement(buffer1[0..abi_size], 493, endian, .unsigned); |
| 2980 | try testing.expect(m.toConst().order(a.toConst()) == .eq); | 2980 | try testing.expectEqual(.eq, m.toConst().order(a.toConst())); |
| 2981 | | 2981 | |
| 2982 | // Equivalent to @bitCast(i493, @as(u493, intMax(u493)) | 2982 | // Equivalent to @bitCast(i493, @as(u493, intMax(u493)) |
| 2983 | a.toConst().writeTwosComplement(buffer1[0..abi_size], endian); | 2983 | a.toConst().writeTwosComplement(buffer1[0..abi_size], endian); |
| 2984 | m.readTwosComplement(buffer1[0..abi_size], 493, endian, .signed); | 2984 | m.readTwosComplement(buffer1[0..abi_size], 493, endian, .signed); |
| 2985 | try testing.expect(m.toConst().orderAgainstScalar(-1) == .eq); | 2985 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(-1)); |
| 2986 | } | 2986 | } |
| 2987 | } | 2987 | } |
| 2988 | | 2988 | |
| ... | @@ -3076,19 +3076,19 @@ test "big int conversion write twos complement with padding" { | ... | @@ -3076,19 +3076,19 @@ test "big int conversion write twos complement with padding" { |
| 3076 | | 3076 | |
| 3077 | buffer = &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0xb }; | 3077 | buffer = &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0xb }; |
| 3078 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); | 3078 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); |
| 3079 | try testing.expect(m.toConst().orderAgainstScalar(0x01_02030405_06070809_0a0b0c0d) == .eq); | 3079 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x01_02030405_06070809_0a0b0c0d)); |
| 3080 | | 3080 | |
| 3081 | buffer = &[_]u8{ 0xb, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }; | 3081 | buffer = &[_]u8{ 0xb, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }; |
| 3082 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); | 3082 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); |
| 3083 | try testing.expect(m.toConst().orderAgainstScalar(0x01_02030405_06070809_0a0b0c0d) == .eq); | 3083 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x01_02030405_06070809_0a0b0c0d)); |
| 3084 | | 3084 | |
| 3085 | buffer = &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0xab, 0xaa, 0xaa, 0xaa }; | 3085 | buffer = &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0xab, 0xaa, 0xaa, 0xaa }; |
| 3086 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); | 3086 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); |
| 3087 | try testing.expect(m.toConst().orderAgainstScalar(0x01_02030405_06070809_0a0b0c0d) == .eq); | 3087 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x01_02030405_06070809_0a0b0c0d)); |
| 3088 | | 3088 | |
| 3089 | buffer = &[_]u8{ 0xaa, 0xaa, 0xaa, 0xab, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }; | 3089 | buffer = &[_]u8{ 0xaa, 0xaa, 0xaa, 0xab, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }; |
| 3090 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); | 3090 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); |
| 3091 | try testing.expect(m.toConst().orderAgainstScalar(0x01_02030405_06070809_0a0b0c0d) == .eq); | 3091 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x01_02030405_06070809_0a0b0c0d)); |
| 3092 | | 3092 | |
| 3093 | bit_count = @sizeOf(Limb) * 8; | 3093 | bit_count = @sizeOf(Limb) * 8; |
| 3094 | | 3094 | |
| ... | @@ -3096,19 +3096,19 @@ test "big int conversion write twos complement with padding" { | ... | @@ -3096,19 +3096,19 @@ test "big int conversion write twos complement with padding" { |
| 3096 | | 3096 | |
| 3097 | buffer = &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0xaa }; | 3097 | buffer = &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0xaa }; |
| 3098 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); | 3098 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); |
| 3099 | try testing.expect(m.toConst().orderAgainstScalar(@as(Limb, @truncate(0xaa_02030405_06070809_0a0b0c0d))) == .eq); | 3099 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(@as(Limb, @truncate(0xaa_02030405_06070809_0a0b0c0d)))); |
| 3100 | | 3100 | |
| 3101 | buffer = &[_]u8{ 0xaa, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }; | 3101 | buffer = &[_]u8{ 0xaa, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }; |
| 3102 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); | 3102 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); |
| 3103 | try testing.expect(m.toConst().orderAgainstScalar(@as(Limb, @truncate(0xaa_02030405_06070809_0a0b0c0d))) == .eq); | 3103 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(@as(Limb, @truncate(0xaa_02030405_06070809_0a0b0c0d)))); |
| 3104 | | 3104 | |
| 3105 | buffer = &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0xaa, 0xaa, 0xaa, 0xaa }; | 3105 | buffer = &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0xaa, 0xaa, 0xaa, 0xaa }; |
| 3106 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); | 3106 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); |
| 3107 | try testing.expect(m.toConst().orderAgainstScalar(@as(Limb, @truncate(0xaaaaaaaa_02030405_06070809_0a0b0c0d))) == .eq); | 3107 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(@as(Limb, @truncate(0xaaaaaaaa_02030405_06070809_0a0b0c0d)))); |
| 3108 | | 3108 | |
| 3109 | buffer = &[_]u8{ 0xaa, 0xaa, 0xaa, 0xaa, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }; | 3109 | buffer = &[_]u8{ 0xaa, 0xaa, 0xaa, 0xaa, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }; |
| 3110 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); | 3110 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); |
| 3111 | try testing.expect(m.toConst().orderAgainstScalar(@as(Limb, @truncate(0xaaaaaaaa_02030405_06070809_0a0b0c0d))) == .eq); | 3111 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(@as(Limb, @truncate(0xaaaaaaaa_02030405_06070809_0a0b0c0d)))); |
| 3112 | | 3112 | |
| 3113 | bit_count = 12 * 8 + 2; | 3113 | bit_count = 12 * 8 + 2; |
| 3114 | | 3114 | |
| ... | @@ -3116,42 +3116,42 @@ test "big int conversion write twos complement with padding" { | ... | @@ -3116,42 +3116,42 @@ test "big int conversion write twos complement with padding" { |
| 3116 | | 3116 | |
| 3117 | buffer = &[_]u8{ 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0x02 }; | 3117 | buffer = &[_]u8{ 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0x02 }; |
| 3118 | m.readTwosComplement(buffer[0..13], bit_count, .little, .signed); | 3118 | m.readTwosComplement(buffer[0..13], bit_count, .little, .signed); |
| 3119 | try testing.expect(m.toConst().orderAgainstScalar(-0x01_02030405_06070809_0a0b0c0d) == .eq); | 3119 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(-0x01_02030405_06070809_0a0b0c0d)); |
| 3120 | | 3120 | |
| 3121 | buffer = &[_]u8{ 0x02, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf3 }; | 3121 | buffer = &[_]u8{ 0x02, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf3 }; |
| 3122 | m.readTwosComplement(buffer[0..13], bit_count, .big, .signed); | 3122 | m.readTwosComplement(buffer[0..13], bit_count, .big, .signed); |
| 3123 | try testing.expect(m.toConst().orderAgainstScalar(-0x01_02030405_06070809_0a0b0c0d) == .eq); | 3123 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(-0x01_02030405_06070809_0a0b0c0d)); |
| 3124 | | 3124 | |
| 3125 | buffer = &[_]u8{ 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0x02, 0xaa, 0xaa, 0xaa }; | 3125 | buffer = &[_]u8{ 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0x02, 0xaa, 0xaa, 0xaa }; |
| 3126 | m.readTwosComplement(buffer[0..16], bit_count, .little, .signed); | 3126 | m.readTwosComplement(buffer[0..16], bit_count, .little, .signed); |
| 3127 | try testing.expect(m.toConst().orderAgainstScalar(-0x01_02030405_06070809_0a0b0c0d) == .eq); | 3127 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(-0x01_02030405_06070809_0a0b0c0d)); |
| 3128 | | 3128 | |
| 3129 | buffer = &[_]u8{ 0xaa, 0xaa, 0xaa, 0x02, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf3 }; | 3129 | buffer = &[_]u8{ 0xaa, 0xaa, 0xaa, 0x02, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf3 }; |
| 3130 | m.readTwosComplement(buffer[0..16], bit_count, .big, .signed); | 3130 | m.readTwosComplement(buffer[0..16], bit_count, .big, .signed); |
| 3131 | try testing.expect(m.toConst().orderAgainstScalar(-0x01_02030405_06070809_0a0b0c0d) == .eq); | 3131 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(-0x01_02030405_06070809_0a0b0c0d)); |
| 3132 | | 3132 | |
| 3133 | // Test 0 | 3133 | // Test 0 |
| 3134 | | 3134 | |
| 3135 | buffer = &([_]u8{0} ** 16); | 3135 | buffer = &([_]u8{0} ** 16); |
| 3136 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); | 3136 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); |
| 3137 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3137 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3138 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); | 3138 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); |
| 3139 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3139 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3140 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); | 3140 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); |
| 3141 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3141 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3142 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); | 3142 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); |
| 3143 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3143 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3144 | | 3144 | |
| 3145 | bit_count = 0; | 3145 | bit_count = 0; |
| 3146 | buffer = &([_]u8{0xaa} ** 16); | 3146 | buffer = &([_]u8{0xaa} ** 16); |
| 3147 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); | 3147 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); |
| 3148 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3148 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3149 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); | 3149 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); |
| 3150 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3150 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3151 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); | 3151 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); |
| 3152 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3152 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3153 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); | 3153 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); |
| 3154 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3154 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3155 | } | 3155 | } |
| 3156 | | 3156 | |
| 3157 | test "big int conversion write twos complement zero" { | 3157 | test "big int conversion write twos complement zero" { |
| ... | @@ -3170,15 +3170,15 @@ test "big int conversion write twos complement zero" { | ... | @@ -3170,15 +3170,15 @@ test "big int conversion write twos complement zero" { |
| 3170 | | 3170 | |
| 3171 | buffer = &([_]u8{0} ** 13); | 3171 | buffer = &([_]u8{0} ** 13); |
| 3172 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); | 3172 | m.readTwosComplement(buffer[0..13], bit_count, .little, .unsigned); |
| 3173 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3173 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3174 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); | 3174 | m.readTwosComplement(buffer[0..13], bit_count, .big, .unsigned); |
| 3175 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3175 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3176 | | 3176 | |
| 3177 | buffer = &([_]u8{0} ** 16); | 3177 | buffer = &([_]u8{0} ** 16); |
| 3178 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); | 3178 | m.readTwosComplement(buffer[0..16], bit_count, .little, .unsigned); |
| 3179 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3179 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3180 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); | 3180 | m.readTwosComplement(buffer[0..16], bit_count, .big, .unsigned); |
| 3181 | try testing.expect(m.toConst().orderAgainstScalar(0x0) == .eq); | 3181 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(0x0)); |
| 3182 | } | 3182 | } |
| 3183 | | 3183 | |
| 3184 | fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void { | 3184 | fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void { |
| ... | @@ -3191,7 +3191,7 @@ fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expec | ... | @@ -3191,7 +3191,7 @@ fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expec |
| 3191 | try a.ensureCapacity(calcTwosCompLimbCount(bit_count)); | 3191 | try a.ensureCapacity(calcTwosCompLimbCount(bit_count)); |
| 3192 | var m = a.toMutable(); | 3192 | var m = a.toMutable(); |
| 3193 | m.bitReverse(a.toConst(), signedness, bit_count); | 3193 | m.bitReverse(a.toConst(), signedness, bit_count); |
| 3194 | try testing.expect(m.toConst().orderAgainstScalar(expected_output) == .eq); | 3194 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(expected_output)); |
| 3195 | } | 3195 | } |
| 3196 | | 3196 | |
| 3197 | test "big int bit reverse" { | 3197 | test "big int bit reverse" { |
| ... | @@ -3238,7 +3238,7 @@ fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expecte | ... | @@ -3238,7 +3238,7 @@ fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expecte |
| 3238 | try a.ensureCapacity(calcTwosCompLimbCount(8 * byte_count)); | 3238 | try a.ensureCapacity(calcTwosCompLimbCount(8 * byte_count)); |
| 3239 | var m = a.toMutable(); | 3239 | var m = a.toMutable(); |
| 3240 | m.byteSwap(a.toConst(), signedness, byte_count); | 3240 | m.byteSwap(a.toConst(), signedness, byte_count); |
| 3241 | try testing.expect(m.toConst().orderAgainstScalar(expected_output) == .eq); | 3241 | try testing.expectEqual(.eq, m.toConst().orderAgainstScalar(expected_output)); |
| 3242 | } | 3242 | } |
| 3243 | | 3243 | |
| 3244 | test "big int byte swap" { | 3244 | test "big int byte swap" { |
| ... | @@ -3449,111 +3449,111 @@ test "clz" { | ... | @@ -3449,111 +3449,111 @@ test "clz" { |
| 3449 | .limbs = &.{ 1, maxInt(Limb) - 1 }, | 3449 | .limbs = &.{ 1, maxInt(Limb) - 1 }, |
| 3450 | .positive = false, | 3450 | .positive = false, |
| 3451 | }; | 3451 | }; |
| 3452 | try testing.expect(neg_limb_max_squared.clz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3452 | try testing.expectEqual(0, neg_limb_max_squared.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3453 | | 3453 | |
| 3454 | const neg_limb_max_squared_plus_one: std.math.big.int.Const = .{ | 3454 | const neg_limb_max_squared_plus_one: std.math.big.int.Const = .{ |
| 3455 | .limbs = &.{ 0, maxInt(Limb) - 1 }, | 3455 | .limbs = &.{ 0, maxInt(Limb) - 1 }, |
| 3456 | .positive = false, | 3456 | .positive = false, |
| 3457 | }; | 3457 | }; |
| 3458 | try testing.expect(neg_limb_max_squared_plus_one.clz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3458 | try testing.expectEqual(0, neg_limb_max_squared_plus_one.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3459 | | 3459 | |
| 3460 | const neg_limb_msb_squared: std.math.big.int.Const = .{ | 3460 | const neg_limb_msb_squared: std.math.big.int.Const = .{ |
| 3461 | .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 }, | 3461 | .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 }, |
| 3462 | .positive = false, | 3462 | .positive = false, |
| 3463 | }; | 3463 | }; |
| 3464 | try testing.expect(neg_limb_msb_squared.clz(@bitSizeOf(Limb) * 2) == 0); | 3464 | try testing.expectEqual(0, neg_limb_msb_squared.clz(@bitSizeOf(Limb) * 2)); |
| 3465 | try testing.expect(neg_limb_msb_squared.clz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3465 | try testing.expectEqual(0, neg_limb_msb_squared.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3466 | | 3466 | |
| 3467 | const neg_limb_max: std.math.big.int.Const = .{ | 3467 | const neg_limb_max: std.math.big.int.Const = .{ |
| 3468 | .limbs = &.{maxInt(Limb)}, | 3468 | .limbs = &.{maxInt(Limb)}, |
| 3469 | .positive = false, | 3469 | .positive = false, |
| 3470 | }; | 3470 | }; |
| 3471 | try testing.expect(neg_limb_max.clz(@bitSizeOf(Limb) + 1) == 0); | 3471 | try testing.expectEqual(0, neg_limb_max.clz(@bitSizeOf(Limb) + 1)); |
| 3472 | try testing.expect(neg_limb_max.clz(@bitSizeOf(Limb) * 2 - 1) == 0); | 3472 | try testing.expectEqual(0, neg_limb_max.clz(@bitSizeOf(Limb) * 2 - 1)); |
| 3473 | try testing.expect(neg_limb_max.clz(@bitSizeOf(Limb) * 2) == 0); | 3473 | try testing.expectEqual(0, neg_limb_max.clz(@bitSizeOf(Limb) * 2)); |
| 3474 | try testing.expect(neg_limb_max.clz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3474 | try testing.expectEqual(0, neg_limb_max.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3475 | | 3475 | |
| 3476 | const neg_limb_msb: std.math.big.int.Const = .{ | 3476 | const neg_limb_msb: std.math.big.int.Const = .{ |
| 3477 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, | 3477 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, |
| 3478 | .positive = false, | 3478 | .positive = false, |
| 3479 | }; | 3479 | }; |
| 3480 | try testing.expect(neg_limb_msb.clz(@bitSizeOf(Limb)) == 0); | 3480 | try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb))); |
| 3481 | try testing.expect(neg_limb_msb.clz(@bitSizeOf(Limb) + 1) == 0); | 3481 | try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb) + 1)); |
| 3482 | try testing.expect(neg_limb_msb.clz(@bitSizeOf(Limb) * 2 - 1) == 0); | 3482 | try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb) * 2 - 1)); |
| 3483 | try testing.expect(neg_limb_msb.clz(@bitSizeOf(Limb) * 2) == 0); | 3483 | try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb) * 2)); |
| 3484 | try testing.expect(neg_limb_msb.clz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3484 | try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3485 | | 3485 | |
| 3486 | const neg_one: std.math.big.int.Const = .{ | 3486 | const neg_one: std.math.big.int.Const = .{ |
| 3487 | .limbs = &.{1}, | 3487 | .limbs = &.{1}, |
| 3488 | .positive = false, | 3488 | .positive = false, |
| 3489 | }; | 3489 | }; |
| 3490 | try testing.expect(neg_one.clz(@bitSizeOf(Limb)) == 0); | 3490 | try testing.expectEqual(0, neg_one.clz(@bitSizeOf(Limb))); |
| 3491 | try testing.expect(neg_one.clz(@bitSizeOf(Limb) + 1) == 0); | 3491 | try testing.expectEqual(0, neg_one.clz(@bitSizeOf(Limb) + 1)); |
| 3492 | try testing.expect(neg_one.clz(@bitSizeOf(Limb) * 2 - 1) == 0); | 3492 | try testing.expectEqual(0, neg_one.clz(@bitSizeOf(Limb) * 2 - 1)); |
| 3493 | try testing.expect(neg_one.clz(@bitSizeOf(Limb) * 2) == 0); | 3493 | try testing.expectEqual(0, neg_one.clz(@bitSizeOf(Limb) * 2)); |
| 3494 | try testing.expect(neg_one.clz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3494 | try testing.expectEqual(0, neg_one.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3495 | | 3495 | |
| 3496 | const zero: std.math.big.int.Const = .{ | 3496 | const zero: std.math.big.int.Const = .{ |
| 3497 | .limbs = &.{0}, | 3497 | .limbs = &.{0}, |
| 3498 | .positive = true, | 3498 | .positive = true, |
| 3499 | }; | 3499 | }; |
| 3500 | try testing.expect(zero.clz(@bitSizeOf(Limb)) == @bitSizeOf(Limb)); | 3500 | try testing.expectEqual(@bitSizeOf(Limb), zero.clz(@bitSizeOf(Limb))); |
| 3501 | try testing.expect(zero.clz(@bitSizeOf(Limb) + 1) == @bitSizeOf(Limb) + 1); | 3501 | try testing.expectEqual(@bitSizeOf(Limb) + 1, zero.clz(@bitSizeOf(Limb) + 1)); |
| 3502 | try testing.expect(zero.clz(@bitSizeOf(Limb) * 2 - 1) == @bitSizeOf(Limb) * 2 - 1); | 3502 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 1, zero.clz(@bitSizeOf(Limb) * 2 - 1)); |
| 3503 | try testing.expect(zero.clz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb) * 2); | 3503 | try testing.expectEqual(@bitSizeOf(Limb) * 2, zero.clz(@bitSizeOf(Limb) * 2)); |
| 3504 | try testing.expect(zero.clz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) * 2 + 1); | 3504 | try testing.expectEqual(@bitSizeOf(Limb) * 2 + 1, zero.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3505 | | 3505 | |
| 3506 | const one: std.math.big.int.Const = .{ | 3506 | const one: std.math.big.int.Const = .{ |
| 3507 | .limbs = &.{1}, | 3507 | .limbs = &.{1}, |
| 3508 | .positive = true, | 3508 | .positive = true, |
| 3509 | }; | 3509 | }; |
| 3510 | try testing.expect(one.clz(@bitSizeOf(Limb)) == @bitSizeOf(Limb) - 1); | 3510 | try testing.expectEqual(@bitSizeOf(Limb) - 1, one.clz(@bitSizeOf(Limb))); |
| 3511 | try testing.expect(one.clz(@bitSizeOf(Limb) + 1) == @bitSizeOf(Limb)); | 3511 | try testing.expectEqual(@bitSizeOf(Limb), one.clz(@bitSizeOf(Limb) + 1)); |
| 3512 | try testing.expect(one.clz(@bitSizeOf(Limb) * 2 - 1) == @bitSizeOf(Limb) * 2 - 2); | 3512 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, one.clz(@bitSizeOf(Limb) * 2 - 1)); |
| 3513 | try testing.expect(one.clz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb) * 2 - 1); | 3513 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 1, one.clz(@bitSizeOf(Limb) * 2)); |
| 3514 | try testing.expect(one.clz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) * 2); | 3514 | try testing.expectEqual(@bitSizeOf(Limb) * 2, one.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3515 | | 3515 | |
| 3516 | const limb_msb: std.math.big.int.Const = .{ | 3516 | const limb_msb: std.math.big.int.Const = .{ |
| 3517 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, | 3517 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, |
| 3518 | .positive = true, | 3518 | .positive = true, |
| 3519 | }; | 3519 | }; |
| 3520 | try testing.expect(limb_msb.clz(@bitSizeOf(Limb)) == 0); | 3520 | try testing.expectEqual(0, limb_msb.clz(@bitSizeOf(Limb))); |
| 3521 | try testing.expect(limb_msb.clz(@bitSizeOf(Limb) + 1) == 1); | 3521 | try testing.expectEqual(1, limb_msb.clz(@bitSizeOf(Limb) + 1)); |
| 3522 | try testing.expect(limb_msb.clz(@bitSizeOf(Limb) * 2 - 1) == @bitSizeOf(Limb) - 1); | 3522 | try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.clz(@bitSizeOf(Limb) * 2 - 1)); |
| 3523 | try testing.expect(limb_msb.clz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb)); | 3523 | try testing.expectEqual(@bitSizeOf(Limb), limb_msb.clz(@bitSizeOf(Limb) * 2)); |
| 3524 | try testing.expect(limb_msb.clz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) + 1); | 3524 | try testing.expectEqual(@bitSizeOf(Limb) + 1, limb_msb.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3525 | | 3525 | |
| 3526 | const limb_max: std.math.big.int.Const = .{ | 3526 | const limb_max: std.math.big.int.Const = .{ |
| 3527 | .limbs = &.{maxInt(Limb)}, | 3527 | .limbs = &.{maxInt(Limb)}, |
| 3528 | .positive = true, | 3528 | .positive = true, |
| 3529 | }; | 3529 | }; |
| 3530 | try testing.expect(limb_max.clz(@bitSizeOf(Limb)) == 0); | 3530 | try testing.expectEqual(0, limb_max.clz(@bitSizeOf(Limb))); |
| 3531 | try testing.expect(limb_max.clz(@bitSizeOf(Limb) + 1) == 1); | 3531 | try testing.expectEqual(1, limb_max.clz(@bitSizeOf(Limb) + 1)); |
| 3532 | try testing.expect(limb_max.clz(@bitSizeOf(Limb) * 2 - 1) == @bitSizeOf(Limb) - 1); | 3532 | try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_max.clz(@bitSizeOf(Limb) * 2 - 1)); |
| 3533 | try testing.expect(limb_max.clz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb)); | 3533 | try testing.expectEqual(@bitSizeOf(Limb), limb_max.clz(@bitSizeOf(Limb) * 2)); |
| 3534 | try testing.expect(limb_max.clz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) + 1); | 3534 | try testing.expectEqual(@bitSizeOf(Limb) + 1, limb_max.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3535 | | 3535 | |
| 3536 | const limb_msb_squared: std.math.big.int.Const = .{ | 3536 | const limb_msb_squared: std.math.big.int.Const = .{ |
| 3537 | .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 }, | 3537 | .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 }, |
| 3538 | .positive = true, | 3538 | .positive = true, |
| 3539 | }; | 3539 | }; |
| 3540 | try testing.expect(limb_msb_squared.clz(@bitSizeOf(Limb) * 2 - 1) == 0); | 3540 | try testing.expectEqual(0, limb_msb_squared.clz(@bitSizeOf(Limb) * 2 - 1)); |
| 3541 | try testing.expect(limb_msb_squared.clz(@bitSizeOf(Limb) * 2) == 1); | 3541 | try testing.expectEqual(1, limb_msb_squared.clz(@bitSizeOf(Limb) * 2)); |
| 3542 | try testing.expect(limb_msb_squared.clz(@bitSizeOf(Limb) * 2 + 1) == 2); | 3542 | try testing.expectEqual(2, limb_msb_squared.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3543 | | 3543 | |
| 3544 | const limb_max_squared_minus_one: std.math.big.int.Const = .{ | 3544 | const limb_max_squared_minus_one: std.math.big.int.Const = .{ |
| 3545 | .limbs = &.{ 0, maxInt(Limb) - 1 }, | 3545 | .limbs = &.{ 0, maxInt(Limb) - 1 }, |
| 3546 | .positive = true, | 3546 | .positive = true, |
| 3547 | }; | 3547 | }; |
| 3548 | try testing.expect(limb_max_squared_minus_one.clz(@bitSizeOf(Limb) * 2) == 0); | 3548 | try testing.expectEqual(0, limb_max_squared_minus_one.clz(@bitSizeOf(Limb) * 2)); |
| 3549 | try testing.expect(limb_max_squared_minus_one.clz(@bitSizeOf(Limb) * 2 + 1) == 1); | 3549 | try testing.expectEqual(1, limb_max_squared_minus_one.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3550 | | 3550 | |
| 3551 | const limb_max_squared: std.math.big.int.Const = .{ | 3551 | const limb_max_squared: std.math.big.int.Const = .{ |
| 3552 | .limbs = &.{ 1, maxInt(Limb) - 1 }, | 3552 | .limbs = &.{ 1, maxInt(Limb) - 1 }, |
| 3553 | .positive = true, | 3553 | .positive = true, |
| 3554 | }; | 3554 | }; |
| 3555 | try testing.expect(limb_max_squared.clz(@bitSizeOf(Limb) * 2) == 0); | 3555 | try testing.expectEqual(0, limb_max_squared.clz(@bitSizeOf(Limb) * 2)); |
| 3556 | try testing.expect(limb_max_squared.clz(@bitSizeOf(Limb) * 2 + 1) == 1); | 3556 | try testing.expectEqual(1, limb_max_squared.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3557 | } | 3557 | } |
| 3558 | | 3558 | |
| 3559 | test "ctz" { | 3559 | test "ctz" { |
| ... | @@ -3561,109 +3561,109 @@ test "ctz" { | ... | @@ -3561,109 +3561,109 @@ test "ctz" { |
| 3561 | .limbs = &.{ 1, maxInt(Limb) - 1 }, | 3561 | .limbs = &.{ 1, maxInt(Limb) - 1 }, |
| 3562 | .positive = false, | 3562 | .positive = false, |
| 3563 | }; | 3563 | }; |
| 3564 | try testing.expect(neg_limb_max_squared.ctz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3564 | try testing.expectEqual(0, neg_limb_max_squared.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3565 | | 3565 | |
| 3566 | const neg_limb_max_squared_plus_one: std.math.big.int.Const = .{ | 3566 | const neg_limb_max_squared_plus_one: std.math.big.int.Const = .{ |
| 3567 | .limbs = &.{ 0, maxInt(Limb) - 1 }, | 3567 | .limbs = &.{ 0, maxInt(Limb) - 1 }, |
| 3568 | .positive = false, | 3568 | .positive = false, |
| 3569 | }; | 3569 | }; |
| 3570 | try testing.expect(neg_limb_max_squared_plus_one.ctz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) + 1); | 3570 | try testing.expectEqual(@bitSizeOf(Limb) + 1, neg_limb_max_squared_plus_one.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3571 | | 3571 | |
| 3572 | const neg_limb_msb_squared: std.math.big.int.Const = .{ | 3572 | const neg_limb_msb_squared: std.math.big.int.Const = .{ |
| 3573 | .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 }, | 3573 | .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 }, |
| 3574 | .positive = false, | 3574 | .positive = false, |
| 3575 | }; | 3575 | }; |
| 3576 | try testing.expect(neg_limb_msb_squared.ctz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb) * 2 - 2); | 3576 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, neg_limb_msb_squared.ctz(@bitSizeOf(Limb) * 2)); |
| 3577 | try testing.expect(neg_limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) * 2 - 2); | 3577 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, neg_limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3578 | | 3578 | |
| 3579 | const neg_limb_max: std.math.big.int.Const = .{ | 3579 | const neg_limb_max: std.math.big.int.Const = .{ |
| 3580 | .limbs = &.{maxInt(Limb)}, | 3580 | .limbs = &.{maxInt(Limb)}, |
| 3581 | .positive = false, | 3581 | .positive = false, |
| 3582 | }; | 3582 | }; |
| 3583 | try testing.expect(neg_limb_max.ctz(@bitSizeOf(Limb) + 1) == 0); | 3583 | try testing.expectEqual(0, neg_limb_max.ctz(@bitSizeOf(Limb) + 1)); |
| 3584 | try testing.expect(neg_limb_max.ctz(@bitSizeOf(Limb) * 2 - 1) == 0); | 3584 | try testing.expectEqual(0, neg_limb_max.ctz(@bitSizeOf(Limb) * 2 - 1)); |
| 3585 | try testing.expect(neg_limb_max.ctz(@bitSizeOf(Limb) * 2) == 0); | 3585 | try testing.expectEqual(0, neg_limb_max.ctz(@bitSizeOf(Limb) * 2)); |
| 3586 | try testing.expect(neg_limb_max.ctz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3586 | try testing.expectEqual(0, neg_limb_max.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3587 | | 3587 | |
| 3588 | const neg_limb_msb: std.math.big.int.Const = .{ | 3588 | const neg_limb_msb: std.math.big.int.Const = .{ |
| 3589 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, | 3589 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, |
| 3590 | .positive = false, | 3590 | .positive = false, |
| 3591 | }; | 3591 | }; |
| 3592 | try testing.expect(neg_limb_msb.ctz(@bitSizeOf(Limb)) == @bitSizeOf(Limb) - 1); | 3592 | try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb))); |
| 3593 | try testing.expect(neg_limb_msb.ctz(@bitSizeOf(Limb) + 1) == @bitSizeOf(Limb) - 1); | 3593 | try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb) + 1)); |
| 3594 | try testing.expect(neg_limb_msb.ctz(@bitSizeOf(Limb) * 2 - 1) == @bitSizeOf(Limb) - 1); | 3594 | try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb) * 2 - 1)); |
| 3595 | try testing.expect(neg_limb_msb.ctz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb) - 1); | 3595 | try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb) * 2)); |
| 3596 | try testing.expect(neg_limb_msb.ctz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) - 1); | 3596 | try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3597 | | 3597 | |
| 3598 | const neg_one: std.math.big.int.Const = .{ | 3598 | const neg_one: std.math.big.int.Const = .{ |
| 3599 | .limbs = &.{1}, | 3599 | .limbs = &.{1}, |
| 3600 | .positive = false, | 3600 | .positive = false, |
| 3601 | }; | 3601 | }; |
| 3602 | try testing.expect(neg_one.ctz(@bitSizeOf(Limb)) == 0); | 3602 | try testing.expectEqual(0, neg_one.ctz(@bitSizeOf(Limb))); |
| 3603 | try testing.expect(neg_one.ctz(@bitSizeOf(Limb) + 1) == 0); | 3603 | try testing.expectEqual(0, neg_one.ctz(@bitSizeOf(Limb) + 1)); |
| 3604 | try testing.expect(neg_one.ctz(@bitSizeOf(Limb) * 2 - 1) == 0); | 3604 | try testing.expectEqual(0, neg_one.ctz(@bitSizeOf(Limb) * 2 - 1)); |
| 3605 | try testing.expect(neg_one.ctz(@bitSizeOf(Limb) * 2) == 0); | 3605 | try testing.expectEqual(0, neg_one.ctz(@bitSizeOf(Limb) * 2)); |
| 3606 | try testing.expect(neg_one.ctz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3606 | try testing.expectEqual(0, neg_one.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3607 | | 3607 | |
| 3608 | const zero: std.math.big.int.Const = .{ | 3608 | const zero: std.math.big.int.Const = .{ |
| 3609 | .limbs = &.{0}, | 3609 | .limbs = &.{0}, |
| 3610 | .positive = true, | 3610 | .positive = true, |
| 3611 | }; | 3611 | }; |
| 3612 | try testing.expect(zero.ctz(@bitSizeOf(Limb)) == @bitSizeOf(Limb)); | 3612 | try testing.expectEqual(@bitSizeOf(Limb), zero.ctz(@bitSizeOf(Limb))); |
| 3613 | try testing.expect(zero.ctz(@bitSizeOf(Limb) + 1) == @bitSizeOf(Limb) + 1); | 3613 | try testing.expectEqual(@bitSizeOf(Limb) + 1, zero.ctz(@bitSizeOf(Limb) + 1)); |
| 3614 | try testing.expect(zero.ctz(@bitSizeOf(Limb) * 2 - 1) == @bitSizeOf(Limb) * 2 - 1); | 3614 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 1, zero.ctz(@bitSizeOf(Limb) * 2 - 1)); |
| 3615 | try testing.expect(zero.ctz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb) * 2); | 3615 | try testing.expectEqual(@bitSizeOf(Limb) * 2, zero.ctz(@bitSizeOf(Limb) * 2)); |
| 3616 | try testing.expect(zero.ctz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) * 2 + 1); | 3616 | try testing.expectEqual(@bitSizeOf(Limb) * 2 + 1, zero.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3617 | | 3617 | |
| 3618 | const one: std.math.big.int.Const = .{ | 3618 | const one: std.math.big.int.Const = .{ |
| 3619 | .limbs = &.{1}, | 3619 | .limbs = &.{1}, |
| 3620 | .positive = true, | 3620 | .positive = true, |
| 3621 | }; | 3621 | }; |
| 3622 | try testing.expect(one.ctz(@bitSizeOf(Limb)) == 0); | 3622 | try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb))); |
| 3623 | try testing.expect(one.ctz(@bitSizeOf(Limb) + 1) == 0); | 3623 | try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb) + 1)); |
| 3624 | try testing.expect(one.ctz(@bitSizeOf(Limb) * 2 - 1) == 0); | 3624 | try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb) * 2 - 1)); |
| 3625 | try testing.expect(one.ctz(@bitSizeOf(Limb) * 2) == 0); | 3625 | try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb) * 2)); |
| 3626 | try testing.expect(one.ctz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3626 | try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3627 | | 3627 | |
| 3628 | const limb_msb: std.math.big.int.Const = .{ | 3628 | const limb_msb: std.math.big.int.Const = .{ |
| 3629 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, | 3629 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, |
| 3630 | .positive = true, | 3630 | .positive = true, |
| 3631 | }; | 3631 | }; |
| 3632 | try testing.expect(limb_msb.ctz(@bitSizeOf(Limb)) == @bitSizeOf(Limb) - 1); | 3632 | try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb))); |
| 3633 | try testing.expect(limb_msb.ctz(@bitSizeOf(Limb) + 1) == @bitSizeOf(Limb) - 1); | 3633 | try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb) + 1)); |
| 3634 | try testing.expect(limb_msb.ctz(@bitSizeOf(Limb) * 2 - 1) == @bitSizeOf(Limb) - 1); | 3634 | try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb) * 2 - 1)); |
| 3635 | try testing.expect(limb_msb.ctz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb) - 1); | 3635 | try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb) * 2)); |
| 3636 | try testing.expect(limb_msb.ctz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) - 1); | 3636 | try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3637 | | 3637 | |
| 3638 | const limb_max: std.math.big.int.Const = .{ | 3638 | const limb_max: std.math.big.int.Const = .{ |
| 3639 | .limbs = &.{maxInt(Limb)}, | 3639 | .limbs = &.{maxInt(Limb)}, |
| 3640 | .positive = true, | 3640 | .positive = true, |
| 3641 | }; | 3641 | }; |
| 3642 | try testing.expect(limb_max.ctz(@bitSizeOf(Limb)) == 0); | 3642 | try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb))); |
| 3643 | try testing.expect(limb_max.ctz(@bitSizeOf(Limb) + 1) == 0); | 3643 | try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb) + 1)); |
| 3644 | try testing.expect(limb_max.ctz(@bitSizeOf(Limb) * 2 - 1) == 0); | 3644 | try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb) * 2 - 1)); |
| 3645 | try testing.expect(limb_max.ctz(@bitSizeOf(Limb) * 2) == 0); | 3645 | try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb) * 2)); |
| 3646 | try testing.expect(limb_max.ctz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3646 | try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3647 | | 3647 | |
| 3648 | const limb_msb_squared: std.math.big.int.Const = .{ | 3648 | const limb_msb_squared: std.math.big.int.Const = .{ |
| 3649 | .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 }, | 3649 | .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 }, |
| 3650 | .positive = true, | 3650 | .positive = true, |
| 3651 | }; | 3651 | }; |
| 3652 | try testing.expect(limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 - 1) == @bitSizeOf(Limb) * 2 - 2); | 3652 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 - 1)); |
| 3653 | try testing.expect(limb_msb_squared.ctz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb) * 2 - 2); | 3653 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, limb_msb_squared.ctz(@bitSizeOf(Limb) * 2)); |
| 3654 | try testing.expect(limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) * 2 - 2); | 3654 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3655 | | 3655 | |
| 3656 | const limb_max_squared_minus_one: std.math.big.int.Const = .{ | 3656 | const limb_max_squared_minus_one: std.math.big.int.Const = .{ |
| 3657 | .limbs = &.{ 0, maxInt(Limb) - 1 }, | 3657 | .limbs = &.{ 0, maxInt(Limb) - 1 }, |
| 3658 | .positive = true, | 3658 | .positive = true, |
| 3659 | }; | 3659 | }; |
| 3660 | try testing.expect(limb_max_squared_minus_one.ctz(@bitSizeOf(Limb) * 2) == @bitSizeOf(Limb) + 1); | 3660 | try testing.expectEqual(@bitSizeOf(Limb) + 1, limb_max_squared_minus_one.ctz(@bitSizeOf(Limb) * 2)); |
| 3661 | try testing.expect(limb_max_squared_minus_one.ctz(@bitSizeOf(Limb) * 2 + 1) == @bitSizeOf(Limb) + 1); | 3661 | try testing.expectEqual(@bitSizeOf(Limb) + 1, limb_max_squared_minus_one.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3662 | | 3662 | |
| 3663 | const limb_max_squared: std.math.big.int.Const = .{ | 3663 | const limb_max_squared: std.math.big.int.Const = .{ |
| 3664 | .limbs = &.{ 1, maxInt(Limb) - 1 }, | 3664 | .limbs = &.{ 1, maxInt(Limb) - 1 }, |
| 3665 | .positive = true, | 3665 | .positive = true, |
| 3666 | }; | 3666 | }; |
| 3667 | try testing.expect(limb_max_squared.ctz(@bitSizeOf(Limb) * 2) == 0); | 3667 | try testing.expectEqual(0, limb_max_squared.ctz(@bitSizeOf(Limb) * 2)); |
| 3668 | try testing.expect(limb_max_squared.ctz(@bitSizeOf(Limb) * 2 + 1) == 0); | 3668 | try testing.expectEqual(0, limb_max_squared.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3669 | } | 3669 | } |