diff options
| author | Techatrix <19954306+Techatrix@users.noreply.github.com> | 2023-07-08 05:33:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-07 23:33:47 -0400 |
| commit | 89396ff02ba235592641fb388e3958c2c047e728 (patch) | |
| tree | 69ad7fc9a7da265e1fefbed2271f81679f86e0a8 /lib/std/json/dynamic_test.zig | |
| parent | b9fc0d2908371dc4f7c95c03972d42e290d6e1e0 (diff) | |
| download | zig-89396ff02ba235592641fb388e3958c2c047e728.tar.gz zig-89396ff02ba235592641fb388e3958c2c047e728.zip | |
add `jsonParseFromValue` to `std.json.Value` (#16324)
Diffstat (limited to 'lib/std/json/dynamic_test.zig')
| -rw-r--r-- | lib/std/json/dynamic_test.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/std/json/dynamic_test.zig b/lib/std/json/dynamic_test.zig index ae4ccef6d3..98a9d41e85 100644 --- a/lib/std/json/dynamic_test.zig +++ b/lib/std/json/dynamic_test.zig @@ -245,6 +245,23 @@ test "Value.jsonStringify" { } } +test "parseFromValue(std.json.Value,...)" { + const str = + \\{ + \\ "int": 32, + \\ "float": 3.2, + \\ "str": "str", + \\ "array": [3, 2], + \\ "object": {} + \\} + ; + + const parsed_tree = try parseFromSlice(Value, testing.allocator, str, .{}); + defer parsed_tree.deinit(); + const tree = try parseFromValueLeaky(Value, parsed_tree.arena.allocator(), parsed_tree.value, .{}); + try testing.expect(std.meta.eql(parsed_tree.value, tree)); +} + test "polymorphic parsing" { if (true) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/16108 const doc = |
