cover a few more branches in the header

This commit is contained in:
James E. King III
2022-04-23 17:02:39 -04:00
committed by Jim King
parent cf956e50b7
commit fda9231a89
2 changed files with 14 additions and 2 deletions

View File

@@ -102,7 +102,7 @@ struct dynamic_get_failure : public dynamic_property_exception {
if(statement.empty())
statement =
std::string(
"dynamic property get cannot retrieve value for property: ")
"dynamic property get cannot retrieve value for property: ")
+ property + ".";
return statement.c_str();

View File

@@ -87,6 +87,14 @@ int main() {
#endif
BOOST_TEST(get("int",properties,std::string("one"), type<int>()) == 1);
BOOST_TEST(get("double",properties,5.3) == "five point three");
try {
get("not_there",properties,"");
BOOST_ERROR("No exception thrown.");
} catch (boost::dynamic_get_failure& ex) {
BOOST_TEST_CSTR_EQ(ex.what(), "dynamic property get cannot retrieve value for property: not_there.");
// test idempotent error string generator branch
BOOST_TEST_CSTR_EQ(ex.what(), "dynamic property get cannot retrieve value for property: not_there.");
}
}
// Put tests
@@ -117,7 +125,11 @@ int main() {
try {
put("nada",properties,3.14,std::string("3.14159"));
BOOST_ERROR("No exception thrown.");
} catch (boost::property_not_found&) { }
} catch (boost::property_not_found& ex) {
BOOST_TEST_CSTR_EQ(ex.what(), "Property not found: nada.");
// test idempotent error string generator branch
BOOST_TEST_CSTR_EQ(ex.what(), "Property not found: nada.");
}
}
// Nonexistent property gets generated