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

Add sequence num_children checks to quickstart #466

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions samples/quickstart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ john: doe)";
CHECK(tree["bar"].is_seq());
CHECK(tree["bar"].has_key());
CHECK(tree["bar"].key() == "bar");
CHECK(tree["bar"].num_children() == 2);
// maps use string keys, seqs use index keys:
CHECK(tree["bar"][0].val() == "2");
CHECK(tree["bar"][1].val() == "3");
Expand Down Expand Up @@ -593,6 +594,7 @@ john: doe)";
// In this case it is OK because those are static strings, located
// in the executable's static section, and will outlive the tree.
CHECK(root["foo"].val() == "says you");
CHECK(root["bar"].num_children() == 2);
CHECK(root["bar"][0].val() == "-2");
CHECK(root["bar"][1].val() == "-3");
CHECK(root["john"].val() == "ron");
Expand Down Expand Up @@ -1797,6 +1799,7 @@ void sample_parse_in_place()
CHECK(root["bar"].is_seq());
CHECK(root["bar"].has_key());
CHECK(root["bar"].key() == "bar");
CHECK(root["bar"].num_children() == 2);
CHECK(root["bar"][0].val() == "2");
CHECK(root["bar"][1].val() == "3");

Expand Down Expand Up @@ -1849,6 +1852,7 @@ void sample_parse_in_arena()
CHECK(root["bar"].is_seq());
CHECK(root["bar"].has_key());
CHECK(root["bar"].key() == "bar");
CHECK(root["bar"].num_children() == 2);
CHECK(root["bar"][0].val() == "2");
CHECK(root["bar"][1].val() == "3");

Expand Down Expand Up @@ -1906,6 +1910,7 @@ bar: [2, 3]
CHECK(root["bar"].is_seq());
CHECK(root["bar"].has_key());
CHECK(root["bar"].key() == "bar");
CHECK(root["bar"].num_children() == 2);
CHECK(root["bar"][0].val() == "2");
CHECK(root["bar"][1].val() == "3");
CHECK(ryml::emitrs_yaml<std::string>(tree) == R"(foo: 1
Expand All @@ -1926,6 +1931,7 @@ bar2: [22,32]
CHECK(root["bar2"].is_seq());
CHECK(root["bar2"].has_key());
CHECK(root["bar2"].key() == "bar2");
CHECK(root["bar2"].num_children() == 2);
CHECK(root["bar2"][0].val() == "22");
CHECK(root["bar2"][1].val() == "32");

Expand All @@ -1951,6 +1957,7 @@ bar2: [22,32]
coffee: Arabica
)");
CHECK(root.is_seq());
CHECK(root.num_children() == 4);
CHECK(root[0].val() == "a");
CHECK(root[1].val() == "b");
CHECK(root[2].is_map());
Expand Down