|
1 | | -const builtin = @import("builtin"); |
2 | 1 | const std = @import("std"); |
3 | 2 | const assert = std.debug.assert; |
4 | 3 | const expect = std.testing.expect; |
5 | 4 | const expectEqual = std.testing.expectEqual; |
6 | 5 | const expectEqualSlices = std.testing.expectEqualSlices; |
7 | 6 | const mem = std.mem; |
8 | 7 | const maxInt = std.math.maxInt; |
| 8 | +const builtin = @import("builtin"); |
| 9 | + |
9 | 10 | const native_endian = builtin.target.cpu.arch.endian(); |
10 | 11 |
|
11 | 12 | test "int to ptr cast" { |
@@ -1672,8 +1673,8 @@ test "peer type resolution: float and comptime-known fixed-width integer" { |
1672 | 1673 |
|
1673 | 1674 | const T = @TypeOf(r1); |
1674 | 1675 |
|
1675 | | - try expectEqual(@as(T, 100.0), r1); |
1676 | | - try expectEqual(@as(T, 1.234), r2); |
| 1676 | + try expect(@as(T, 100.0) == r1); |
| 1677 | + try expect(@as(T, 1.234) == r2); |
1677 | 1678 | } |
1678 | 1679 |
|
1679 | 1680 | test "peer type resolution: same array type with sentinel" { |
@@ -1811,8 +1812,8 @@ test "peer type resolution: C pointer and @TypeOf(null)" { |
1811 | 1812 |
|
1812 | 1813 | const T = @TypeOf(r1); |
1813 | 1814 |
|
1814 | | - try expectEqual(@as(T, 0x1000), r1); |
1815 | | - try expectEqual(@as(T, null), r2); |
| 1815 | + try expect(@as(T, 0x1000) == r1); |
| 1816 | + try expect(@as(T, null) == r2); |
1816 | 1817 | } |
1817 | 1818 |
|
1818 | 1819 | test "peer type resolution: three-way resolution combines error set and optional" { |
@@ -1899,8 +1900,8 @@ test "peer type resolution: optional fixed-width int and comptime_int" { |
1899 | 1900 |
|
1900 | 1901 | const T = @TypeOf(r1); |
1901 | 1902 |
|
1902 | | - try expectEqual(@as(T, 42), r1); |
1903 | | - try expectEqual(@as(T, 50), r2); |
| 1903 | + try expect(@as(T, 42) == r1); |
| 1904 | + try expect(@as(T, 50) == r2); |
1904 | 1905 | } |
1905 | 1906 |
|
1906 | 1907 | test "peer type resolution: array and tuple" { |
@@ -2149,11 +2150,11 @@ test "peer type resolution: tuples with comptime fields" { |
2149 | 2150 | const r1 = if (t) a else b; |
2150 | 2151 | const r2 = if (t) b else a; |
2151 | 2152 |
|
2152 | | - try expectEqual(@as(u32, 1), r1[0]); |
2153 | | - try expectEqual(@as(i16, 2), r1[1]); |
| 2153 | + try expect(@as(u32, 1) == r1[0]); |
| 2154 | + try expect(@as(i16, 2) == r1[1]); |
2154 | 2155 |
|
2155 | | - try expectEqual(@as(u32, 3), r2[0]); |
2156 | | - try expectEqual(@as(i16, 4), r2[1]); |
| 2156 | + try expect(@as(u32, 3) == r2[0]); |
| 2157 | + try expect(@as(i16, 4) == r2[1]); |
2157 | 2158 | } |
2158 | 2159 |
|
2159 | 2160 | test "peer type resolution: C pointer and many pointer" { |
@@ -2546,7 +2547,7 @@ test "numeric coercions with undefined" { |
2546 | 2547 | var to: f32 = from; |
2547 | 2548 | to = @floatFromInt(from); |
2548 | 2549 | to = 42.0; |
2549 | | - try expectEqual(@as(f32, 42.0), to); |
| 2550 | + try expect(@as(f32, 42.0) == to); |
2550 | 2551 | } |
2551 | 2552 |
|
2552 | 2553 | test "15-bit int to float" { |
@@ -2628,7 +2629,7 @@ test "bitcast vector" { |
2628 | 2629 |
|
2629 | 2630 | const zerox32: u8x32 = [_]u8{0} ** 32; |
2630 | 2631 | const bigsum: u32x8 = @bitCast(zerox32); |
2631 | | - try std.testing.expectEqual(0, @reduce(.Add, bigsum)); |
| 2632 | + try std.testing.expect(0 == @reduce(.Add, bigsum)); |
2632 | 2633 | } |
2633 | 2634 |
|
2634 | 2635 | test "peer type resolution: slice of sentinel-terminated array" { |
|
0 commit comments