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