From 0d67204b344087e8c3d8d91d020b92dda08894bc Mon Sep 17 00:00:00 2001 From: pwbh Date: Fri, 6 Sep 2024 17:46:50 +0300 Subject: [PATCH] pass test casea --- resources/yaml-test-suite/CC74.yml | 18 ++++++++++++++++++ src/tests.zig | 28 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 resources/yaml-test-suite/CC74.yml diff --git a/resources/yaml-test-suite/CC74.yml b/resources/yaml-test-suite/CC74.yml new file mode 100644 index 0000000..1211cb7 --- /dev/null +++ b/resources/yaml-test-suite/CC74.yml @@ -0,0 +1,18 @@ +elements: + - name: Spec Example 6.20. Tag Handles + from: http://www.yaml.org/spec/1.2/spec.html#id2783195 + tags: spec directive tag unknown-tag + yaml: | + %TAG !e! tag:example.com,2000:app/ + --- + !e!foo "bar" + tree: | + +STR + +DOC --- + =VAL "bar + -DOC + -STR + json: | + "bar" + dump: | + --- ! "bar" diff --git a/src/tests.zig b/src/tests.zig index ba4d3f9..f6a8745 100644 --- a/src/tests.zig +++ b/src/tests.zig @@ -31,3 +31,31 @@ test "98YD" { try expect(std.mem.eql(u8, result.elements[0].name, "Spec Example 5.5. Comment Indicator")); } + +test "CC74" { + const Element = struct { + name: []const u8, + from: []const u8, + tags: []const u8, + yaml: []const u8, + tree: []const u8, + json: []const u8, + dump: []const u8, + }; + + const Experiment = struct { + elements: []Element, + }; + + const yml_file_location = try std.fs.cwd().realpathAlloc( + std.testing.allocator, + "./resources/yaml-test-suite/CC74.yml", + ); + defer std.testing.allocator.free(yml_file_location); + + var ymlz = try Ymlz(Experiment).init(std.testing.allocator); + const result = try ymlz.loadFile(yml_file_location); + defer ymlz.deinit(result); + + try expect(std.mem.eql(u8, result.elements[0].name, "Spec Example 6.20. Tag Handles")); +}