authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-30 11:57:44-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-30 11:57:44-07:00
log32815914a487ab6d69a29ef1ff8d7e527ffc82ff
treefecbff35be00027c69a563334b9def3fd7c23578
parent781a21af2ffb8d8a8398fab8dafe638fad3a0ea6

std.json: update to new testing API


1 files changed, 7 insertions(+), 7 deletions(-)

lib/std/json.zig+7-7
...@@ -1493,7 +1493,7 @@ test "skipValue" {...@@ -1493,7 +1493,7 @@ test "skipValue" {
1493 { // An absurd number of nestings1493 { // An absurd number of nestings
1494 const nestings = 256;1494 const nestings = 256;
14951495
1496 testing.expectError(1496 try testing.expectError(
1497 error.TooManyNestedItems,1497 error.TooManyNestedItems,
1498 skipValue(&TokenStream.init("[" ** nestings ++ "]" ** nestings)),1498 skipValue(&TokenStream.init("[" ** nestings ++ "]" ** nestings)),
1499 );1499 );
...@@ -1505,14 +1505,14 @@ test "skipValue" {...@@ -1505,14 +1505,14 @@ test "skipValue" {
15051505
1506 try skipValue(&TokenStream.init(deeply_nested_array));1506 try skipValue(&TokenStream.init(deeply_nested_array));
15071507
1508 testing.expectError(1508 try testing.expectError(
1509 error.TooManyNestedItems,1509 error.TooManyNestedItems,
1510 skipValue(&TokenStream.init("[" ++ deeply_nested_array ++ "]")),1510 skipValue(&TokenStream.init("[" ++ deeply_nested_array ++ "]")),
1511 );1511 );
1512 }1512 }
15131513
1514 // Mismatched brace/square bracket1514 // Mismatched brace/square bracket
1515 testing.expectError(1515 try testing.expectError(
1516 error.UnexpectedClosingBrace,1516 error.UnexpectedClosingBrace,
1517 skipValue(&TokenStream.init("[102, 111, 111}")),1517 skipValue(&TokenStream.init("[102, 111, 111}")),
1518 );1518 );
...@@ -1520,11 +1520,11 @@ test "skipValue" {...@@ -1520,11 +1520,11 @@ test "skipValue" {
1520 { // should fail if no value found (e.g. immediate close of object)1520 { // should fail if no value found (e.g. immediate close of object)
1521 var empty_object = TokenStream.init("{}");1521 var empty_object = TokenStream.init("{}");
1522 assert(.ObjectBegin == (try empty_object.next()).?);1522 assert(.ObjectBegin == (try empty_object.next()).?);
1523 testing.expectError(error.UnexpectedJsonDepth, skipValue(&empty_object));1523 try testing.expectError(error.UnexpectedJsonDepth, skipValue(&empty_object));
15241524
1525 var empty_array = TokenStream.init("[]");1525 var empty_array = TokenStream.init("[]");
1526 assert(.ArrayBegin == (try empty_array.next()).?);1526 assert(.ArrayBegin == (try empty_array.next()).?);
1527 testing.expectError(error.UnexpectedJsonDepth, skipValue(&empty_array));1527 try testing.expectError(error.UnexpectedJsonDepth, skipValue(&empty_array));
1528 }1528 }
1529}1529}
15301530
...@@ -2152,8 +2152,8 @@ test "parse into struct ignoring unknown fields" {...@@ -2152,8 +2152,8 @@ test "parse into struct ignoring unknown fields" {
2152 ), ops);2152 ), ops);
2153 defer parseFree(T, r, ops);2153 defer parseFree(T, r, ops);
21542154
2155 testing.expectEqual(@as(i64, 420), r.int);2155 try testing.expectEqual(@as(i64, 420), r.int);
2156 testing.expectEqualSlices(u8, "zig", r.language);2156 try testing.expectEqualSlices(u8, "zig", r.language);
2157}2157}
21582158
2159/// A non-stream JSON parser which constructs a tree of Value's.2159/// A non-stream JSON parser which constructs a tree of Value's.