| author | |
| committer | |
| log | d7b36503cad1de60cd0b6a115ef7ac336a03a09a |
| tree | b4ae3fbe2147b223543dc5ac62d39a13b65248db |
| parent | 4c1da0912a474228750362a11db85799cac311b9 |
These are some spurious fixes to help illustrate the improved ergonomics of the `expectEqual` change. It is by no means complete.4 files changed, 42 insertions(+), 42 deletions(-)
lib/std/debug.zig+2-2| ... | ... | @@ -853,8 +853,8 @@ test "machoSearchSymbols" { |
| 853 | 853 | .{ .addr = 300, .strx = undefined, .size = undefined, .ofile = undefined }, |
| 854 | 854 | }; |
| 855 | 855 | |
| 856 | try testing.expectEqual(@as(?*const MachoSymbol, null), machoSearchSymbols(&symbols, 0)); | |
| 857 | try testing.expectEqual(@as(?*const MachoSymbol, null), machoSearchSymbols(&symbols, 99)); | |
| 856 | try testing.expectEqual(null, machoSearchSymbols(&symbols, 0)); | |
| 857 | try testing.expectEqual(null, machoSearchSymbols(&symbols, 99)); | |
| 858 | 858 | try testing.expectEqual(&symbols[0], machoSearchSymbols(&symbols, 100).?); |
| 859 | 859 | try testing.expectEqual(&symbols[0], machoSearchSymbols(&symbols, 150).?); |
| 860 | 860 | try testing.expectEqual(&symbols[0], machoSearchSymbols(&symbols, 199).?); |
lib/std/http.zig+2-2| ... | ... | @@ -283,8 +283,8 @@ pub const Status = enum(u10) { |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | test { |
| 286 | try std.testing.expectEqual(@as(?Status.Class, Status.Class.success), Status.ok.class()); | |
| 287 | try std.testing.expectEqual(@as(?Status.Class, Status.Class.client_error), Status.not_found.class()); | |
| 286 | try std.testing.expectEqual(Status.Class.success, Status.ok.class()); | |
| 287 | try std.testing.expectEqual(Status.Class.client_error, Status.not_found.class()); | |
| 288 | 288 | } |
| 289 | 289 | }; |
| 290 | 290 |
lib/std/json/static_test.zig+13-13| ... | ... | @@ -373,19 +373,19 @@ test "test all types" { |
| 373 | 373 | test "parse" { |
| 374 | 374 | try testing.expectEqual(false, try parseFromSliceLeaky(bool, testing.allocator, "false", .{})); |
| 375 | 375 | try testing.expectEqual(true, try parseFromSliceLeaky(bool, testing.allocator, "true", .{})); |
| 376 | try testing.expectEqual(@as(u1, 1), try parseFromSliceLeaky(u1, testing.allocator, "1", .{})); | |
| 376 | try testing.expectEqual(1, try parseFromSliceLeaky(u1, testing.allocator, "1", .{})); | |
| 377 | 377 | try testing.expectError(error.Overflow, parseFromSliceLeaky(u1, testing.allocator, "50", .{})); |
| 378 | try testing.expectEqual(@as(u64, 42), try parseFromSliceLeaky(u64, testing.allocator, "42", .{})); | |
| 379 | try testing.expectEqual(@as(f64, 42), try parseFromSliceLeaky(f64, testing.allocator, "42.0", .{})); | |
| 380 | try testing.expectEqual(@as(?bool, null), try parseFromSliceLeaky(?bool, testing.allocator, "null", .{})); | |
| 381 | try testing.expectEqual(@as(?bool, true), try parseFromSliceLeaky(?bool, testing.allocator, "true", .{})); | |
| 378 | try testing.expectEqual(42, try parseFromSliceLeaky(u64, testing.allocator, "42", .{})); | |
| 379 | try testing.expectEqual(42, try parseFromSliceLeaky(f64, testing.allocator, "42.0", .{})); | |
| 380 | try testing.expectEqual(null, try parseFromSliceLeaky(?bool, testing.allocator, "null", .{})); | |
| 381 | try testing.expectEqual(true, try parseFromSliceLeaky(?bool, testing.allocator, "true", .{})); | |
| 382 | 382 | |
| 383 | try testing.expectEqual(@as([3]u8, "foo".*), try parseFromSliceLeaky([3]u8, testing.allocator, "\"foo\"", .{})); | |
| 384 | try testing.expectEqual(@as([3]u8, "foo".*), try parseFromSliceLeaky([3]u8, testing.allocator, "[102, 111, 111]", .{})); | |
| 385 | try testing.expectEqual(@as([0]u8, undefined), try parseFromSliceLeaky([0]u8, testing.allocator, "[]", .{})); | |
| 383 | try testing.expectEqual("foo".*, try parseFromSliceLeaky([3]u8, testing.allocator, "\"foo\"", .{})); | |
| 384 | try testing.expectEqual("foo".*, try parseFromSliceLeaky([3]u8, testing.allocator, "[102, 111, 111]", .{})); | |
| 385 | try testing.expectEqual(undefined, try parseFromSliceLeaky([0]u8, testing.allocator, "[]", .{})); | |
| 386 | 386 | |
| 387 | try testing.expectEqual(@as(u64, 12345678901234567890), try parseFromSliceLeaky(u64, testing.allocator, "\"12345678901234567890\"", .{})); | |
| 388 | try testing.expectEqual(@as(f64, 123.456), try parseFromSliceLeaky(f64, testing.allocator, "\"123.456\"", .{})); | |
| 387 | try testing.expectEqual(12345678901234567890, try parseFromSliceLeaky(u64, testing.allocator, "\"12345678901234567890\"", .{})); | |
| 388 | try testing.expectEqual(123.456, try parseFromSliceLeaky(f64, testing.allocator, "\"123.456\"", .{})); | |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | test "parse into enum" { |
| ... | ... | @@ -394,9 +394,9 @@ test "parse into enum" { |
| 394 | 394 | Bar, |
| 395 | 395 | @"with\\escape", |
| 396 | 396 | }; |
| 397 | try testing.expectEqual(@as(T, .Foo), try parseFromSliceLeaky(T, testing.allocator, "\"Foo\"", .{})); | |
| 398 | try testing.expectEqual(@as(T, .Foo), try parseFromSliceLeaky(T, testing.allocator, "42", .{})); | |
| 399 | try testing.expectEqual(@as(T, .@"with\\escape"), try parseFromSliceLeaky(T, testing.allocator, "\"with\\\\escape\"", .{})); | |
| 397 | try testing.expectEqual(.Foo, try parseFromSliceLeaky(T, testing.allocator, "\"Foo\"", .{})); | |
| 398 | try testing.expectEqual(.Foo, try parseFromSliceLeaky(T, testing.allocator, "42", .{})); | |
| 399 | try testing.expectEqual(.@"with\\escape", try parseFromSliceLeaky(T, testing.allocator, "\"with\\\\escape\"", .{})); | |
| 400 | 400 | try testing.expectError(error.InvalidEnumTag, parseFromSliceLeaky(T, testing.allocator, "5", .{})); |
| 401 | 401 | try testing.expectError(error.InvalidEnumTag, parseFromSliceLeaky(T, testing.allocator, "\"Qux\"", .{})); |
| 402 | 402 | } |
test/behavior/packed-struct.zig+25-25| ... | ... | @@ -173,17 +173,17 @@ test "correct sizeOf and offsets in packed structs" { |
| 173 | 173 | try expectEqual(true, s1.bool_d); |
| 174 | 174 | try expectEqual(true, s1.bool_e); |
| 175 | 175 | try expectEqual(true, s1.bool_f); |
| 176 | try expectEqual(@as(u1, 1), s1.u1_a); | |
| 176 | try expectEqual(1, s1.u1_a); | |
| 177 | 177 | try expectEqual(false, s1.bool_g); |
| 178 | try expectEqual(@as(u1, 0), s1.u1_b); | |
| 179 | try expectEqual(@as(u3, 3), s1.u3_a); | |
| 180 | try expectEqual(@as(u10, 0b1101000101), s1.u10_a); | |
| 181 | try expectEqual(@as(u10, 0b0001001000), s1.u10_b); | |
| 178 | try expectEqual(0, s1.u1_b); | |
| 179 | try expectEqual(3, s1.u3_a); | |
| 180 | try expectEqual(0b1101000101, s1.u10_a); | |
| 181 | try expectEqual(0b0001001000, s1.u10_b); | |
| 182 | 182 | |
| 183 | 183 | const s2 = @as(packed struct { x: u1, y: u7, z: u24 }, @bitCast(@as(u32, 0xd5c71ff4))); |
| 184 | try expectEqual(@as(u1, 0), s2.x); | |
| 185 | try expectEqual(@as(u7, 0b1111010), s2.y); | |
| 186 | try expectEqual(@as(u24, 0xd5c71f), s2.z); | |
| 184 | try expectEqual(0, s2.x); | |
| 185 | try expectEqual(0b1111010, s2.y); | |
| 186 | try expectEqual(0xd5c71f, s2.z); | |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| ... | ... | @@ -208,12 +208,12 @@ test "nested packed structs" { |
| 208 | 208 | |
| 209 | 209 | if (native_endian == .little) { |
| 210 | 210 | const s3 = @as(S3Padded, @bitCast(@as(u64, 0xe952d5c71ff4))).s3; |
| 211 | try expectEqual(@as(u8, 0xf4), s3.x.a); | |
| 212 | try expectEqual(@as(u8, 0x1f), s3.x.b); | |
| 213 | try expectEqual(@as(u8, 0xc7), s3.x.c); | |
| 214 | try expectEqual(@as(u8, 0xd5), s3.y.d); | |
| 215 | try expectEqual(@as(u8, 0x52), s3.y.e); | |
| 216 | try expectEqual(@as(u8, 0xe9), s3.y.f); | |
| 211 | try expectEqual(0xf4, s3.x.a); | |
| 212 | try expectEqual(0x1f, s3.x.b); | |
| 213 | try expectEqual(0xc7, s3.x.c); | |
| 214 | try expectEqual(0xd5, s3.y.d); | |
| 215 | try expectEqual(0x52, s3.y.e); | |
| 216 | try expectEqual(0xe9, s3.y.f); | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | const S4 = packed struct { a: i32, b: i8 }; |
| ... | ... | @@ -249,8 +249,8 @@ test "regular in irregular packed struct" { |
| 249 | 249 | foo.bar.a = 235; |
| 250 | 250 | foo.bar.b = 42; |
| 251 | 251 | |
| 252 | try expectEqual(@as(u16, 235), foo.bar.a); | |
| 253 | try expectEqual(@as(u8, 42), foo.bar.b); | |
| 252 | try expectEqual(235, foo.bar.a); | |
| 253 | try expectEqual(42, foo.bar.b); | |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | test "nested packed struct unaligned" { |
| ... | ... | @@ -456,12 +456,12 @@ test "nested packed struct field pointers" { |
| 456 | 456 | const ptr_p0_c = &S2.s.p0.c; |
| 457 | 457 | const ptr_p1_a = &S2.s.p1.a; |
| 458 | 458 | const ptr_p1_b = &S2.s.p1.b; |
| 459 | try expectEqual(@as(u8, 1), ptr_base.*); | |
| 460 | try expectEqual(@as(u4, 2), ptr_p0_a.*); | |
| 461 | try expectEqual(@as(u4, 3), ptr_p0_b.*); | |
| 462 | try expectEqual(@as(u8, 4), ptr_p0_c.*); | |
| 463 | try expectEqual(@as(u7, 5), ptr_p1_a.*); | |
| 464 | try expectEqual(@as(u8, 6), ptr_p1_b.*); | |
| 459 | try expectEqual(1, ptr_base.*); | |
| 460 | try expectEqual(2, ptr_p0_a.*); | |
| 461 | try expectEqual(3, ptr_p0_b.*); | |
| 462 | try expectEqual(4, ptr_p0_c.*); | |
| 463 | try expectEqual(5, ptr_p1_a.*); | |
| 464 | try expectEqual(6, ptr_p1_b.*); | |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | test "load pointer from packed struct" { |
| ... | ... | @@ -1033,12 +1033,12 @@ test "modify nested packed struct aligned field" { |
| 1033 | 1033 | |
| 1034 | 1034 | var opts = Options{}; |
| 1035 | 1035 | opts.pretty_print.indent += 1; |
| 1036 | try std.testing.expectEqual(@as(u17, 0b00000000100100000), @as(u17, @bitCast(opts))); | |
| 1036 | try std.testing.expectEqual(0b00000000100100000, @as(u17, @bitCast(opts))); | |
| 1037 | 1037 | try std.testing.expect(!opts.foo); |
| 1038 | 1038 | try std.testing.expect(!opts.bar); |
| 1039 | 1039 | try std.testing.expect(!opts.pretty_print.enabled); |
| 1040 | try std.testing.expectEqual(@as(u4, 4), opts.pretty_print.num_spaces); | |
| 1041 | try std.testing.expectEqual(@as(u8, 1), opts.pretty_print.indent); | |
| 1040 | try std.testing.expectEqual(4, opts.pretty_print.num_spaces); | |
| 1041 | try std.testing.expectEqual(1, opts.pretty_print.indent); | |
| 1042 | 1042 | try std.testing.expect(!opts.baz); |
| 1043 | 1043 | } |
| 1044 | 1044 |