2016-05-17 13:32:43 -07:00
|
|
|
const assert = @import("debug.zig").assert;
|
2016-04-18 16:42:56 -07:00
|
|
|
|
2016-07-24 18:35:50 -07:00
|
|
|
pub fn eql(a: []const u8, b: []const u8) -> bool {
|
2016-08-16 22:42:50 -07:00
|
|
|
sliceEql(u8, a, b)
|
2016-07-24 18:35:50 -07:00
|
|
|
}
|
2016-04-18 16:42:56 -07:00
|
|
|
|
2016-08-16 22:42:50 -07:00
|
|
|
pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool {
|
2016-04-18 16:42:56 -07:00
|
|
|
if (a.len != b.len) return false;
|
|
|
|
for (a) |item, index| {
|
|
|
|
if (b[index] != item) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-27 23:33:32 -07:00
|
|
|
fn testStringEquality() {
|
2016-12-31 14:10:29 -08:00
|
|
|
@setFnTest(this);
|
2016-09-27 23:33:32 -07:00
|
|
|
|
2016-04-18 16:42:56 -07:00
|
|
|
assert(eql("abcd", "abcd"));
|
|
|
|
assert(!eql("abcdef", "abZdef"));
|
|
|
|
assert(!eql("abcdefg", "abcdef"));
|
|
|
|
}
|