std.json: update tests to match new floating point formatting

This commit is contained in:
Marc Tiehuis 2024-03-09 17:03:05 +13:00
parent 04fd113e22
commit b6695f0542
2 changed files with 7 additions and 7 deletions

View File

@ -213,7 +213,7 @@ test "Value.jsonStringify" {
\\ true, \\ true,
\\ 42, \\ 42,
\\ 43, \\ 43,
\\ 4.2e+01, \\ 4.2e1,
\\ "weeee", \\ "weeee",
\\ [ \\ [
\\ 1, \\ 1,

View File

@ -74,16 +74,16 @@ fn testBasicWriteStream(w: anytype, slice_stream: anytype) !void {
\\{ \\{
\\ "object": { \\ "object": {
\\ "one": 1, \\ "one": 1,
\\ "two": 2.0e+00 \\ "two": 2e0
\\ }, \\ },
\\ "string": "This is a string", \\ "string": "This is a string",
\\ "array": [ \\ "array": [
\\ "Another string", \\ "Another string",
\\ 1, \\ 1,
\\ 3.5e+00 \\ 3.5e0
\\ ], \\ ],
\\ "int": 10, \\ "int": 10,
\\ "float": 3.5e+00 \\ "float": 3.5e0
\\} \\}
; ;
try std.testing.expectEqualStrings(expected, result); try std.testing.expectEqualStrings(expected, result);
@ -123,12 +123,12 @@ test "stringify basic types" {
try testStringify("null", @as(?u8, null), .{}); try testStringify("null", @as(?u8, null), .{});
try testStringify("null", @as(?*u32, null), .{}); try testStringify("null", @as(?*u32, null), .{});
try testStringify("42", 42, .{}); try testStringify("42", 42, .{});
try testStringify("4.2e+01", 42.0, .{}); try testStringify("4.2e1", 42.0, .{});
try testStringify("42", @as(u8, 42), .{}); try testStringify("42", @as(u8, 42), .{});
try testStringify("42", @as(u128, 42), .{}); try testStringify("42", @as(u128, 42), .{});
try testStringify("9999999999999999", 9999999999999999, .{}); try testStringify("9999999999999999", 9999999999999999, .{});
try testStringify("4.2e+01", @as(f32, 42), .{}); try testStringify("4.2e1", @as(f32, 42), .{});
try testStringify("4.2e+01", @as(f64, 42), .{}); try testStringify("4.2e1", @as(f64, 42), .{});
try testStringify("\"ItBroke\"", @as(anyerror, error.ItBroke), .{}); try testStringify("\"ItBroke\"", @as(anyerror, error.ItBroke), .{});
try testStringify("\"ItBroke\"", error.ItBroke, .{}); try testStringify("\"ItBroke\"", error.ItBroke, .{});
} }