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
3038a785
Commit
3038a785
authored
Jul 11, 2014
by
thebusytypist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revise unittests: reset the handler before the transition which we are going to test.
parent
36434b66
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
16 deletions
+32
-16
en.h
include/rapidjson/error/en.h
+1
-1
reader.h
include/rapidjson/reader.h
+1
-1
readertest.cpp
test/unittest/readertest.cpp
+30
-14
No files found.
include/rapidjson/error/en.h
View file @
3038a785
...
...
@@ -38,7 +38,7 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErro
case
kParseErrorNumberMissFraction
:
return
RAPIDJSON_ERROR_STRING
(
"Miss fraction part in number."
);
case
kParseErrorNumberMissExponent
:
return
RAPIDJSON_ERROR_STRING
(
"Miss exponent in number."
);
case
kParseErrorUnspecificSyntaxError
:
return
RAPIDJSON_ERROR_STRING
(
"Unspecific syntax error."
);
case
kParseErrorUnspecificSyntaxError
:
return
RAPIDJSON_ERROR_STRING
(
"Unspecific syntax error."
);
default
:
return
RAPIDJSON_ERROR_STRING
(
"Unknown error."
);
...
...
include/rapidjson/reader.h
View file @
3038a785
...
...
@@ -82,7 +82,7 @@ enum ParseErrorCode {
kParseErrorNumberMissFraction
,
//!< Miss fraction part in number.
kParseErrorNumberMissExponent
,
//!< Miss exponent in number.
kParseErrorUnspecificSyntaxError
//!< General
syntax error.
kParseErrorUnspecificSyntaxError
//!< Unspecific
syntax error.
};
///////////////////////////////////////////////////////////////////////////////
...
...
test/unittest/readertest.cpp
View file @
3038a785
...
...
@@ -735,20 +735,24 @@ template<typename Encoding = UTF8<> >
struct
IterativeParsingReaderHandler
{
typedef
typename
Encoding
::
Ch
Ch
;
IterativeParsingReaderHandler
()
:
IsNullTriggered
(
false
),
IsBoolTriggered
(
false
),
IsIntTriggered
(
false
),
IsUintTriggered
(
false
),
IsInt64Triggered
(
false
),
IsUint64Triggered
(
false
),
IsDoubleTriggered
(
false
),
IsStringTriggered
(
false
),
IsStartObjectTriggered
(
false
),
IsEndObjectTriggered
(
false
),
MemberCount
(
0
),
IsStartArrayTriggered
(
false
),
ElementCount
(
0
)
{
IterativeParsingReaderHandler
()
{
Reset
();
}
void
Reset
()
{
IsNullTriggered
=
false
;
IsBoolTriggered
=
false
;
IsIntTriggered
=
false
;
IsUintTriggered
=
false
;
IsInt64Triggered
=
false
;
IsUint64Triggered
=
false
;
IsDoubleTriggered
=
false
;
IsStringTriggered
=
false
;
IsStartObjectTriggered
=
false
;
IsEndObjectTriggered
=
false
;
MemberCount
=
0
;
IsStartArrayTriggered
=
false
;
ElementCount
=
0
;
}
bool
IsNullTriggered
;
...
...
@@ -838,6 +842,7 @@ TEST(Reader, IterativeParsing_StateTransition_ObjectInitial) {
// ObjectInitial -> ObjectFinish -> Finish
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"{}"
,
1
);
handler
.
Reset
();
EXPECT_EQ
(
Reader
::
IterativeParsingObjectInitialState
,
state
);
Reader
::
IterativeParsingState
d
=
reader
.
Transit
<
kParseIterativeFlag
>
(
...
...
@@ -855,6 +860,7 @@ TEST(Reader, IterativeParsing_StateTransition_ObjectInitial) {
// ObjectInitial -> MemberKey
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"{
\"
key
\"
: 1}"
,
1
);
handler
.
Reset
();
EXPECT_EQ
(
Reader
::
IterativeParsingObjectInitialState
,
state
);
Reader
::
IterativeParsingState
d
=
reader
.
Transit
<
kParseIterativeFlag
>
(
...
...
@@ -962,6 +968,7 @@ TEST(Reader, IterativeParsing_StateTransition_MemberValue) {
// MemberValue -> ObjectFinish
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"{
\"
k
\"
: 123}"
,
9
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingMemberValueState
,
state
);
...
...
@@ -981,6 +988,7 @@ TEST(Reader, IterativeParsing_StateTransition_MemberValue) {
// MemberValue -> MemberDelimiter
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"{
\"
k
\"
: 1,
\"
e
\"
: 2}"
,
7
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingMemberValueState
,
state
);
...
...
@@ -999,6 +1007,7 @@ TEST(Reader, IterativeParsing_StateTransition_MemberValue) {
TEST
(
Reader
,
IterativeParsing_StateTransition_MemberDelimiter
)
{
// MemberDelimiter -> MemberKey
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"{
\"
k
\"
: 1,
\"
e
\"
: 2}"
,
9
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingMemberDelimiterState
,
state
);
...
...
@@ -1027,6 +1036,7 @@ TEST(Reader, IterativeParsing_StateTransition_ArrayInitial) {
// ArrayInitial -> ArrayFinish -> Finish
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"[]"
,
1
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingArrayInitialState
,
state
);
...
...
@@ -1056,6 +1066,7 @@ TEST(Reader, IterativeParsing_StateTransition_ArrayInitial) {
// ArrayInitial -> Element
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"[1]"
,
1
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingArrayInitialState
,
state
);
...
...
@@ -1075,6 +1086,7 @@ TEST(Reader, IterativeParsing_StateTransition_Element) {
// Element -> ArrayFinish -> Finish
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"[1]"
,
2
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingElementState
,
state
);
...
...
@@ -1094,6 +1106,7 @@ TEST(Reader, IterativeParsing_StateTransition_Element) {
// Element -> ElementDelimiter
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"[1, 2]"
,
2
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingElementState
,
state
);
...
...
@@ -1113,6 +1126,7 @@ TEST(Reader, IterativeParsing_StateTransition_ElementDelimiter) {
// ElementDelimiter -> ArrayInitial
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"[1, [1]]"
,
4
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingElementDelimiterState
,
state
);
...
...
@@ -1135,6 +1149,7 @@ TEST(Reader, IterativeParsing_StateTransition_ElementDelimiter) {
// ElementDelimiter -> ObjectInitial
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"[1, [1]]"
,
4
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingElementDelimiterState
,
state
);
...
...
@@ -1157,6 +1172,7 @@ TEST(Reader, IterativeParsing_StateTransition_ElementDelimiter) {
// ElementDelimiter -> Element
{
ITERATIVE_PARSING_PREPARE_STATE_UNTIL
(
"[1, 2]"
,
4
);
handler
.
Reset
();
EXPECT_FALSE
(
reader
.
HasParseError
());
EXPECT_EQ
(
Reader
::
IterativeParsingElementDelimiterState
,
state
);
...
...
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