Skip to content

Commit

Permalink
QT73 test
Browse files Browse the repository at this point in the history
  • Loading branch information
pwbh committed Sep 14, 2024
1 parent bd3ce82 commit 55f90f5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions resources/yaml-test-suite/QT73.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
elements:
- name: Comment and document-end marker
from: "@perlpunk"
tags: comment footer
yaml: |
# comment
...
tree: |
+STR
-STR
json: ""
dump: ""
31 changes: 31 additions & 0 deletions src/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,34 @@ test "F6MC" {
try expect(std.mem.eql(u8, element.name, "More indented lines at the beginning of folded block scalars"));
try expect(std.mem.eql(u8, element.json, "{\n \"a\": \" more indented\\nregular\\n\",\n \"b\": \"\\n\\n more indented\\nregular\\n\"\n}"));
}

test "QT73" {
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/QT73.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);

const element = result.elements[0];

try expect(std.mem.eql(u8, element.name, "Comment and document-end marker"));
try expect(std.mem.eql(u8, element.from, "@perlpunk"));
}

0 comments on commit 55f90f5

Please sign in to comment.