authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-01 22:20:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-08 19:37:29-07:00
log126c9a34afea06437d0be5d748f1ccd8f7eda4b9
tree22a5db8670c180f6bcea93c8feacfe394e010a71
parent08cecc1c7e453042123f8ec6a240a49cbf3b165a

restructure unit test to be easier to debug


1 files changed, 19 insertions(+), 21 deletions(-)

lib/std/math/big/int_test.zig+19-21
......@@ -288,31 +288,29 @@ test "string set bad base error" {
288288}
289289
290290test "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}
301300
302 inline for (test_types) |T| {
303 const int_info = @typeInfo(T).Int;
301fn testTwosComplementLimit(comptime T: type) !void {
302 const int_info = @typeInfo(T).Int;
304303
305 var a = try Managed.init(testing.allocator);
306 defer a.deinit();
304 var a = try Managed.init(testing.allocator);
305 defer a.deinit();
307306
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));
311310
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));
316314}
317315
318316test "string to" {