Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
178c8d1f
Commit
178c8d1f
authored
Mar 26, 2016
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for parser exceptions for incomplete JSON.
parent
0a135252
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletions
+29
-1
test/integration/load_node_test.cpp
+29
-1
No files found.
test/integration/load_node_test.cpp
View file @
178c8d1f
...
...
@@ -198,5 +198,33 @@ TEST(NodeTest, ParseNodeStyle) {
EXPECT_EQ
(
EmitterStyle
::
Block
,
Load
(
"- foo
\n
- bar"
).
Style
());
EXPECT_EQ
(
EmitterStyle
::
Block
,
Load
(
"foo: bar"
).
Style
());
}
struct
ParserExceptionTestCase
{
std
::
string
name
;
std
::
string
input
;
std
::
string
expected_exception
;
};
TEST
(
NodeTest
,
IncompleteJson
)
{
std
::
vector
<
ParserExceptionTestCase
>
tests
=
{
{
"JSON map without value"
,
"{
\"
access
\"
"
,
ErrorMsg
::
END_OF_MAP_FLOW
},
{
"JSON map with colon but no value"
,
"{
\"
access
\"
:"
,
ErrorMsg
::
END_OF_MAP_FLOW
},
{
"JSON map with unclosed value quote"
,
"{
\"
access
\"
:
\"
"
,
ErrorMsg
::
END_OF_MAP_FLOW
},
{
"JSON map without end brace"
,
"{
\"
access
\"
:
\"
abc
\"
"
,
ErrorMsg
::
END_OF_MAP_FLOW
},
};
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
);
}
}
}
}
}
// namespace
}
// namespace YAML
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