Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
fa32ec89
Commit
fa32ec89
authored
Apr 15, 2015
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #302 from thebusytypist/issue298_coverage
Improve code coverage for iterative parsing
parents
631302e6
6ef29ff4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
18 deletions
+29
-18
reader.h
include/rapidjson/reader.h
+18
-18
readertest.cpp
test/unittest/readertest.cpp
+11
-0
No files found.
include/rapidjson/reader.h
View file @
fa32ec89
...
...
@@ -1227,14 +1227,9 @@ private:
// May return a new state on state pop.
template
<
unsigned
parseFlags
,
typename
InputStream
,
typename
Handler
>
RAPIDJSON_FORCEINLINE
IterativeParsingState
Transit
(
IterativeParsingState
src
,
Token
token
,
IterativeParsingState
dst
,
InputStream
&
is
,
Handler
&
handler
)
{
switch
(
dst
)
{
case
IterativeParsingStartState
:
RAPIDJSON_ASSERT
(
false
);
return
IterativeParsingErrorState
;
case
IterativeParsingFinishState
:
return
dst
;
(
void
)
token
;
switch
(
dst
)
{
case
IterativeParsingErrorState
:
return
dst
;
...
...
@@ -1273,12 +1268,9 @@ private:
return
dst
;
case
IterativeParsingKeyValueDelimiterState
:
if
(
token
==
ColonToken
)
{
is
.
Take
();
return
dst
;
}
else
return
IterativeParsingErrorState
;
RAPIDJSON_ASSERT
(
token
==
ColonToken
);
is
.
Take
();
return
dst
;
case
IterativeParsingMemberValueState
:
// Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.
...
...
@@ -1353,17 +1345,25 @@ private:
}
}
case
IterativeParsingValueState
:
default
:
// This branch is for IterativeParsingValueState actually.
// Use `default:` rather than
// `case IterativeParsingValueState:` is for code coverage.
// The IterativeParsingStartState is not enumerated in this switch-case.
// It is impossible for that case. And it can be caught by following assertion.
// The IterativeParsingFinishState is not enumerated in this switch-case either.
// It is a "derivative" state which cannot triggered from Predict() directly.
// Therefore it cannot happen here. And it can be caught by following assertion.
RAPIDJSON_ASSERT
(
dst
==
IterativeParsingValueState
);
// Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.
ParseValue
<
parseFlags
>
(
is
,
handler
);
if
(
HasParseError
())
{
return
IterativeParsingErrorState
;
}
return
IterativeParsingFinishState
;
default
:
RAPIDJSON_ASSERT
(
false
);
return
IterativeParsingErrorState
;
}
}
...
...
test/unittest/readertest.cpp
View file @
fa32ec89
...
...
@@ -1053,6 +1053,17 @@ TEST(Reader, IterativeParsing_ErrorHandling) {
TESTERRORHANDLING
(
"{
\"
a
\"
}"
,
kParseErrorObjectMissColon
,
4u
);
TESTERRORHANDLING
(
"{
\"
a
\"
: 1"
,
kParseErrorObjectMissCommaOrCurlyBracket
,
7u
);
TESTERRORHANDLING
(
"[1 2 3]"
,
kParseErrorArrayMissCommaOrSquareBracket
,
3u
);
TESTERRORHANDLING
(
"{
\"
a: 1"
,
kParseErrorStringMissQuotationMark
,
5u
);
// Any JSON value can be a valid root element in RFC7159.
TESTERRORHANDLING
(
"
\"
ab"
,
kParseErrorStringMissQuotationMark
,
2u
);
TESTERRORHANDLING
(
"truE"
,
kParseErrorValueInvalid
,
3u
);
TESTERRORHANDLING
(
"False"
,
kParseErrorValueInvalid
,
0u
);
TESTERRORHANDLING
(
"true, false"
,
kParseErrorDocumentRootNotSingular
,
4u
);
TESTERRORHANDLING
(
"false, false"
,
kParseErrorDocumentRootNotSingular
,
5u
);
TESTERRORHANDLING
(
"nulL"
,
kParseErrorValueInvalid
,
3u
);
TESTERRORHANDLING
(
"null , null"
,
kParseErrorDocumentRootNotSingular
,
5u
);
TESTERRORHANDLING
(
"1a"
,
kParseErrorDocumentRootNotSingular
,
1u
);
}
template
<
typename
Encoding
=
UTF8
<>
>
...
...
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