Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79786161
yaml.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Aug 28, 05:51
Size
1 KB
Mime Type
text/x-c
Expires
Fri, Aug 30, 05:51 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20233148
Attached To
rSPECMICP SpecMiCP / ReactMiCP
yaml.cpp
View Options
#include <catch.hpp>
#include "utils/io/yaml.hpp"
using namespace specmicp::io;
const char* yaml_input =
R"(
---
section1:
{key1: value1, key2: 2, key3: true}
section2:
key4: value4
)";
TEST_CASE("YAML RO", "[yaml],[io]") {
SECTION("Parsing") {
auto file = RORichYAMLNode::parse_yaml_string(yaml_input);
CHECK(file.check("section1"));
CHECK(file.check("section2"));
CHECK(not file.check("section4"));
file.check_mandatory("section1");
RORichYAMLNode section1 = file["section1"];
CHECK_THROWS(file["section4"]);
const YAML::Node& node = section1.get_raw_node();
CHECK(node.IsSequence() == false);
CHECK(node.IsMap() == true);
std::string test = section1.get_mandatory<std::string>("key1");
CHECK(test == "value1");
CHECK(section1.get_mandatory<int>("key2") == 2);
CHECK(section1.get_mandatory<bool>("key3") == true);
CHECK(section1.get_optional<std::string>("keyopt", "opt") == "opt");
RORichYAMLNode section2 = file["section2"];
CHECK(section2.get_optional<std::string>("key4", "foo") == "value4");
}
}
Event Timeline
Log In to Comment