Skip to content

Commit

Permalink
github issue biojppm#277: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Otterbein committed Dec 6, 2022
1 parent 2bfb4c9 commit 268dddc
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test_github_issues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,41 @@
namespace c4 {
namespace yml {

TEST(github, 277)
{
Tree tree = parse_in_arena(R"(
A: &A
V: 3
W: 4
B:
<<: *A
V: 5
X: 6
)");
const char *keys[] = {"V", "W", "X"};
const char *vals[] = {"5", "4", "6"};
tree.resolve();
auto root = tree.rootref();
ASSERT_TRUE(root["B"].is_map());
size_t num_childs = root["B"].num_children();
size_t child = 0;
ASSERT_EQ(num_childs, 3);
for (const auto node : root["B"].children())
{
EXPECT_EQ(node.key(), csubstr(keys[child], 1));
EXPECT_EQ(node.val(), csubstr(vals[child], 1));
child++;
}
// test whether the tree is corrupted
child = num_childs - 1;
for (size_t n = tree.last_child(root["B"].id()); n != NONE; n = tree.prev_sibling(n))
{
ASSERT_TRUE(child >= 0);
EXPECT_EQ(tree.key(n), csubstr(keys[child], 1));
child--;
}
}

TEST(github, 78)
{
Tree t = parse_in_arena("{foo: 1, bar: [2, 3]}");
Expand Down

0 comments on commit 268dddc

Please sign in to comment.