aboutsummaryrefslogtreecommitdiff
path: root/lib/compiler_rt/absvdi2_test.zig
blob: e861ef0ff3372c1058f99d75c9e7fa2b15f33e7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const testing = @import("std").testing;

const __absvdi2 = @import("absvdi2.zig").__absvdi2;

fn test__absvdi2(a: i64, expected: i64) !void {
    var result = __absvdi2(a);
    try testing.expectEqual(expected, result);
}

test "absvdi2" {
    // -2^63 <= i64 <= 2^63-1
    // 2^63 = 9223372036854775808
    // 2^63-1 = 9223372036854775807
    // TODO write panic handler for testing panics
    //try test__absvdi2(-9223372036854775808, -5); // tested with return -5; and panic
    try test__absvdi2(-9223372036854775807, 9223372036854775807);
    try test__absvdi2(-9223372036854775806, 9223372036854775806);
    try test__absvdi2(-9223372036854775805, 9223372036854775805);
    try test__absvdi2(-9223372036854775804, 9223372036854775804);
    try test__absvdi2(-42, 42);
    try test__absvdi2(-7, 7);
    try test__absvdi2(-1, 1);
    try test__absvdi2(0, 0);
    try test__absvdi2(1, 1);
    try test__absvdi2(7, 7);
    try test__absvdi2(42, 42);
    try test__absvdi2(9223372036854775804, 9223372036854775804);
    try test__absvdi2(9223372036854775805, 9223372036854775805);
    try test__absvdi2(9223372036854775806, 9223372036854775806);
    try test__absvdi2(9223372036854775807, 9223372036854775807);
}