mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
14 lines
358 B
Zig
14 lines
358 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
const minInt = std.math.minInt;
|
|
const maxInt = std.math.maxInt;
|
|
|
|
test "wraparound addition and subtraction" {
|
|
const x: i32 = maxInt(i32);
|
|
const min_val = x +% 1;
|
|
try expect(min_val == minInt(i32));
|
|
const max_val = min_val -% 1;
|
|
try expect(max_val == maxInt(i32));
|
|
}
|
|
|
|
// test
|