test_wraparound_semantics.zig (358B) - Raw
1 const std = @import("std"); 2 const expect = std.testing.expect; 3 const minInt = std.math.minInt; 4 const maxInt = std.math.maxInt; 5 6 test "wraparound addition and subtraction" { 7 const x: i32 = maxInt(i32); 8 const min_val = x +% 1; 9 try expect(min_val == minInt(i32)); 10 const max_val = min_val -% 1; 11 try expect(max_val == maxInt(i32)); 12 } 13 14 // test