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
1a64cd09
Commit
1a64cd09
authored
Sep 19, 2016
by
Tallódi Mihály
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for Writer, PrettyWriter move constructors
parent
62dc1077
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
prettywritertest.cpp
test/unittest/prettywritertest.cpp
+31
-0
writertest.cpp
test/unittest/writertest.cpp
+27
-0
No files found.
test/unittest/prettywritertest.cpp
View file @
1a64cd09
...
...
@@ -18,6 +18,11 @@
#include "rapidjson/stringbuffer.h"
#include "rapidjson/filewritestream.h"
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
#endif
using
namespace
rapidjson
;
static
const
char
kJson
[]
=
"{
\"
hello
\"
:
\"
world
\"
,
\"
t
\"
:true,
\"
f
\"
:false,
\"
n
\"
:null,
\"
i
\"
:123,
\"
pi
\"
:3.1416,
\"
a
\"
:[1,2,3,-1],
\"
u64
\"
:1234567890123456789,
\"
i64
\"
:-1234567890123456789}"
;
...
...
@@ -201,3 +206,29 @@ TEST(PrettyWriter, RawValue) {
"}"
,
buffer
.
GetString
());
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
TEST
(
PrettyWriter
,
MoveCtor
)
{
StringBuffer
buffer
;
auto
writerGen
=
[](
StringBuffer
&
target
)
->
PrettyWriter
<
StringBuffer
>
{
PrettyWriter
<
StringBuffer
>
writer
(
target
);
writer
.
StartObject
();
writer
.
Key
(
"a"
);
writer
.
Int
(
1
);
return
std
::
move
(
writer
);
};
PrettyWriter
<
StringBuffer
>
writer
(
writerGen
(
buffer
));
writer
.
EndObject
();
EXPECT_TRUE
(
writer
.
IsComplete
());
EXPECT_STREQ
(
"{
\n
"
"
\"
a
\"
: 1
\n
"
"}"
,
buffer
.
GetString
());
}
#endif
#ifdef __clang__
RAPIDJSON_DIAG_POP
#endif
test/unittest/writertest.cpp
View file @
1a64cd09
...
...
@@ -20,6 +20,11 @@
#include "rapidjson/stringbuffer.h"
#include "rapidjson/memorybuffer.h"
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
#endif
using
namespace
rapidjson
;
TEST
(
Writer
,
Compact
)
{
...
...
@@ -495,3 +500,25 @@ TEST(Writer, RawValue) {
EXPECT_TRUE
(
writer
.
IsComplete
());
EXPECT_STREQ
(
"{
\"
a
\"
:1,
\"
raw
\"
:[
\"
Hello
\\
nWorld
\"
, 123.456]}"
,
buffer
.
GetString
());
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
TEST
(
Writer
,
MoveCtor
)
{
StringBuffer
buffer
;
auto
writerGen
=
[](
StringBuffer
&
target
)
->
Writer
<
StringBuffer
>
{
Writer
<
StringBuffer
>
writer
(
target
);
writer
.
StartObject
();
writer
.
Key
(
"a"
);
writer
.
Int
(
1
);
return
std
::
move
(
writer
);
};
Writer
<
StringBuffer
>
writer
(
writerGen
(
buffer
));
writer
.
EndObject
();
EXPECT_TRUE
(
writer
.
IsComplete
());
EXPECT_STREQ
(
"{
\"
a
\"
:1}"
,
buffer
.
GetString
());
}
#endif
#ifdef __clang__
RAPIDJSON_DIAG_POP
#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