Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
4cd341d4
Commit
4cd341d4
authored
Feb 10, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more unit tests
parent
29a8d43d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
2 deletions
+53
-2
json.hpp.re2c
src/json.hpp.re2c
+6
-2
unit.cpp
test/unit.cpp
+47
-0
No files found.
src/json.hpp.re2c
View file @
4cd341d4
...
@@ -1315,24 +1315,28 @@ class basic_json
...
@@ -1315,24 +1315,28 @@ class basic_json
{
{
return "null";
return "null";
}
}
case (value_t::object):
case (value_t::object):
{
{
return "object";
return "object";
}
}
case (value_t::array):
case (value_t::array):
{
{
return "array";
return "array";
}
}
case (value_t::string):
case (value_t::string):
{
{
return "string";
return "string";
}
}
case (value_t::boolean):
case (value_t::boolean):
{
{
return "boolean";
return "boolean";
}
}
case (value_t::number_integer):
case (value_t::number_float)
:
default
:
{
{
return "number";
return "number";
}
}
...
...
test/unit.cpp
View file @
4cd341d4
...
@@ -3821,3 +3821,50 @@ TEST_CASE("lexicographical comparison operators")
...
@@ -3821,3 +3821,50 @@ TEST_CASE("lexicographical comparison operators")
}
}
}
}
}
}
TEST_CASE
(
"serialization"
)
{
SECTION
(
"operator<<"
)
{
std
::
stringstream
ss
;
json
j
=
{
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}};
ss
<<
j
;
CHECK
(
ss
.
str
()
==
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
);
}
SECTION
(
"operator>>"
)
{
std
::
stringstream
ss
;
json
j
=
{
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}};
j
>>
ss
;
CHECK
(
ss
.
str
()
==
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
);
}
}
TEST_CASE
(
"deserialization"
)
{
SECTION
(
"string"
)
{
auto
s
=
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
json
j
=
json
::
parse
(
s
);
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
}
SECTION
(
"operator<<"
)
{
std
::
stringstream
ss
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
json
j
;
j
<<
ss
;
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
}
SECTION
(
"operator>>"
)
{
std
::
stringstream
ss
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
json
j
;
ss
>>
j
;
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
}
}
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