aboutsummaryrefslogtreecommitdiff
path: root/lib/std/special/compiler_rt/divti3_test.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/special/compiler_rt/divti3_test.zig')
-rw-r--r--lib/std/special/compiler_rt/divti3_test.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/std/special/compiler_rt/divti3_test.zig b/lib/std/special/compiler_rt/divti3_test.zig
new file mode 100644
index 0000000000..e1c1babae7
--- /dev/null
+++ b/lib/std/special/compiler_rt/divti3_test.zig
@@ -0,0 +1,21 @@
+const __divti3 = @import("divti3.zig").__divti3;
+const testing = @import("std").testing;
+
+fn test__divti3(a: i128, b: i128, expected: i128) void {
+ const x = __divti3(a, b);
+ testing.expect(x == expected);
+}
+
+test "divti3" {
+ test__divti3(0, 1, 0);
+ test__divti3(0, -1, 0);
+ test__divti3(2, 1, 2);
+ test__divti3(2, -1, -2);
+ test__divti3(-2, 1, -2);
+ test__divti3(-2, -1, 2);
+
+ test__divti3(@bitCast(i128, u128(0x8 << 124)), 1, @bitCast(i128, u128(0x8 << 124)));
+ test__divti3(@bitCast(i128, u128(0x8 << 124)), -1, @bitCast(i128, u128(0x8 << 124)));
+ test__divti3(@bitCast(i128, u128(0x8 << 124)), -2, @bitCast(i128, u128(0x4 << 124)));
+ test__divti3(@bitCast(i128, u128(0x8 << 124)), 2, @bitCast(i128, u128(0xc << 124)));
+}