Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
147d909f
Commit
147d909f
authored
Dec 06, 2016
by
butataatawa
Committed by
Jesse Beder
Dec 06, 2016
Browse files
Fix inconsistent Node::size when removing a key with unassigned node (#327) (#449)
parent
e3492bb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
include/yaml-cpp/node/detail/impl.h
include/yaml-cpp/node/detail/impl.h
+8
-0
test/node/node_test.cpp
test/node/node_test.cpp
+7
-0
No files found.
include/yaml-cpp/node/detail/impl.h
View file @
147d909f
...
...
@@ -132,6 +132,14 @@ inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
if
(
m_type
!=
NodeType
::
Map
)
return
false
;
kv_pairs
::
iterator
it
=
m_undefinedPairs
.
begin
();
while
(
it
!=
m_undefinedPairs
.
end
())
{
kv_pairs
::
iterator
jt
=
std
::
next
(
it
);
if
(
it
->
first
->
equals
(
key
,
pMemory
))
m_undefinedPairs
.
erase
(
it
);
it
=
jt
;
}
for
(
node_map
::
iterator
it
=
m_map
.
begin
();
it
!=
m_map
.
end
();
++
it
)
{
if
(
it
->
first
->
equals
(
key
,
pMemory
))
{
m_map
.
erase
(
it
);
...
...
test/node/node_test.cpp
View file @
147d909f
...
...
@@ -88,6 +88,13 @@ TEST(NodeTest, MapWithUndefinedValues) {
EXPECT_EQ
(
2
,
node
.
size
());
}
TEST
(
NodeTest
,
RemoveUnassignedNode
)
{
Node
node
(
NodeType
::
Map
);
node
[
"key"
];
node
.
remove
(
"key"
);
EXPECT_EQ
(
node
.
size
(),
0
);
}
TEST
(
NodeTest
,
MapForceInsert
)
{
Node
node
;
Node
k1
(
"k1"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment