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
5a9ab177
Unverified
Commit
5a9ab177
authored
Jun 18, 2020
by
Chen
Committed by
GitHub
Jun 17, 2020
Browse files
tag_null (#897)
parent
72fe73a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
src/singledocparser.cpp
src/singledocparser.cpp
+6
-5
test/integration/load_node_test.cpp
test/integration/load_node_test.cpp
+12
-1
No files found.
src/singledocparser.cpp
View file @
5a9ab177
...
...
@@ -90,16 +90,17 @@ void SingleDocParser::HandleNode(EventHandler& eventHandler) {
const
Token
&
token
=
m_scanner
.
peek
();
if
(
token
.
type
==
Token
::
PLAIN_SCALAR
&&
IsNullString
(
token
.
value
))
{
// add non-specific tags
if
(
tag
.
empty
())
tag
=
(
token
.
type
==
Token
::
NON_PLAIN_SCALAR
?
"!"
:
"?"
);
if
(
token
.
type
==
Token
::
PLAIN_SCALAR
&&
tag
.
compare
(
"?"
)
==
0
&&
IsNullString
(
token
.
value
))
{
eventHandler
.
OnNull
(
mark
,
anchor
);
m_scanner
.
pop
();
return
;
}
// add non-specific tags
if
(
tag
.
empty
())
tag
=
(
token
.
type
==
Token
::
NON_PLAIN_SCALAR
?
"!"
:
"?"
);
// now split based on what kind of node we should be
switch
(
token
.
type
)
{
case
Token
::
PLAIN_SCALAR
:
...
...
test/integration/load_node_test.cpp
View file @
5a9ab177
...
...
@@ -269,7 +269,18 @@ TEST(NodeTest, LoadTildeAsNull) {
Node
node
=
Load
(
"~"
);
ASSERT_TRUE
(
node
.
IsNull
());
}
TEST
(
NodeTest
,
LoadNullWithStrTag
)
{
Node
node
=
Load
(
"!!str null"
);
EXPECT_EQ
(
node
.
Tag
(),
"tag:yaml.org,2002:str"
);
EXPECT_EQ
(
node
.
as
<
std
::
string
>
(),
"null"
);
}
TEST
(
NodeTest
,
LoadQuotedNull
)
{
Node
node
=
Load
(
"
\"
null
\"
"
);
EXPECT_EQ
(
node
.
as
<
std
::
string
>
(),
"null"
);
}
TEST
(
NodeTest
,
LoadTagWithParenthesis
)
{
Node
node
=
Load
(
"!Complex(Tag) foo"
);
EXPECT_EQ
(
node
.
Tag
(),
"!Complex(Tag)"
);
...
...
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