diff options
| author | data-man <datamanrb@gmail.com> | 2020-01-07 19:14:37 +0500 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2020-02-13 12:13:55 +0100 |
| commit | 4578d13b49d16463b870119005877f7b6e10092e (patch) | |
| tree | 11279ba404a894022ebc08f401bea6fff89e347c /lib/std/testing.zig | |
| parent | 55304128c086989ad4c08e51c7708d61d544e820 (diff) | |
| download | zig-4578d13b49d16463b870119005877f7b6e10092e.tar.gz zig-4578d13b49d16463b870119005877f7b6e10092e.zip | |
Vector comparison in meta and testing
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index f8247b5a9d..8a4491d1d7 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -56,7 +56,6 @@ pub fn expectEqual(expected: var, actual: @TypeOf(expected)) void { .EnumLiteral, .Enum, .Fn, - .Vector, .ErrorSet, => { if (actual != expected) { @@ -88,6 +87,15 @@ pub fn expectEqual(expected: var, actual: @TypeOf(expected)) void { .Array => |array| expectEqualSlices(array.child, &expected, &actual), + .Vector => |vectorType| { + var i: usize = 0; + while (i < vectorType.len) : (i += 1) { + if (!std.meta.eql(expected[i], actual[i])) { + std.debug.panic("index {} incorrect. expected {}, found {}", .{ i, expected[i], actual[i] }); + } + } + }, + .Struct => |structType| { inline for (structType.fields) |field| { expectEqual(@field(expected, field.name), @field(actual, field.name)); @@ -202,3 +210,10 @@ test "expectEqual nested array" { expectEqual(a, b); } + +test "expectEqual vector" { + var a = @splat(4, @as(u32, 4)); + var b = @splat(4, @as(u32, 4)); + + expectEqual(a, b); +} |
