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
bd4c282d
Commit
bd4c282d
authored
Feb 07, 2017
by
John Stiles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test coverage up
Add more tests! Good for coverage.
parent
0f8389e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
rapidjsontest.cpp
test/perftest/rapidjsontest.cpp
+29
-0
jsoncheckertest.cpp
test/unittest/jsoncheckertest.cpp
+44
-0
No files found.
test/perftest/rapidjsontest.cpp
View file @
bd4c282d
...
...
@@ -152,6 +152,35 @@ TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseIterativeInsitu_DummyHandler)) {
}
}
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
ReaderParseIterativePull_DummyHandler
))
{
for
(
size_t
i
=
0
;
i
<
kTrialCount
;
i
++
)
{
StringStream
s
(
json_
);
BaseReaderHandler
<>
h
;
Reader
reader
;
reader
.
IterativeParseInit
();
while
(
!
reader
.
IterativeParseComplete
())
{
if
(
!
reader
.
IterativeParseNext
<
kParseDefaultFlags
>
(
s
,
h
))
break
;
}
EXPECT_FALSE
(
reader
.
HasParseError
());
}
}
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
ReaderParseIterativePullInsitu_DummyHandler
))
{
for
(
size_t
i
=
0
;
i
<
kTrialCount
;
i
++
)
{
memcpy
(
temp_
,
json_
,
length_
+
1
);
InsituStringStream
s
(
temp_
);
BaseReaderHandler
<>
h
;
Reader
reader
;
reader
.
IterativeParseInit
();
while
(
!
reader
.
IterativeParseComplete
())
{
if
(
!
reader
.
IterativeParseNext
<
kParseDefaultFlags
|
kParseInsituFlag
>
(
s
,
h
))
break
;
}
EXPECT_FALSE
(
reader
.
HasParseError
());
}
}
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
ReaderParse_DummyHandler_ValidateEncoding
))
{
for
(
size_t
i
=
0
;
i
<
kTrialCount
;
i
++
)
{
StringStream
s
(
json_
);
...
...
test/unittest/jsoncheckertest.cpp
View file @
bd4c282d
...
...
@@ -48,6 +48,24 @@ static char* ReadFile(const char* filename, size_t& length) {
return
json
;
}
struct
NoOpHandler
{
bool
Null
()
{
return
true
;
}
bool
Bool
(
bool
)
{
return
true
;
}
bool
Int
(
int
)
{
return
true
;
}
bool
Uint
(
unsigned
)
{
return
true
;
}
bool
Int64
(
int64_t
)
{
return
true
;
}
bool
Uint64
(
uint64_t
)
{
return
true
;
}
bool
Double
(
double
)
{
return
true
;
}
bool
RawNumber
(
const
char
*
,
SizeType
,
bool
)
{
return
true
;
}
bool
String
(
const
char
*
,
SizeType
,
bool
)
{
return
true
;
}
bool
StartObject
()
{
return
true
;
}
bool
Key
(
const
char
*
,
SizeType
,
bool
)
{
return
true
;
}
bool
EndObject
(
SizeType
)
{
return
true
;
}
bool
StartArray
()
{
return
true
;
}
bool
EndArray
(
SizeType
)
{
return
true
;
}
};
TEST
(
JsonChecker
,
Reader
)
{
char
filename
[
256
];
...
...
@@ -67,13 +85,26 @@ TEST(JsonChecker, Reader) {
continue
;
}
// Test stack-based parsing.
GenericDocument
<
UTF8
<>
,
CrtAllocator
>
document
;
// Use Crt allocator to check exception-safety (no memory leak)
document
.
Parse
(
json
);
EXPECT_TRUE
(
document
.
HasParseError
())
<<
filename
;
// Test iterative parsing.
document
.
Parse
<
kParseIterativeFlag
>
(
json
);
EXPECT_TRUE
(
document
.
HasParseError
())
<<
filename
;
// Test iterative pull-parsing.
Reader
reader
;
StringStream
ss
(
json
);
NoOpHandler
h
;
reader
.
IterativeParseInit
();
while
(
!
reader
.
IterativeParseComplete
())
{
if
(
!
reader
.
IterativeParseNext
<
kParseDefaultFlags
>
(
ss
,
h
))
break
;
}
EXPECT_TRUE
(
reader
.
HasParseError
())
<<
filename
;
free
(
json
);
}
...
...
@@ -87,12 +118,25 @@ TEST(JsonChecker, Reader) {
continue
;
}
// Test stack-based parsing.
GenericDocument
<
UTF8
<>
,
CrtAllocator
>
document
;
// Use Crt allocator to check exception-safety (no memory leak)
document
.
Parse
(
json
);
EXPECT_FALSE
(
document
.
HasParseError
())
<<
filename
;
// Test iterative parsing.
document
.
Parse
<
kParseIterativeFlag
>
(
json
);
EXPECT_FALSE
(
document
.
HasParseError
())
<<
filename
;
// Test iterative pull-parsing.
Reader
reader
;
StringStream
ss
(
json
);
NoOpHandler
h
;
reader
.
IterativeParseInit
();
while
(
!
reader
.
IterativeParseComplete
())
{
if
(
!
reader
.
IterativeParseNext
<
kParseDefaultFlags
>
(
ss
,
h
))
break
;
}
EXPECT_FALSE
(
reader
.
HasParseError
())
<<
filename
;
free
(
json
);
}
...
...
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