zig/lib/compiler_rt/absvsi2_test.zig
Andrew Kelley ec95e00e28 flatten lib/std/special and improve "pkg inside another" logic
stage2: change logic for detecting whether the main package is inside
the std package. Previously it relied on realpath() which is not portable.
This uses resolve() which is how imports already work.

 * stage2: fix cleanup bug when creating Module
 * flatten lib/std/special/* to lib/*
   - this was motivated by making main_pkg_is_inside_std false for
     compiler_rt & friends.
 * rename "mini libc" to "universal libc"
2022-05-06 22:41:00 -07:00

31 lines
1.0 KiB
Zig

const absv = @import("absv.zig");
const testing = @import("std").testing;
fn test__absvsi2(a: i32, expected: i32) !void {
var result = absv.__absvsi2(a);
try testing.expectEqual(expected, result);
}
test "absvsi2" {
// -2^31 <= i32 <= 2^31-1
// 2^31 = 2147483648
// 2^31-1 = 2147483647
// TODO write panic handler for testing panics
//try test__absvsi2(-2147483648, -5); // tested with return -5; and panic
try test__absvsi2(-2147483647, 2147483647);
try test__absvsi2(-2147483646, 2147483646);
try test__absvsi2(-2147483645, 2147483645);
try test__absvsi2(-2147483644, 2147483644);
try test__absvsi2(-42, 42);
try test__absvsi2(-7, 7);
try test__absvsi2(-1, 1);
try test__absvsi2(0, 0);
try test__absvsi2(1, 1);
try test__absvsi2(7, 7);
try test__absvsi2(42, 42);
try test__absvsi2(2147483644, 2147483644);
try test__absvsi2(2147483645, 2147483645);
try test__absvsi2(2147483646, 2147483646);
try test__absvsi2(2147483647, 2147483647);
}