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
83410955
Commit
83410955
authored
Aug 11, 2014
by
Philipp A. Hartmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
readertest.cpp: use CRTP to activate "ADD_FAILURE()" calls in handlers
parent
3755470f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
readertest.cpp
test/unittest/readertest.cpp
+11
-10
No files found.
test/unittest/readertest.cpp
View file @
83410955
...
...
@@ -31,7 +31,7 @@ RAPIDJSON_DIAG_OFF(effc++)
#endif
template
<
bool
expect
>
struct
ParseBoolHandler
:
BaseReaderHandler
<>
{
struct
ParseBoolHandler
:
BaseReaderHandler
<
UTF8
<>
,
ParseBoolHandler
<
expect
>
>
{
ParseBoolHandler
()
:
step_
(
0
)
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
// gcc 4.8.x generates warning in EXPECT_EQ(bool, bool) on this gtest version.
...
...
@@ -66,7 +66,7 @@ struct ParseIntHandler : BaseReaderHandler<UTF8<>, ParseIntHandler> {
int
actual_
;
};
struct
ParseUintHandler
:
BaseReaderHandler
<>
{
struct
ParseUintHandler
:
BaseReaderHandler
<
UTF8
<>
,
ParseUintHandler
>
{
ParseUintHandler
()
:
step_
(
0
),
actual_
()
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
bool
Uint
(
unsigned
i
)
{
actual_
=
i
;
step_
++
;
return
true
;
}
...
...
@@ -75,7 +75,7 @@ struct ParseUintHandler : BaseReaderHandler<> {
unsigned
actual_
;
};
struct
ParseInt64Handler
:
BaseReaderHandler
<>
{
struct
ParseInt64Handler
:
BaseReaderHandler
<
UTF8
<>
,
ParseInt64Handler
>
{
ParseInt64Handler
()
:
step_
(
0
),
actual_
()
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
bool
Int64
(
int64_t
i
)
{
actual_
=
i
;
step_
++
;
return
true
;
}
...
...
@@ -84,7 +84,7 @@ struct ParseInt64Handler : BaseReaderHandler<> {
int64_t
actual_
;
};
struct
ParseUint64Handler
:
BaseReaderHandler
<>
{
struct
ParseUint64Handler
:
BaseReaderHandler
<
UTF8
<>
,
ParseUint64Handler
>
{
ParseUint64Handler
()
:
step_
(
0
),
actual_
()
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
bool
Uint64
(
uint64_t
i
)
{
actual_
=
i
;
step_
++
;
return
true
;
}
...
...
@@ -93,7 +93,7 @@ struct ParseUint64Handler : BaseReaderHandler<> {
uint64_t
actual_
;
};
struct
ParseDoubleHandler
:
BaseReaderHandler
<>
{
struct
ParseDoubleHandler
:
BaseReaderHandler
<
UTF8
<>
,
ParseDoubleHandler
>
{
ParseDoubleHandler
()
:
step_
(
0
),
actual_
()
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
bool
Double
(
double
d
)
{
actual_
=
d
;
step_
++
;
return
true
;
}
...
...
@@ -209,7 +209,7 @@ TEST(Reader, ParseNumber_Error) {
}
template
<
typename
Encoding
>
struct
ParseStringHandler
:
BaseReaderHandler
<
Encoding
>
{
struct
ParseStringHandler
:
BaseReaderHandler
<
Encoding
,
ParseStringHandler
<
Encoding
>
>
{
ParseStringHandler
()
:
str_
(
0
),
length_
(
0
),
copy_
()
{}
~
ParseStringHandler
()
{
EXPECT_TRUE
(
str_
!=
0
);
if
(
copy_
)
free
(
const_cast
<
typename
Encoding
::
Ch
*>
(
str_
));
}
...
...
@@ -431,7 +431,7 @@ TEST(Reader, ParseString_Error) {
}
template
<
unsigned
count
>
struct
ParseArrayHandler
:
BaseReaderHandler
<>
{
struct
ParseArrayHandler
:
BaseReaderHandler
<
UTF8
<>
,
ParseArrayHandler
<
count
>
>
{
ParseArrayHandler
()
:
step_
(
0
)
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
...
...
@@ -482,9 +482,10 @@ TEST(Reader, ParseArray_Error) {
#undef TEST_ARRAY_ERROR
}
struct
ParseObjectHandler
:
BaseReaderHandler
<>
{
struct
ParseObjectHandler
:
BaseReaderHandler
<
UTF8
<>
,
ParseObjectHandler
>
{
ParseObjectHandler
()
:
step_
(
0
)
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
bool
Null
()
{
EXPECT_EQ
(
8u
,
step_
);
step_
++
;
return
true
;
}
bool
Bool
(
bool
b
)
{
switch
(
step_
)
{
...
...
@@ -549,7 +550,7 @@ TEST(Reader, ParseObject) {
}
}
struct
ParseEmptyObjectHandler
:
BaseReaderHandler
<>
{
struct
ParseEmptyObjectHandler
:
BaseReaderHandler
<
UTF8
<>
,
ParseEmptyObjectHandler
>
{
ParseEmptyObjectHandler
()
:
step_
(
0
)
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
...
...
@@ -567,7 +568,7 @@ TEST(Reader, Parse_EmptyObject) {
EXPECT_EQ
(
2u
,
h
.
step_
);
}
struct
ParseMultipleRootHandler
:
BaseReaderHandler
<>
{
struct
ParseMultipleRootHandler
:
BaseReaderHandler
<
UTF8
<>
,
ParseMultipleRootHandler
>
{
ParseMultipleRootHandler
()
:
step_
(
0
)
{}
bool
Default
()
{
ADD_FAILURE
();
return
false
;
}
...
...
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