missing keys should throw InvalidNode, not BadConversion

Fixes GH #1274
This commit is contained in:
Reini Urban
2024-11-01 13:29:36 +01:00
committed by Jesse Beder
parent c2bec4c755
commit 3d2888cc8a
2 changed files with 12 additions and 2 deletions

View File

@@ -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";