2018-06-13 11:25:04 +01:00
|
|
|
const __divti3 = @import("divti3.zig").__divti3;
|
2019-02-08 23:18:47 +00:00
|
|
|
const testing = @import("std").testing;
|
2018-06-13 11:25:04 +01:00
|
|
|
|
2021-05-06 07:32:29 +01:00
|
|
|
fn test__divti3(a: i128, b: i128, expected: i128) !void {
|
2018-06-13 11:25:04 +01:00
|
|
|
const x = __divti3(a, b);
|
2021-05-04 18:47:26 +01:00
|
|
|
try testing.expect(x == expected);
|
2018-06-13 11:25:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
test "divti3" {
|
2021-05-06 07:32:29 +01:00
|
|
|
try test__divti3(0, 1, 0);
|
|
|
|
try test__divti3(0, -1, 0);
|
|
|
|
try test__divti3(2, 1, 2);
|
|
|
|
try test__divti3(2, -1, -2);
|
|
|
|
try test__divti3(-2, 1, -2);
|
|
|
|
try test__divti3(-2, -1, 2);
|
2018-06-13 11:25:04 +01:00
|
|
|
|
2021-05-06 07:32:29 +01:00
|
|
|
try test__divti3(@bitCast(i128, @as(u128, 0x8 << 124)), 1, @bitCast(i128, @as(u128, 0x8 << 124)));
|
|
|
|
try test__divti3(@bitCast(i128, @as(u128, 0x8 << 124)), -1, @bitCast(i128, @as(u128, 0x8 << 124)));
|
|
|
|
try test__divti3(@bitCast(i128, @as(u128, 0x8 << 124)), -2, @bitCast(i128, @as(u128, 0x4 << 124)));
|
|
|
|
try test__divti3(@bitCast(i128, @as(u128, 0x8 << 124)), 2, @bitCast(i128, @as(u128, 0xc << 124)));
|
2018-06-13 11:25:04 +01:00
|
|
|
}
|