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
026a53fb
"monkey_model/text_monkey/window.py" did not exist on "b81b2f598b3397951885f7e5aab038f705d7228a"
Unverified
Commit
026a53fb
authored
Jul 03, 2020
by
Chen
Committed by
GitHub
Jul 02, 2020
Browse files
Parse colon in plain scalar correctly when in a flow collection
Fixes #740.
parent
1c2e7673
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
src/exp.h
src/exp.h
+1
-1
test/integration/load_node_test.cpp
test/integration/load_node_test.cpp
+46
-0
No files found.
src/exp.h
View file @
026a53fb
...
@@ -110,7 +110,7 @@ inline const RegEx& Value() {
...
@@ -110,7 +110,7 @@ inline const RegEx& Value() {
return
e
;
return
e
;
}
}
inline
const
RegEx
&
ValueInFlow
()
{
inline
const
RegEx
&
ValueInFlow
()
{
static
const
RegEx
e
=
RegEx
(
':'
)
+
(
BlankOrBreak
()
|
RegEx
(
",}"
,
REGEX_OR
));
static
const
RegEx
e
=
RegEx
(
':'
)
+
(
BlankOrBreak
()
|
RegEx
(
",
]
}"
,
REGEX_OR
));
return
e
;
return
e
;
}
}
inline
const
RegEx
&
ValueInJSONFlow
()
{
inline
const
RegEx
&
ValueInJSONFlow
()
{
...
...
test/integration/load_node_test.cpp
View file @
026a53fb
...
@@ -265,6 +265,52 @@ TEST(NodeTest, IncompleteJson) {
...
@@ -265,6 +265,52 @@ TEST(NodeTest, IncompleteJson) {
}
}
}
}
struct
SingleNodeTestCase
{
std
::
string
input
;
NodeType
::
value
nodeType
;
int
nodeSize
;
std
::
string
expected_content
;
};
TEST
(
NodeTest
,
SpecialFlow
)
{
std
::
vector
<
SingleNodeTestCase
>
tests
=
{
{
"[:]"
,
NodeType
::
Sequence
,
1
,
"[{~: ~}]"
},
{
"[a:]"
,
NodeType
::
Sequence
,
1
,
"[{a: ~}]"
},
{
"[:a]"
,
NodeType
::
Sequence
,
1
,
"[:a]"
},
{
"[,]"
,
NodeType
::
Sequence
,
1
,
"[~]"
},
{
"[a:,]"
,
NodeType
::
Sequence
,
1
,
"[{a: ~}]"
},
{
"{:}"
,
NodeType
::
Map
,
1
,
"{~: ~}"
},
{
"{a:}"
,
NodeType
::
Map
,
1
,
"{a: ~}"
},
{
"{:a}"
,
NodeType
::
Map
,
1
,
"{:a: ~}"
},
{
"{,}"
,
NodeType
::
Map
,
1
,
"{~: ~}"
},
{
"{a:,}"
,
NodeType
::
Map
,
1
,
"{a: ~}"
},
};
for
(
const
SingleNodeTestCase
&
test
:
tests
)
{
Node
node
=
Load
(
test
.
input
);
Emitter
emitter
;
emitter
<<
node
;
EXPECT_EQ
(
test
.
nodeType
,
node
.
Type
());
EXPECT_EQ
(
test
.
nodeSize
,
node
.
size
());
EXPECT_EQ
(
test
.
expected_content
,
std
::
string
(
emitter
.
c_str
()));
}
}
TEST
(
NodeTest
,
IncorrectFlow
)
{
std
::
vector
<
ParserExceptionTestCase
>
tests
=
{
{
"Incorrect yaml:
\"
{:]
\"
"
,
"{:]"
,
ErrorMsg
::
FLOW_END
},
{
"Incorrect yaml:
\"
[:}
\"
"
,
"[:}"
,
ErrorMsg
::
FLOW_END
},
};
for
(
const
ParserExceptionTestCase
test
:
tests
)
{
try
{
Load
(
test
.
input
);
FAIL
()
<<
"Expected exception "
<<
test
.
expected_exception
<<
" for "
<<
test
.
name
<<
", input: "
<<
test
.
input
;
}
catch
(
const
ParserException
&
e
)
{
EXPECT_EQ
(
test
.
expected_exception
,
e
.
msg
);
}
}
}
TEST
(
NodeTest
,
LoadTildeAsNull
)
{
TEST
(
NodeTest
,
LoadTildeAsNull
)
{
Node
node
=
Load
(
"~"
);
Node
node
=
Load
(
"~"
);
ASSERT_TRUE
(
node
.
IsNull
());
ASSERT_TRUE
(
node
.
IsNull
());
...
...
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