mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
missing keys should throw InvalidNode, not BadConversion
Fixes GH #1274
This commit is contained in:
@@ -191,6 +191,14 @@ TEST(NodeTest, MapElementRemoval) {
|
||||
EXPECT_TRUE(!node["foo"]);
|
||||
}
|
||||
|
||||
TEST(NodeTest, MissingKey) {
|
||||
Node node;
|
||||
node["foo"] = "value";
|
||||
EXPECT_TRUE(!node["bar"]);
|
||||
EXPECT_EQ(NodeType::Undefined, node["bar"].Type());
|
||||
EXPECT_THROW(node["bar"].as<std::string>(), InvalidNode);
|
||||
}
|
||||
|
||||
TEST(NodeTest, MapIntegerElementRemoval) {
|
||||
Node node;
|
||||
node[1] = "hello";
|
||||
|
Reference in New Issue
Block a user