115 const std::filesystem::path& generated_path,
const std::string& yaml_namespace =
"")
117 std::string msg_prefix =
118 std::string(
"In ") + generated_path.c_str() +
", node with namespace '" + yaml_namespace +
"' ";
120 if (generated.Type() != reference.Type())
122 ADD_FAILURE() << msg_prefix +
"does not have matching types!";
126 if (generated.IsSequence())
128 if (generated.size() != reference.size())
130 ADD_FAILURE() << msg_prefix +
"does not have matching sizes!";
133 for (std::size_t i = 0; i < generated.size(); ++i)
135 std::string sub_namespace = yaml_namespace +
"[" + std::to_string(i) +
"]";
139 else if (generated.IsMap())
141 std::set<std::string> gkeys =
getKeys(generated), rkeys =
getKeys(reference), missing_keys, common_keys, extra_keys;
143 std::set_difference(rkeys.begin(), rkeys.end(), gkeys.begin(), gkeys.end(),
144 std::inserter(missing_keys, missing_keys.end()));
145 std::set_difference(gkeys.begin(), gkeys.end(), rkeys.begin(), rkeys.end(),
146 std::inserter(extra_keys, extra_keys.end()));
147 std::set_intersection(gkeys.begin(), gkeys.end(), rkeys.begin(), rkeys.end(),
148 std::inserter(common_keys, common_keys.end()));
150 for (
const std::string& key : missing_keys)
152 ADD_FAILURE() << msg_prefix <<
"is missing the key '" << key <<
"'";
154 for (
const std::string& key : extra_keys)
156 ADD_FAILURE() << msg_prefix <<
"has an extra key '" << key <<
"'";
158 for (
const std::string& key : common_keys)
160 std::string sub_namespace = yaml_namespace +
"/" + key;
166 EXPECT_EQ(generated.as<std::string>(), reference.as<std::string>())
167 << msg_prefix <<
"does not match scalar values!";
173 EXPECT_EQ(std::filesystem::is_regular_file(generated_path), std::filesystem::is_regular_file(reference_path));
174 if (!std::filesystem::is_regular_file(reference_path))
178 const YAML::Node& generated = YAML::LoadFile(generated_path);
179 const YAML::Node& reference = YAML::LoadFile(reference_path);