From 55f90f50e7b1600f654c6d5554a0124805888a83 Mon Sep 17 00:00:00 2001 From: pwbh Date: Sat, 14 Sep 2024 12:22:58 +0300 Subject: [PATCH] QT73 test --- resources/yaml-test-suite/QT73.yml | 12 ++++++++++++ src/tests.zig | 31 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 resources/yaml-test-suite/QT73.yml diff --git a/resources/yaml-test-suite/QT73.yml b/resources/yaml-test-suite/QT73.yml new file mode 100644 index 0000000..4c1a254 --- /dev/null +++ b/resources/yaml-test-suite/QT73.yml @@ -0,0 +1,12 @@ +elements: + - name: Comment and document-end marker + from: "@perlpunk" + tags: comment footer + yaml: | + # comment + ... + tree: | + +STR + -STR + json: "" + dump: "" diff --git a/src/tests.zig b/src/tests.zig index 58b2e82..37f08ef 100644 --- a/src/tests.zig +++ b/src/tests.zig @@ -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")); +}