| ... | @@ -288,31 +288,29 @@ test "string set bad base error" { | ... | @@ -288,31 +288,29 @@ test "string set bad base error" { |
| 288 | } | 288 | } |
| 289 | | 289 | |
| 290 | test "twos complement limit set" { | 290 | test "twos complement limit set" { |
| 291 | const test_types = [_]type{ | 291 | try testTwosComplementLimit(u64); |
| 292 | u64, | 292 | try testTwosComplementLimit(i64); |
| 293 | i64, | 293 | try testTwosComplementLimit(u1); |
| 294 | u1, | 294 | try testTwosComplementLimit(i1); |
| 295 | i1, | 295 | try testTwosComplementLimit(u0); |
| 296 | u0, | 296 | try testTwosComplementLimit(i0); |
| 297 | i0, | 297 | try testTwosComplementLimit(u65); |
| 298 | u65, | 298 | try testTwosComplementLimit(i65); |
| 299 | i65, | 299 | } |
| 300 | }; | | |
| 301 | | 300 | |
| 302 | inline for (test_types) |T| { | 301 | fn testTwosComplementLimit(comptime T: type) !void { |
| 303 | const int_info = @typeInfo(T).Int; | 302 | const int_info = @typeInfo(T).Int; |
| 304 | | 303 | |
| 305 | var a = try Managed.init(testing.allocator); | 304 | var a = try Managed.init(testing.allocator); |
| 306 | defer a.deinit(); | 305 | defer a.deinit(); |
| 307 | | 306 | |
| 308 | try a.setTwosCompIntLimit(.max, int_info.signedness, int_info.bits); | 307 | try a.setTwosCompIntLimit(.max, int_info.signedness, int_info.bits); |
| 309 | const max: T = maxInt(T); | 308 | const max: T = maxInt(T); |
| 310 | try testing.expect(max == try a.to(T)); | 309 | try testing.expect(max == try a.to(T)); |
| 311 | | 310 | |
| 312 | try a.setTwosCompIntLimit(.min, int_info.signedness, int_info.bits); | 311 | try a.setTwosCompIntLimit(.min, int_info.signedness, int_info.bits); |
| 313 | const min: T = minInt(T); | 312 | const min: T = minInt(T); |
| 314 | try testing.expect(min == try a.to(T)); | 313 | try testing.expect(min == try a.to(T)); |
| 315 | } | | |
| 316 | } | 314 | } |
| 317 | | 315 | |
| 318 | test "string to" { | 316 | test "string to" { |