Skip to content

Commit

Permalink
pass test casea
Browse files Browse the repository at this point in the history
  • Loading branch information
pwbh committed Sep 6, 2024
1 parent ec7335f commit 0d67204
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
18 changes: 18 additions & 0 deletions resources/yaml-test-suite/CC74.yml
Original file line number Diff line number Diff line change
@@ -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 <tag:example.com,2000:app/foo> "bar
-DOC
-STR
json: |
"bar"
dump: |
--- !<tag:example.com,2000:app/foo> "bar"
28 changes: 28 additions & 0 deletions src/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

0 comments on commit 0d67204

Please sign in to comment.