Commit 85869f8225

Carl Åstholm <carl@astholm.se>
2024-01-01 17:37:32
Correct expected/actual parameter order of some assertions
1 parent d7b3650
Changed files (4)
lib/std/mem.zig
@@ -3284,9 +3284,9 @@ pub fn indexOfMinMax(comptime T: type, slice: []const T) IndexOfMinMaxResult {
 pub const IndexOfMinMaxResult = struct { index_min: usize, index_max: usize };
 
 test "indexOfMinMax" {
-    try testing.expectEqual(indexOfMinMax(u8, "abcdefg"), IndexOfMinMaxResult{ .index_min = 0, .index_max = 6 });
-    try testing.expectEqual(indexOfMinMax(u8, "gabcdef"), IndexOfMinMaxResult{ .index_min = 1, .index_max = 0 });
-    try testing.expectEqual(indexOfMinMax(u8, "a"), IndexOfMinMaxResult{ .index_min = 0, .index_max = 0 });
+    try testing.expectEqual(IndexOfMinMaxResult{ .index_min = 0, .index_max = 6 }, indexOfMinMax(u8, "abcdefg"));
+    try testing.expectEqual(IndexOfMinMaxResult{ .index_min = 1, .index_max = 0 }, indexOfMinMax(u8, "gabcdef"));
+    try testing.expectEqual(IndexOfMinMaxResult{ .index_min = 0, .index_max = 0 }, indexOfMinMax(u8, "a"));
 }
 
 pub fn swap(comptime T: type, a: *T, b: *T) void {
lib/std/multi_array_list.zig
@@ -842,24 +842,24 @@ test "union" {
         &.{ .a, .b, .b, .a, .a, .a, .a, .a, .a },
         list.items(.tags),
     );
-    try testing.expectEqual(list.get(0), Foo{ .a = 1 });
-    try testing.expectEqual(list.get(1), Foo{ .b = "zigzag" });
-    try testing.expectEqual(list.get(2), Foo{ .b = "foobar" });
-    try testing.expectEqual(list.get(3), Foo{ .a = 4 });
-    try testing.expectEqual(list.get(4), Foo{ .a = 5 });
-    try testing.expectEqual(list.get(5), Foo{ .a = 6 });
-    try testing.expectEqual(list.get(6), Foo{ .a = 7 });
-    try testing.expectEqual(list.get(7), Foo{ .a = 8 });
-    try testing.expectEqual(list.get(8), Foo{ .a = 9 });
+    try testing.expectEqual(Foo{ .a = 1 }, list.get(0));
+    try testing.expectEqual(Foo{ .b = "zigzag" }, list.get(1));
+    try testing.expectEqual(Foo{ .b = "foobar" }, list.get(2));
+    try testing.expectEqual(Foo{ .a = 4 }, list.get(3));
+    try testing.expectEqual(Foo{ .a = 5 }, list.get(4));
+    try testing.expectEqual(Foo{ .a = 6 }, list.get(5));
+    try testing.expectEqual(Foo{ .a = 7 }, list.get(6));
+    try testing.expectEqual(Foo{ .a = 8 }, list.get(7));
+    try testing.expectEqual(Foo{ .a = 9 }, list.get(8));
 
     list.shrinkAndFree(ally, 3);
 
     try testing.expectEqual(@as(usize, 3), list.items(.tags).len);
     try testing.expectEqualSlices(meta.Tag(Foo), list.items(.tags), &.{ .a, .b, .b });
 
-    try testing.expectEqual(list.get(0), Foo{ .a = 1 });
-    try testing.expectEqual(list.get(1), Foo{ .b = "zigzag" });
-    try testing.expectEqual(list.get(2), Foo{ .b = "foobar" });
+    try testing.expectEqual(Foo{ .a = 1 }, list.get(0));
+    try testing.expectEqual(Foo{ .b = "zigzag" }, list.get(1));
+    try testing.expectEqual(Foo{ .b = "foobar" }, list.get(2));
 }
 
 test "sorting a span" {
test/behavior/cast.zig
@@ -1156,7 +1156,7 @@ test "cast function with an opaque parameter" {
         .func = @ptrCast(&Foo.funcImpl),
     };
     c.func(c.ctx);
-    try std.testing.expectEqual(foo, Foo{ .x = 101, .y = 201 });
+    try std.testing.expectEqual(Foo{ .x = 101, .y = 201 }, foo);
 }
 
 test "implicit ptr to *anyopaque" {
test/c_abi/main.zig
@@ -946,7 +946,7 @@ test "DC: C returns to Zig" {
     if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
     if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
     if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
-    try expectEqual(c_ret_DC(), DC{ .v1 = -0.25, .v2 = 15 });
+    try expectEqual(DC{ .v1 = -0.25, .v2 = 15 }, c_ret_DC());
 }
 
 pub extern fn c_assert_DC(lv: DC) c_int;
@@ -998,7 +998,7 @@ test "CFF: C returns to Zig" {
     if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
     if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
     if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
-    try expectEqual(c_ret_CFF(), CFF{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 });
+    try expectEqual(CFF{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }, c_ret_CFF());
 }
 pub extern fn c_assert_CFF(lv: CFF) c_int;
 pub extern fn c_assert_ret_CFF() c_int;
@@ -1045,7 +1045,7 @@ test "PD: C returns to Zig" {
     if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
     if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
     if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
-    try expectEqual(c_ret_PD(), PD{ .v1 = null, .v2 = 0.5 });
+    try expectEqual(PD{ .v1 = null, .v2 = 0.5 }, c_ret_PD());
 }
 pub extern fn c_assert_PD(lv: PD) c_int;
 pub extern fn c_assert_ret_PD() c_int;