master
1const negv = @import("negv.zig");
2const testing = @import("std").testing;
3
4fn test__negvdi2(a: i64, expected: i64) !void {
5 const result = negv.__negvdi2(a);
6 try testing.expectEqual(expected, result);
7}
8
9test "negvdi2" {
10 // -2^63 <= i64 <= 2^63-1
11 // 2^63 = 9223372036854775808
12 // 2^63-1 = 9223372036854775807
13 // TODO write panic handler for testing panics
14 //try test__negvdi2(-9223372036854775808, -5); // tested with return -5; and panic
15 try test__negvdi2(-9223372036854775807, 9223372036854775807);
16 try test__negvdi2(-9223372036854775806, 9223372036854775806);
17 try test__negvdi2(-9223372036854775805, 9223372036854775805);
18 try test__negvdi2(-9223372036854775804, 9223372036854775804);
19 try test__negvdi2(-42, 42);
20 try test__negvdi2(-7, 7);
21 try test__negvdi2(-1, 1);
22 try test__negvdi2(0, 0);
23 try test__negvdi2(1, -1);
24 try test__negvdi2(7, -7);
25 try test__negvdi2(42, -42);
26 try test__negvdi2(9223372036854775804, -9223372036854775804);
27 try test__negvdi2(9223372036854775805, -9223372036854775805);
28 try test__negvdi2(9223372036854775806, -9223372036854775806);
29 try test__negvdi2(9223372036854775807, -9223372036854775807);
30}