|
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" { |
@@ -1738,8 +1739,8 @@ test "peer type resolution: float and comptime-known fixed-width integer" { |
1738 | 1739 |
|
1739 | 1740 | const T = @TypeOf(r1); |
1740 | 1741 |
|
1741 | | - try expectEqual(@as(T, 100.0), r1); |
1742 | | - try expectEqual(@as(T, 1.234), r2); |
| 1742 | + try expect(@as(T, 100.0) == r1); |
| 1743 | + try expect(@as(T, 1.234) == r2); |
1743 | 1744 | } |
1744 | 1745 |
|
1745 | 1746 | test "peer type resolution: same array type with sentinel" { |
@@ -1879,8 +1880,8 @@ test "peer type resolution: C pointer and @TypeOf(null)" { |
1879 | 1880 |
|
1880 | 1881 | const T = @TypeOf(r1); |
1881 | 1882 |
|
1882 | | - try expectEqual(@as(T, 0x1000), r1); |
1883 | | - try expectEqual(@as(T, null), r2); |
| 1883 | + try expect(@as(T, 0x1000) == r1); |
| 1884 | + try expect(@as(T, null) == r2); |
1884 | 1885 | } |
1885 | 1886 |
|
1886 | 1887 | test "peer type resolution: three-way resolution combines error set and optional" { |
@@ -1969,8 +1970,8 @@ test "peer type resolution: optional fixed-width int and comptime_int" { |
1969 | 1970 |
|
1970 | 1971 | const T = @TypeOf(r1); |
1971 | 1972 |
|
1972 | | - try expectEqual(@as(T, 42), r1); |
1973 | | - try expectEqual(@as(T, 50), r2); |
| 1973 | + try expect(@as(T, 42) == r1); |
| 1974 | + try expect(@as(T, 50) == r2); |
1974 | 1975 | } |
1975 | 1976 |
|
1976 | 1977 | test "peer type resolution: array and tuple" { |
@@ -2224,11 +2225,11 @@ test "peer type resolution: tuples with comptime fields" { |
2224 | 2225 | const r1 = if (t) a else b; |
2225 | 2226 | const r2 = if (t) b else a; |
2226 | 2227 |
|
2227 | | - try expectEqual(@as(u32, 1), r1[0]); |
2228 | | - try expectEqual(@as(i16, 2), r1[1]); |
| 2228 | + try expect(@as(u32, 1) == r1[0]); |
| 2229 | + try expect(@as(i16, 2) == r1[1]); |
2229 | 2230 |
|
2230 | | - try expectEqual(@as(u32, 3), r2[0]); |
2231 | | - try expectEqual(@as(i16, 4), r2[1]); |
| 2231 | + try expect(@as(u32, 3) == r2[0]); |
| 2232 | + try expect(@as(i16, 4) == r2[1]); |
2232 | 2233 | } |
2233 | 2234 |
|
2234 | 2235 | test "peer type resolution: C pointer and many pointer" { |
@@ -2626,7 +2627,7 @@ test "numeric coercions with undefined" { |
2626 | 2627 | var to: f32 = from; |
2627 | 2628 | to = @floatFromInt(from); |
2628 | 2629 | to = 42.0; |
2629 | | - try expectEqual(@as(f32, 42.0), to); |
| 2630 | + try expect(@as(f32, 42.0) == to); |
2630 | 2631 | } |
2631 | 2632 |
|
2632 | 2633 | test "15-bit int to float" { |
@@ -2711,7 +2712,7 @@ test "bitcast vector" { |
2711 | 2712 |
|
2712 | 2713 | const zerox32: u8x32 = [_]u8{0} ** 32; |
2713 | 2714 | const bigsum: u32x8 = @bitCast(zerox32); |
2714 | | - try std.testing.expectEqual(0, @reduce(.Add, bigsum)); |
| 2715 | + try std.testing.expect(0 == @reduce(.Add, bigsum)); |
2715 | 2716 | } |
2716 | 2717 |
|
2717 | 2718 | test "peer type resolution: slice of sentinel-terminated array" { |
|
0 commit comments