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
2375f2c6
Commit
2375f2c6
authored
Apr 13, 2013
by
Jesse Beder
Browse files
Fix bug where the string "null" (without quotes) is deserialized as a string, instead of null.
parent
e0ae477b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
src/singledocparser.cpp
src/singledocparser.cpp
+6
-0
test/core/parsertests.cpp
test/core/parsertests.cpp
+13
-0
No files found.
src/singledocparser.cpp
View file @
2375f2c6
...
...
@@ -75,6 +75,12 @@ namespace YAML
ParseProperties
(
tag
,
anchor
);
const
Token
&
token
=
m_scanner
.
peek
();
if
(
token
.
type
==
Token
::
PLAIN_SCALAR
&&
token
.
value
==
"null"
)
{
eventHandler
.
OnNull
(
mark
,
anchor
);
m_scanner
.
pop
();
return
;
}
// add non-specific tags
if
(
tag
.
empty
())
...
...
test/core/parsertests.cpp
View file @
2375f2c6
...
...
@@ -28,6 +28,18 @@ namespace Test
EXPECT_DOC_END
();
DONE
();
}
TEST
NullStringScalar
()
{
HANDLE
(
"foo: null"
);
EXPECT_DOC_START
();
EXPECT_MAP_START
(
"?"
,
0
);
EXPECT_SCALAR
(
"?"
,
0
,
"foo"
);
EXPECT_NULL
(
0
);
EXPECT_MAP_END
();
EXPECT_DOC_END
();
DONE
();
}
}
namespace
{
...
...
@@ -57,6 +69,7 @@ namespace Test
int
total
=
0
;
RunParserTest
(
&
Parser
::
NoEndOfMapFlow
,
"No end of map flow"
,
passed
,
total
);
RunParserTest
(
&
Parser
::
PlainScalarStartingWithQuestionMark
,
"Plain scalar starting with question mark"
,
passed
,
total
);
RunParserTest
(
&
Parser
::
NullStringScalar
,
"Null string scalar"
,
passed
,
total
);
std
::
cout
<<
"Parser tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
return
passed
==
total
;
...
...
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