-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test cases addition to find edge cases in ymlz (#16)
* Start adding more tests and find more edge cases * pass test casea * fix more edge cases
- Loading branch information
Showing
5 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
elemennts: | ||
- name: Spec Example 5.5. Comment Indicator | ||
from: http://www.yaml.org/spec/1.2/spec.html#id2773032 | ||
tags: spec comment empty | ||
yaml: | | ||
# Comment only. | ||
tree: | | ||
+STR | ||
-STR | ||
json: "" | ||
dump: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
elements: | ||
- name: More indented lines at the beginning of folded block scalars | ||
from: "@perlpunk" | ||
tags: folded indent | ||
yaml: | | ||
--- | ||
a: >2 | ||
more indented | ||
regular | ||
b: >2 | ||
more indented | ||
regular | ||
tree: | | ||
+STR | ||
+DOC --- | ||
+MAP | ||
=VAL :a | ||
=VAL > more indented\nregular\n | ||
=VAL :b | ||
=VAL >\n\n more indented\nregular\n | ||
-MAP | ||
-DOC | ||
-STR | ||
json: | | ||
{ | ||
"a": " more indented\nregular\n", | ||
"b": "\n\n more indented\nregular\n" | ||
} | ||
emit: | | ||
--- | ||
a: >2 | ||
more indented | ||
regular | ||
b: >2 | ||
more indented | ||
regular |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
const std = @import("std"); | ||
|
||
const expect = std.testing.expect; | ||
|
||
const Ymlz = @import("root.zig").Ymlz; | ||
|
||
test "98YD" { | ||
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/98YD.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 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")); | ||
} | ||
|
||
test "F6MC" { | ||
const Element = struct { | ||
name: []const u8, | ||
from: []const u8, | ||
tags: []const u8, | ||
yaml: []const u8, | ||
tree: []const u8, | ||
json: []const u8, | ||
emit: []const u8, | ||
}; | ||
|
||
const Experiment = struct { | ||
elements: []Element, | ||
}; | ||
|
||
const yml_file_location = try std.fs.cwd().realpathAlloc( | ||
std.testing.allocator, | ||
"./resources/yaml-test-suite/F6MC.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, "More indented lines at the beginning of folded block scalars")); | ||
} |