From 6af39aa49afeb3498d6c5dfa0b60a0fdc15ca47c Mon Sep 17 00:00:00 2001 From: data-man Date: Sun, 22 Dec 2019 06:37:25 +0500 Subject: [PATCH] Fixes #3966 --- lib/std/testing.zig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 437c12ee8b..7a261e0751 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -165,7 +165,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const } var i: usize = 0; while (i < expected.len) : (i += 1) { - if (expected[i] != actual[i]) { + if (!std.meta.eql(expected[i], actual[i])) { std.debug.panic("index {} incorrect. expected {}, found {}", .{ i, expected[i], actual[i] }); } } @@ -176,3 +176,17 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const pub fn expect(ok: bool) void { if (!ok) @panic("test failure"); } + +test "expectEqual nested array" { + const a = [2][2]f32{ + [_]f32{ 1.0, 0.0 }, + [_]f32{ 0.0, 1.0 }, + }; + + const b = [2][2]f32{ + [_]f32{ 1.0, 0.0 }, + [_]f32{ 0.0, 1.0 }, + }; + + expectEqual(a, b); +}