Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More test and new file start #20

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/yaml-test-suite/98YD-mixed.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
elemennts:
- name: Spec Example 5.5. Comment Indicator
from: http://www.yaml.org/spec/1.2/spec.html#id2773032
Expand All @@ -11,4 +12,4 @@ elemennts:
dump: ""
bool_val: true
bool_val_b2: false
bool_val_with_spaces: true
bool_val_with_spaces: true
5 changes: 3 additions & 2 deletions resources/yaml-test-suite/98YD.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
elemennts:
---
elements:
- name: Spec Example 5.5. Comment Indicator
from: http://www.yaml.org/spec/1.2/spec.html#id2773032
tags: spec comment empty
Expand All @@ -8,4 +9,4 @@ elemennts:
+STR
-STR
json: ""
dump: ""
dump: ""
1 change: 1 addition & 0 deletions resources/yaml-test-suite/CC74.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
elements:
- name: Spec Example 6.20. Tag Handles
from: http://www.yaml.org/spec/1.2/spec.html#id2783195
Expand Down
1 change: 1 addition & 0 deletions resources/yaml-test-suite/F6MC.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
elements:
- name: More indented lines at the beginning of folded block scalars
from: "@perlpunk"
Expand Down
28 changes: 28 additions & 0 deletions resources/yaml-test-suite/J5UC.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
elements:
- name: Multiple Pair Block Mapping
from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml
tags: mapping
yaml: |
foo: blue
bar: arrr
baz: jazz
tree: |
+STR
+DOC
+MAP
=VAL :foo
=VAL :blue
=VAL :bar
=VAL :arrr
=VAL :baz
=VAL :jazz
-MAP
-DOC
-STR
json: |
{
"foo": "blue",
"bar": "arrr",
"baz": "jazz"
}
1 change: 1 addition & 0 deletions resources/yaml-test-suite/QT73.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
elements:
- name: Comment and document-end marker
from: "@perlpunk"
Expand Down
32 changes: 32 additions & 0 deletions src/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,35 @@ test "QT73" {
try expect(std.mem.eql(u8, element.name, "Comment and document-end marker"));
try expect(std.mem.eql(u8, element.from, "@perlpunk"));
}

test "J5UC" {
const Element = struct {
name: []const u8,
from: []const u8,
tags: []const u8,
yaml: []const u8,
tree: []const u8,
json: []const u8,
};

const Experiment = struct {
elements: []Element,
};

const yml_file_location = try std.fs.cwd().realpathAlloc(
std.testing.allocator,
"./resources/yaml-test-suite/J5UC.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);

std.debug.print("elements: {}\n", .{result.elements.len});

const element = result.elements[0];

try expect(std.mem.eql(u8, element.name, "Multiple Pair Block Mapping"));
try expect(std.mem.eql(u8, element.from, "https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml"));
}
Loading