diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-01-05 03:57:48 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-01-05 03:57:48 -0500 |
| commit | 3b5e26b7f7e4b37cf9357d058f32c0ad08ed7338 (patch) | |
| tree | 3e62f38dbdee624eb7ac8780e8f2735b3945484d /test/cases/array.zig | |
| parent | ee09eb7f5461aa9e2374a6adbfbf130bfc0ebf21 (diff) | |
| download | zig-3b5e26b7f7e4b37cf9357d058f32c0ad08ed7338.tar.gz zig-3b5e26b7f7e4b37cf9357d058f32c0ad08ed7338.zip | |
self hosted tests import std library
Diffstat (limited to 'test/cases/array.zig')
| -rw-r--r-- | test/cases/array.zig | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/test/cases/array.zig b/test/cases/array.zig index 7839db9bb9..f29d36b680 100644 --- a/test/cases/array.zig +++ b/test/cases/array.zig @@ -1,3 +1,6 @@ +const assert = @import("std").debug.assert; +const str = @import("std").str; + fn arrays() { @setFnTest(this); @@ -60,32 +63,10 @@ fn nestedArrays() { const array_of_strings = [][]u8 {"hello", "this", "is", "my", "thing"}; for (array_of_strings) |s, i| { - if (i == 0) assert(memeql(s, "hello")); - if (i == 1) assert(memeql(s, "this")); - if (i == 2) assert(memeql(s, "is")); - if (i == 3) assert(memeql(s, "my")); - if (i == 4) assert(memeql(s, "thing")); - } -} - - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - -// TODO import from std.str -pub fn memeql(a: []const u8, b: []const u8) -> bool { - sliceEql(u8, a, b) -} - -// TODO import from std.str -pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool { - if (a.len != b.len) return false; - for (a) |item, index| { - if (b[index] != item) return false; + if (i == 0) assert(str.eql(s, "hello")); + if (i == 1) assert(str.eql(s, "this")); + if (i == 2) assert(str.eql(s, "is")); + if (i == 3) assert(str.eql(s, "my")); + if (i == 4) assert(str.eql(s, "thing")); } - return true; } |
