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
25b2ed07
Commit
25b2ed07
authored
Mar 29, 2015
by
Jesse Beder
Browse files
Fix operator bool() exception on zombie node
parent
67e37d00
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
include/yaml-cpp/node/impl.h
include/yaml-cpp/node/impl.h
+3
-2
test/integration/load_node_test.cpp
test/integration/load_node_test.cpp
+2
-2
test/node/node_test.cpp
test/node/node_test.cpp
+7
-0
No files found.
include/yaml-cpp/node/impl.h
View file @
25b2ed07
...
@@ -60,8 +60,9 @@ inline void Node::EnsureNodeExists() const {
...
@@ -60,8 +60,9 @@ inline void Node::EnsureNodeExists() const {
}
}
inline
bool
Node
::
IsDefined
()
const
{
inline
bool
Node
::
IsDefined
()
const
{
if
(
!
m_isValid
)
if
(
!
m_isValid
)
{
throw
InvalidNode
();
return
false
;
}
return
m_pNode
?
m_pNode
->
is_defined
()
:
true
;
return
m_pNode
?
m_pNode
->
is_defined
()
:
true
;
}
}
...
...
test/integration/load_node_test.cpp
View file @
25b2ed07
...
@@ -181,8 +181,8 @@ TEST(LoadNodeTest, DereferenceIteratorError) {
...
@@ -181,8 +181,8 @@ TEST(LoadNodeTest, DereferenceIteratorError) {
EXPECT_THROW
(
node
.
begin
()
->
first
.
as
<
int
>
(),
InvalidNode
);
EXPECT_THROW
(
node
.
begin
()
->
first
.
as
<
int
>
(),
InvalidNode
);
EXPECT_EQ
(
true
,
(
*
node
.
begin
()).
IsMap
());
EXPECT_EQ
(
true
,
(
*
node
.
begin
()).
IsMap
());
EXPECT_EQ
(
true
,
node
.
begin
()
->
IsMap
());
EXPECT_EQ
(
true
,
node
.
begin
()
->
IsMap
());
EXPECT_THROW
((
*
node
.
begin
()
->
begin
()).
IsDefined
(),
InvalidNode
);
EXPECT_THROW
((
*
node
.
begin
()
->
begin
()).
Type
(),
InvalidNode
);
EXPECT_THROW
(
node
.
begin
()
->
begin
()
->
IsDefined
(),
InvalidNode
);
EXPECT_THROW
(
node
.
begin
()
->
begin
()
->
Type
(),
InvalidNode
);
}
}
TEST
(
NodeTest
,
EmitEmptyNode
)
{
TEST
(
NodeTest
,
EmitEmptyNode
)
{
...
...
test/node/node_test.cpp
View file @
25b2ed07
...
@@ -281,6 +281,13 @@ TEST(NodeTest, DefaultNodeStyle) {
...
@@ -281,6 +281,13 @@ TEST(NodeTest, DefaultNodeStyle) {
EXPECT_EQ
(
EmitterStyle
::
Default
,
node
.
Style
());
EXPECT_EQ
(
EmitterStyle
::
Default
,
node
.
Style
());
}
}
TEST
(
NodeTest
,
AccessNonexistentKeyOnConstNode
)
{
YAML
::
Node
node
;
node
[
"3"
]
=
"4"
;
const
YAML
::
Node
&
other
=
node
;
ASSERT_FALSE
(
other
[
"5"
]);
}
class
NodeEmitterTest
:
public
::
testing
::
Test
{
class
NodeEmitterTest
:
public
::
testing
::
Test
{
protected:
protected:
void
ExpectOutput
(
const
std
::
string
&
output
,
const
Node
&
node
)
{
void
ExpectOutput
(
const
std
::
string
&
output
,
const
Node
&
node
)
{
...
...
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