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
3c028685
Commit
3c028685
authored
Apr 13, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for Writer API for RAPIDJSON_HAS_STDSTRING
parent
3d82781a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
2 deletions
+22
-2
prettywriter.h
include/rapidjson/prettywriter.h
+1
-1
writer.h
include/rapidjson/writer.h
+1
-1
prettywritertest.cpp
test/unittest/prettywritertest.cpp
+11
-0
writertest.cpp
test/unittest/writertest.cpp
+9
-0
No files found.
include/rapidjson/prettywriter.h
View file @
3c028685
...
@@ -78,7 +78,7 @@ public:
...
@@ -78,7 +78,7 @@ public:
#if RAPIDJSON_HAS_STDSTRING
#if RAPIDJSON_HAS_STDSTRING
bool
String
(
const
std
::
basic_string
<
Ch
>&
str
)
{
bool
String
(
const
std
::
basic_string
<
Ch
>&
str
)
{
return
String
(
str
.
data
(),
SizeType
(
str
.
size
()));
return
String
(
str
.
data
(),
SizeType
(
str
.
size
()));
}
}
#endif
#endif
...
...
include/rapidjson/writer.h
View file @
3c028685
...
@@ -127,7 +127,7 @@ public:
...
@@ -127,7 +127,7 @@ public:
#if RAPIDJSON_HAS_STDSTRING
#if RAPIDJSON_HAS_STDSTRING
bool
String
(
const
std
::
basic_string
<
Ch
>&
str
)
{
bool
String
(
const
std
::
basic_string
<
Ch
>&
str
)
{
return
String
(
str
.
data
(),
SizeType
(
str
.
size
()));
return
String
(
str
.
data
(),
SizeType
(
str
.
size
()));
}
}
#endif
#endif
...
...
test/unittest/prettywritertest.cpp
View file @
3c028685
...
@@ -79,3 +79,14 @@ TEST(PrettyWriter, SetIndent) {
...
@@ -79,3 +79,14 @@ TEST(PrettyWriter, SetIndent) {
"}"
,
"}"
,
buffer
.
GetString
());
buffer
.
GetString
());
}
}
#if RAPIDJSON_HAS_STDSTRING
TEST
(
PrettyWriter
,
String_STDSTRING
)
{
StringBuffer
buffer
;
PrettyWriter
<
StringBuffer
>
writer
(
buffer
);
EXPECT_TRUE
(
writer
.
StartArray
());
EXPECT_TRUE
(
writer
.
String
(
std
::
string
(
"Hello
\n
"
)));
EXPECT_TRUE
(
writer
.
EndArray
());
EXPECT_STREQ
(
"[
\n
\"
Hello
\\
n
\"\n
]"
,
buffer
.
GetString
());
}
#endif
test/unittest/writertest.cpp
View file @
3c028685
...
@@ -89,6 +89,15 @@ TEST(Writer, String) {
...
@@ -89,6 +89,15 @@ TEST(Writer, String) {
TEST_ROUNDTRIP
(
"[
\"
Hello
\"
]"
);
TEST_ROUNDTRIP
(
"[
\"
Hello
\"
]"
);
TEST_ROUNDTRIP
(
"[
\"
Hello
\\
u0000World
\"
]"
);
TEST_ROUNDTRIP
(
"[
\"
Hello
\\
u0000World
\"
]"
);
TEST_ROUNDTRIP
(
"[
\"\\\"\\\\
/
\\
b
\\
f
\\
n
\\
r
\\
t
\"
]"
);
TEST_ROUNDTRIP
(
"[
\"\\\"\\\\
/
\\
b
\\
f
\\
n
\\
r
\\
t
\"
]"
);
#if RAPIDJSON_HAS_STDSTRING
{
StringBuffer
buffer
;
Writer
<
StringBuffer
>
writer
(
buffer
);
writer
.
String
(
std
::
string
(
"Hello
\n
"
));
EXPECT_STREQ
(
"
\"
Hello
\\
n
\"
"
,
buffer
.
GetString
());
}
#endif
}
}
TEST
(
Writer
,
Double
)
{
TEST
(
Writer
,
Double
)
{
...
...
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