aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJimmi Holst Christensen <jhc@liab.dk>2018-01-17 14:31:47 +0100
committerJimmi Holst Christensen <jhc@liab.dk>2018-01-17 14:31:47 +0100
commitfa2c3be341ac6a7eddc65397984dac1bf648be26 (patch)
treef389038e0324fad415aa6a80096ebb5328f86950 /test
parentdb0fc32ab2d5277655a87200be8f602473ed30d2 (diff)
downloadzig-fa2c3be341ac6a7eddc65397984dac1bf648be26.tar.gz
zig-fa2c3be341ac6a7eddc65397984dac1bf648be26.zip
More tests, and fixed none negative bigint xor
Diffstat (limited to 'test')
-rw-r--r--test/cases/math.zig30
1 files changed, 24 insertions, 6 deletions
diff --git a/test/cases/math.zig b/test/cases/math.zig
index 7f57838ecb..91fb52d217 100644
--- a/test/cases/math.zig
+++ b/test/cases/math.zig
@@ -349,6 +349,29 @@ test "big number shifting" {
}
}
+test "xor" {
+ test_xor();
+ comptime test_xor();
+}
+
+fn test_xor() {
+ assert(0xFF ^ 0x00 == 0xFF);
+ assert(0xF0 ^ 0x0F == 0xFF);
+ assert(0xFF ^ 0xF0 == 0x0F);
+ assert(0xFF ^ 0x0F == 0xF0);
+ assert(0xFF ^ 0xFF == 0x00);
+}
+
+test "big number xor" {
+ comptime {
+ assert(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ^ 0x00000000000000000000000000000000 == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
+ assert(0xFFFFFFFFFFFFFFFF0000000000000000 ^ 0x0000000000000000FFFFFFFFFFFFFFFF == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
+ assert(0xFFFFFFFFFFFFFFFF0000000000000000 ^ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF == 0x0000000000000000FFFFFFFFFFFFFFFF);
+ assert(0x0000000000000000FFFFFFFFFFFFFFFF ^ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF == 0xFFFFFFFFFFFFFFFF0000000000000000);
+ assert(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ^ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF == 0x00000000000000000000000000000000);
+ }
+}
+
test "f128" {
test_f128();
comptime test_f128();
@@ -368,9 +391,4 @@ fn test_f128() {
fn should_not_be_zero(x: f128) {
assert(x != 0.0);
-}
-
-test "xor with zero" {
- assert(0xFF ^ 0x00 == 0xFF);
- comptime assert(0xFF ^ 0x00 == 0xFF);
-}
+} \ No newline at end of file