| 1 | const std = @import("std"); |
| 2 | const expectEqual = std.testing.expectEqual; |
| 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 expectEqual(minInt(i32), min_val); |
| 10 | const max_val = min_val -% 1; |
| 11 | try expectEqual(maxInt(i32), max_val); |
| 12 | } |
| 13 | |
| 14 | // test |