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
c8138641
Commit
c8138641
authored
Jul 27, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add kParseStopWhenDoneFlag, its implementation and related unit tests
parent
c4ce48cd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
reader.h
include/rapidjson/reader.h
+0
-0
readertest.cpp
test/unittest/readertest.cpp
+32
-12
No files found.
include/rapidjson/reader.h
View file @
c8138641
This diff is collapsed.
Click to expand it.
test/unittest/readertest.cpp
View file @
c8138641
...
@@ -545,6 +545,38 @@ TEST(Reader, Parse_EmptyObject) {
...
@@ -545,6 +545,38 @@ TEST(Reader, Parse_EmptyObject) {
EXPECT_EQ
(
2u
,
h
.
step_
);
EXPECT_EQ
(
2u
,
h
.
step_
);
}
}
struct
ParseMultipleRootHandler
:
BaseReaderHandler
<>
{
ParseMultipleRootHandler
()
:
step_
(
0
)
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
bool
StartObject
()
{
EXPECT_EQ
(
0u
,
step_
);
step_
++
;
return
true
;
}
bool
EndObject
(
SizeType
)
{
EXPECT_EQ
(
1u
,
step_
);
step_
++
;
return
true
;
}
bool
StartArray
()
{
EXPECT_EQ
(
2u
,
step_
);
step_
++
;
return
true
;
}
bool
EndArray
(
SizeType
)
{
EXPECT_EQ
(
3u
,
step_
);
step_
++
;
return
true
;
}
unsigned
step_
;
};
template
<
unsigned
parseFlags
>
void
TestMultipleRoot
()
{
StringStream
s
(
"{}[]a"
);
ParseMultipleRootHandler
h
;
Reader
reader
;
EXPECT_TRUE
(
reader
.
Parse
<
parseFlags
>
(
s
,
h
));
EXPECT_EQ
(
2u
,
h
.
step_
);
EXPECT_TRUE
(
reader
.
Parse
<
parseFlags
>
(
s
,
h
));
EXPECT_EQ
(
4u
,
h
.
step_
);
EXPECT_EQ
(
'a'
,
s
.
Peek
());
}
TEST
(
Reader
,
Parse_MultipleRoot
)
{
TestMultipleRoot
<
kParseStopWhenDoneFlag
>
();
}
TEST
(
Reader
,
ParseIterative_MultipleRoot
)
{
TestMultipleRoot
<
kParseIterativeFlag
|
kParseStopWhenDoneFlag
>
();
}
#define TEST_ERROR(errorCode, str) \
#define TEST_ERROR(errorCode, str) \
{
\
{
\
char
buffer
[
1001
];
\
char
buffer
[
1001
];
\
...
@@ -932,18 +964,6 @@ TEST(Reader, IterativeParsing_ShortCircuit) {
...
@@ -932,18 +964,6 @@ TEST(Reader, IterativeParsing_ShortCircuit) {
}
}
}
}
TEST
(
Reader
,
IterativeParsing_LimitStackSize
)
{
BaseReaderHandler
<>
handler
;
Reader
reader
(
20
);
StringStream
is
(
"[[[]]]"
);
ParseResult
r
=
reader
.
Parse
<
kParseIterativeFlag
>
(
is
,
handler
);
EXPECT_TRUE
(
reader
.
HasParseError
());
EXPECT_EQ
(
kParseErrorStackSizeLimitExceeded
,
r
.
Code
());
EXPECT_EQ
(
2u
,
r
.
Offset
());
}
#ifdef __GNUC__
#ifdef __GNUC__
RAPIDJSON_DIAG_POP
RAPIDJSON_DIAG_POP
#endif
#endif
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