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
ff763433
Commit
ff763433
authored
Jul 16, 2018
by
Minmin Gong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the code to adapt the new gtest.
parent
fdd2db93
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
55 deletions
+55
-55
platformtest.cpp
test/perftest/platformtest.cpp
+1
-1
cursorstreamwrappertest.cpp
test/unittest/cursorstreamwrappertest.cpp
+18
-18
istreamwrappertest.cpp
test/unittest/istreamwrappertest.cpp
+9
-9
pointertest.cpp
test/unittest/pointertest.cpp
+12
-12
readertest.cpp
test/unittest/readertest.cpp
+0
-0
stringbuffertest.cpp
test/unittest/stringbuffertest.cpp
+4
-4
valuetest.cpp
test/unittest/valuetest.cpp
+11
-11
No files found.
test/perftest/platformtest.cpp
View file @
ff763433
...
...
@@ -76,7 +76,7 @@ TEST_F(Platform, strlen) {
TEST_F
(
Platform
,
memcmp
)
{
for
(
int
i
=
0
;
i
<
kTrialCount
;
i
++
)
{
EXPECT_EQ
(
0
,
memcmp
(
temp_
,
json_
,
length_
));
EXPECT_EQ
(
0
u
,
memcmp
(
temp_
,
json_
,
length_
));
}
}
...
...
test/unittest/cursorstreamwrappertest.cpp
View file @
ff763433
...
...
@@ -38,8 +38,8 @@ TEST(CursorStreamWrapper, MissingFirstBracket) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
3
);
EXPECT_EQ
(
col
,
0
);
EXPECT_EQ
(
line
,
3
u
);
EXPECT_EQ
(
col
,
0
u
);
}
TEST
(
CursorStreamWrapper
,
MissingQuotes
)
{
...
...
@@ -47,8 +47,8 @@ TEST(CursorStreamWrapper, MissingQuotes) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
1
);
EXPECT_EQ
(
col
,
8
);
EXPECT_EQ
(
line
,
1
u
);
EXPECT_EQ
(
col
,
8
u
);
}
TEST
(
CursorStreamWrapper
,
MissingColon
)
{
...
...
@@ -56,8 +56,8 @@ TEST(CursorStreamWrapper, MissingColon) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
3
);
EXPECT_EQ
(
col
,
0
);
EXPECT_EQ
(
line
,
3
u
);
EXPECT_EQ
(
col
,
0
u
);
}
TEST
(
CursorStreamWrapper
,
MissingSecondQuotes
)
{
...
...
@@ -65,8 +65,8 @@ TEST(CursorStreamWrapper, MissingSecondQuotes) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
3
);
EXPECT_EQ
(
col
,
1
);
EXPECT_EQ
(
line
,
3
u
);
EXPECT_EQ
(
col
,
1
u
);
}
TEST
(
CursorStreamWrapper
,
MissingComma
)
{
...
...
@@ -74,8 +74,8 @@ TEST(CursorStreamWrapper, MissingComma) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
3
);
EXPECT_EQ
(
col
,
12
);
EXPECT_EQ
(
line
,
3
u
);
EXPECT_EQ
(
col
,
12
u
);
}
TEST
(
CursorStreamWrapper
,
MissingArrayBracket
)
{
...
...
@@ -83,8 +83,8 @@ TEST(CursorStreamWrapper, MissingArrayBracket) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
4
);
EXPECT_EQ
(
col
,
9
);
EXPECT_EQ
(
line
,
4
u
);
EXPECT_EQ
(
col
,
9
u
);
}
TEST
(
CursorStreamWrapper
,
MissingArrayComma
)
{
...
...
@@ -92,8 +92,8 @@ TEST(CursorStreamWrapper, MissingArrayComma) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
4
);
EXPECT_EQ
(
col
,
6
);
EXPECT_EQ
(
line
,
4
u
);
EXPECT_EQ
(
col
,
6
u
);
}
TEST
(
CursorStreamWrapper
,
MissingLastArrayBracket
)
{
...
...
@@ -101,8 +101,8 @@ TEST(CursorStreamWrapper, MissingLastArrayBracket) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json8
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
4
);
EXPECT_EQ
(
col
,
15
);
EXPECT_EQ
(
line
,
4
u
);
EXPECT_EQ
(
col
,
15
u
);
}
TEST
(
CursorStreamWrapper
,
MissingLastBracket
)
{
...
...
@@ -110,6 +110,6 @@ TEST(CursorStreamWrapper, MissingLastBracket) {
size_t
col
,
line
;
bool
ret
=
testJson
(
json9
,
line
,
col
);
EXPECT_TRUE
(
ret
);
EXPECT_EQ
(
line
,
4
);
EXPECT_EQ
(
col
,
16
);
EXPECT_EQ
(
line
,
4
u
);
EXPECT_EQ
(
col
,
16
u
);
}
test/unittest/istreamwrappertest.cpp
View file @
ff763433
...
...
@@ -35,21 +35,21 @@ static void TestStringStream() {
{
StringStreamType
iss
;
BasicIStreamWrapper
<
StringStreamType
>
is
(
iss
);
EXPECT_EQ
(
0
,
is
.
Tell
());
EXPECT_EQ
(
0
u
,
is
.
Tell
());
if
(
sizeof
(
Ch
)
==
1
)
{
EXPECT_EQ
(
0
,
is
.
Peek4
());
EXPECT_EQ
(
0
,
is
.
Tell
());
EXPECT_EQ
(
0
u
,
is
.
Tell
());
}
EXPECT_EQ
(
0
,
is
.
Peek
());
EXPECT_EQ
(
0
,
is
.
Take
());
EXPECT_EQ
(
0
,
is
.
Tell
());
EXPECT_EQ
(
0
u
,
is
.
Tell
());
}
{
Ch
s
[]
=
{
'A'
,
'B'
,
'C'
,
'\0'
};
StringStreamType
iss
(
s
);
BasicIStreamWrapper
<
StringStreamType
>
is
(
iss
);
EXPECT_EQ
(
0
,
is
.
Tell
());
EXPECT_EQ
(
0
u
,
is
.
Tell
());
if
(
sizeof
(
Ch
)
==
1
)
{
EXPECT_EQ
(
0
,
is
.
Peek4
());
// less than 4 bytes
}
...
...
@@ -59,7 +59,7 @@ static void TestStringStream() {
EXPECT_EQ
(
'A'
+
i
,
is
.
Peek
());
EXPECT_EQ
(
'A'
+
i
,
is
.
Take
());
}
EXPECT_EQ
(
3
,
is
.
Tell
());
EXPECT_EQ
(
3
u
,
is
.
Tell
());
EXPECT_EQ
(
0
,
is
.
Peek
());
EXPECT_EQ
(
0
,
is
.
Take
());
}
...
...
@@ -72,7 +72,7 @@ static void TestStringStream() {
const
Ch
*
c
=
is
.
Peek4
();
for
(
int
i
=
0
;
i
<
4
;
i
++
)
EXPECT_EQ
(
'A'
+
i
,
c
[
i
]);
EXPECT_EQ
(
0
,
is
.
Tell
());
EXPECT_EQ
(
0
u
,
is
.
Tell
());
}
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
EXPECT_EQ
(
static_cast
<
size_t
>
(
i
),
is
.
Tell
());
...
...
@@ -80,7 +80,7 @@ static void TestStringStream() {
EXPECT_EQ
(
'A'
+
i
,
is
.
Peek
());
EXPECT_EQ
(
'A'
+
i
,
is
.
Take
());
}
EXPECT_EQ
(
5
,
is
.
Tell
());
EXPECT_EQ
(
5
u
,
is
.
Tell
());
EXPECT_EQ
(
0
,
is
.
Peek
());
EXPECT_EQ
(
0
,
is
.
Take
());
}
...
...
@@ -129,7 +129,7 @@ TEST(IStreamWrapper, ifstream) {
Document
d
;
EXPECT_TRUE
(
!
d
.
ParseStream
(
eis
).
HasParseError
());
EXPECT_TRUE
(
d
.
IsObject
());
EXPECT_EQ
(
5
,
d
.
MemberCount
());
EXPECT_EQ
(
5
u
,
d
.
MemberCount
());
}
TEST
(
IStreamWrapper
,
fstream
)
{
...
...
@@ -140,7 +140,7 @@ TEST(IStreamWrapper, fstream) {
Document
d
;
EXPECT_TRUE
(
!
d
.
ParseStream
(
eis
).
HasParseError
());
EXPECT_TRUE
(
d
.
IsObject
());
EXPECT_EQ
(
5
,
d
.
MemberCount
());
EXPECT_EQ
(
5
u
,
d
.
MemberCount
());
}
// wifstream/wfstream only works on C++11 with codecvt_utf16
...
...
test/unittest/pointertest.cpp
View file @
ff763433
...
...
@@ -634,13 +634,13 @@ TEST(Pointer, Get) {
EXPECT_TRUE
(
Pointer
(
"/abc"
).
Get
(
d
)
==
0
);
size_t
unresolvedTokenIndex
;
EXPECT_TRUE
(
Pointer
(
"/foo/2"
).
Get
(
d
,
&
unresolvedTokenIndex
)
==
0
);
// Out of boundary
EXPECT_EQ
(
1
,
unresolvedTokenIndex
);
EXPECT_EQ
(
1
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
Pointer
(
"/foo/a"
).
Get
(
d
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo" is an array, cannot query by "a"
EXPECT_EQ
(
1
,
unresolvedTokenIndex
);
EXPECT_EQ
(
1
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
Pointer
(
"/foo/0/0"
).
Get
(
d
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo/0" is an string, cannot further query
EXPECT_EQ
(
2
,
unresolvedTokenIndex
);
EXPECT_EQ
(
2
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
Pointer
(
"/foo/0/a"
).
Get
(
d
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo/0" is an string, cannot further query
EXPECT_EQ
(
2
,
unresolvedTokenIndex
);
EXPECT_EQ
(
2
u
,
unresolvedTokenIndex
);
}
TEST
(
Pointer
,
GetWithDefault
)
{
...
...
@@ -959,13 +959,13 @@ TEST(Pointer, GetValueByPointer) {
size_t
unresolvedTokenIndex
;
EXPECT_TRUE
(
GetValueByPointer
(
d
,
"/foo/2"
,
&
unresolvedTokenIndex
)
==
0
);
// Out of boundary
EXPECT_EQ
(
1
,
unresolvedTokenIndex
);
EXPECT_EQ
(
1
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
GetValueByPointer
(
d
,
"/foo/a"
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo" is an array, cannot query by "a"
EXPECT_EQ
(
1
,
unresolvedTokenIndex
);
EXPECT_EQ
(
1
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
GetValueByPointer
(
d
,
"/foo/0/0"
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo/0" is an string, cannot further query
EXPECT_EQ
(
2
,
unresolvedTokenIndex
);
EXPECT_EQ
(
2
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
GetValueByPointer
(
d
,
"/foo/0/a"
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo/0" is an string, cannot further query
EXPECT_EQ
(
2
,
unresolvedTokenIndex
);
EXPECT_EQ
(
2
u
,
unresolvedTokenIndex
);
// const version
const
Value
&
v
=
d
;
...
...
@@ -973,13 +973,13 @@ TEST(Pointer, GetValueByPointer) {
EXPECT_EQ
(
&
d
[
"foo"
][
0
],
GetValueByPointer
(
v
,
"/foo/0"
));
EXPECT_TRUE
(
GetValueByPointer
(
v
,
"/foo/2"
,
&
unresolvedTokenIndex
)
==
0
);
// Out of boundary
EXPECT_EQ
(
1
,
unresolvedTokenIndex
);
EXPECT_EQ
(
1
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
GetValueByPointer
(
v
,
"/foo/a"
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo" is an array, cannot query by "a"
EXPECT_EQ
(
1
,
unresolvedTokenIndex
);
EXPECT_EQ
(
1
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
GetValueByPointer
(
v
,
"/foo/0/0"
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo/0" is an string, cannot further query
EXPECT_EQ
(
2
,
unresolvedTokenIndex
);
EXPECT_EQ
(
2
u
,
unresolvedTokenIndex
);
EXPECT_TRUE
(
GetValueByPointer
(
v
,
"/foo/0/a"
,
&
unresolvedTokenIndex
)
==
0
);
// "/foo/0" is an string, cannot further query
EXPECT_EQ
(
2
,
unresolvedTokenIndex
);
EXPECT_EQ
(
2
u
,
unresolvedTokenIndex
);
}
...
...
test/unittest/readertest.cpp
View file @
ff763433
This diff is collapsed.
Click to expand it.
test/unittest/stringbuffertest.cpp
View file @
ff763433
...
...
@@ -41,11 +41,11 @@ TEST(StringBuffer, Put) {
TEST
(
StringBuffer
,
PutN_Issue672
)
{
GenericStringBuffer
<
UTF8
<>
,
MemoryPoolAllocator
<>
>
buffer
;
EXPECT_EQ
(
0
,
buffer
.
GetSize
());
EXPECT_EQ
(
0
,
buffer
.
GetLength
());
EXPECT_EQ
(
0
u
,
buffer
.
GetSize
());
EXPECT_EQ
(
0
u
,
buffer
.
GetLength
());
rapidjson
::
PutN
(
buffer
,
' '
,
1
);
EXPECT_EQ
(
1
,
buffer
.
GetSize
());
EXPECT_EQ
(
1
,
buffer
.
GetLength
());
EXPECT_EQ
(
1
u
,
buffer
.
GetSize
());
EXPECT_EQ
(
1
u
,
buffer
.
GetLength
());
}
TEST
(
StringBuffer
,
Clear
)
{
...
...
test/unittest/valuetest.cpp
View file @
ff763433
...
...
@@ -26,11 +26,11 @@ using namespace rapidjson;
TEST
(
Value
,
Size
)
{
if
(
sizeof
(
SizeType
)
==
4
)
{
#if RAPIDJSON_48BITPOINTER_OPTIMIZATION
EXPECT_EQ
(
16
,
sizeof
(
Value
));
EXPECT_EQ
(
16
u
,
sizeof
(
Value
));
#elif RAPIDJSON_64BIT
EXPECT_EQ
(
24
,
sizeof
(
Value
));
EXPECT_EQ
(
24
u
,
sizeof
(
Value
));
#else
EXPECT_EQ
(
16
,
sizeof
(
Value
));
EXPECT_EQ
(
16
u
,
sizeof
(
Value
));
#endif
}
}
...
...
@@ -1135,10 +1135,10 @@ TEST(Value, ArrayHelper) {
a
.
PushBack
(
1
,
allocator
);
Value
::
Array
a2
(
a
);
// copy constructor
EXPECT_EQ
(
1
,
a2
.
Size
());
EXPECT_EQ
(
1
u
,
a2
.
Size
());
Value
::
Array
a3
=
a
;
EXPECT_EQ
(
1
,
a3
.
Size
());
EXPECT_EQ
(
1
u
,
a3
.
Size
());
Value
::
ConstArray
y
=
static_cast
<
const
Value
&>
(
x
).
GetArray
();
(
void
)
y
;
...
...
@@ -1175,7 +1175,7 @@ TEST(Value, ArrayHelper) {
y
.
PushBack
(
123
,
allocator
);
x
.
PushBack
(
y
.
GetArray
(),
allocator
);
// Implicit constructor to convert Array to GenericValue
EXPECT_EQ
(
1
,
x
.
Size
());
EXPECT_EQ
(
1
u
,
x
.
Size
());
EXPECT_EQ
(
123
,
x
[
0
][
0
].
GetInt
());
EXPECT_TRUE
(
y
.
IsArray
());
EXPECT_TRUE
(
y
.
Empty
());
...
...
@@ -1424,7 +1424,7 @@ static void TestObject(T& x, Allocator& allocator) {
for
(;
itr
!=
x
.
MemberEnd
();
++
itr
)
{
size_t
i
=
static_cast
<
size_t
>
((
itr
-
x
.
MemberBegin
()))
+
1
;
EXPECT_STREQ
(
itr
->
name
.
GetString
(),
keys
[
i
]);
EXPECT_EQ
(
i
,
itr
->
value
[
0
].
GetInt
());
EXPECT_EQ
(
static_cast
<
int
>
(
i
)
,
itr
->
value
[
0
].
GetInt
());
}
// Erase the last
...
...
@@ -1435,7 +1435,7 @@ static void TestObject(T& x, Allocator& allocator) {
for
(;
itr
!=
x
.
MemberEnd
();
++
itr
)
{
size_t
i
=
static_cast
<
size_t
>
(
itr
-
x
.
MemberBegin
())
+
1
;
EXPECT_STREQ
(
itr
->
name
.
GetString
(),
keys
[
i
]);
EXPECT_EQ
(
i
,
itr
->
value
[
0
].
GetInt
());
EXPECT_EQ
(
static_cast
<
int
>
(
i
)
,
itr
->
value
[
0
].
GetInt
());
}
// Erase the middle
...
...
@@ -1447,7 +1447,7 @@ static void TestObject(T& x, Allocator& allocator) {
size_t
i
=
static_cast
<
size_t
>
(
itr
-
x
.
MemberBegin
());
i
+=
(
i
<
4
)
?
1
:
2
;
EXPECT_STREQ
(
itr
->
name
.
GetString
(),
keys
[
i
]);
EXPECT_EQ
(
i
,
itr
->
value
[
0
].
GetInt
());
EXPECT_EQ
(
static_cast
<
int
>
(
i
)
,
itr
->
value
[
0
].
GetInt
());
}
// EraseMember(ConstMemberIterator, ConstMemberIterator)
...
...
@@ -1516,10 +1516,10 @@ TEST(Value, ObjectHelper) {
o
.
AddMember
(
"1"
,
1
,
allocator
);
Value
::
Object
o2
(
o
);
// copy constructor
EXPECT_EQ
(
1
,
o2
.
MemberCount
());
EXPECT_EQ
(
1
u
,
o2
.
MemberCount
());
Value
::
Object
o3
=
o
;
EXPECT_EQ
(
1
,
o3
.
MemberCount
());
EXPECT_EQ
(
1
u
,
o3
.
MemberCount
());
Value
::
ConstObject
y
=
static_cast
<
const
Value
&>
(
x
).
GetObject
();
(
void
)
y
;
...
...
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