Commit 50310cf9df

Andrew Kelley <superjoe30@gmail.com>
2016-05-15 09:42:48
add 64 bit division test
1 parent 7f90dbb
Changed files (1)
test/self_hosted.zig
@@ -1670,3 +1670,22 @@ const some_namespace = switch(@compile_var("os")) {
     linux => @import("a.zig"),
     else => @import("b.zig"),
 };
+
+
+#attribute("test")
+fn unsigned_64_bit_division() {
+    const result = div(1152921504606846976, 34359738365);
+    assert(result.quotient == 33554432);
+    assert(result.remainder == 100663296);
+}
+#static_eval_enable(false)
+fn div(a: u64, b: u64) -> DivResult {
+    DivResult {
+        .quotient = a / b,
+        .remainder = a % b,
+    }
+}
+struct DivResult {
+    quotient: u64,
+    remainder: u64,
+}