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
a485aa8d
Commit
a485aa8d
authored
Aug 30, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup and improvement of branch coverage
parent
463ffb21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
29 deletions
+91
-29
json.hpp
src/json.hpp
+0
-0
json.hpp.re2c
src/json.hpp.re2c
+0
-0
unit-class_const_iterator.cpp
test/src/unit-class_const_iterator.cpp
+16
-0
unit-deserialization.cpp
test/src/unit-deserialization.cpp
+75
-29
No files found.
src/json.hpp
View file @
a485aa8d
This diff is collapsed.
Click to expand it.
src/json.hpp.re2c
View file @
a485aa8d
This diff is collapsed.
Click to expand it.
test/src/unit-class_const_iterator.cpp
View file @
a485aa8d
...
@@ -64,6 +64,22 @@ TEST_CASE("const_iterator class")
...
@@ -64,6 +64,22 @@ TEST_CASE("const_iterator class")
json
::
const_iterator
it2
(
&
j
);
json
::
const_iterator
it2
(
&
j
);
it2
=
it
;
it2
=
it
;
}
}
SECTION
(
"copy constructor from non-const iterator"
)
{
SECTION
(
"create from uninitialized iterator"
)
{
const
json
::
iterator
it
{};
json
::
const_iterator
cit
(
it
);
}
SECTION
(
"create from initialized iterator"
)
{
json
j
;
const
json
::
iterator
it
=
j
.
begin
();
json
::
const_iterator
cit
(
it
);
}
}
}
}
SECTION
(
"initialization"
)
SECTION
(
"initialization"
)
...
...
test/src/unit-deserialization.cpp
View file @
a485aa8d
...
@@ -33,41 +33,87 @@ using nlohmann::json;
...
@@ -33,41 +33,87 @@ using nlohmann::json;
TEST_CASE
(
"deserialization"
)
TEST_CASE
(
"deserialization"
)
{
{
SECTION
(
"s
tream
"
)
SECTION
(
"s
uccessful deserialization
"
)
{
{
std
::
stringstream
ss
;
SECTION
(
"stream"
)
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
{
json
j
=
json
::
parse
(
ss
);
std
::
stringstream
ss
;
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
}
json
j
=
json
::
parse
(
ss
);
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
}
SECTION
(
"string"
)
SECTION
(
"string"
)
{
{
auto
s
=
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
json
::
string_t
s
=
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
json
j
=
json
::
parse
(
s
);
json
j
=
json
::
parse
(
s
);
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
}
}
SECTION
(
"operator<<"
)
SECTION
(
"operator<<"
)
{
{
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
json
j
;
json
j
;
j
<<
ss
;
j
<<
ss
;
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
}
}
SECTION
(
"operator>>"
)
SECTION
(
"operator>>"
)
{
{
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
;
json
j
;
json
j
;
ss
>>
j
;
ss
>>
j
;
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
CHECK
(
j
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
}
SECTION
(
"user-defined string literal"
)
{
CHECK
(
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
_json
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
}
}
}
SECTION
(
"
user-defined string literal
"
)
SECTION
(
"
successful deserialization
"
)
{
{
CHECK
(
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}]"
_json
==
json
({
"foo"
,
1
,
2
,
3
,
false
,
{{
"one"
,
1
}}}));
SECTION
(
"stream"
)
{
std
::
stringstream
ss
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}"
;
CHECK_THROWS_AS
(
json
::
parse
(
ss
),
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
json
::
parse
(
ss
),
"parse error - unexpected end of input"
);
}
SECTION
(
"string"
)
{
json
::
string_t
s
=
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}"
;
CHECK_THROWS_AS
(
json
::
parse
(
s
),
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
json
::
parse
(
s
),
"parse error - unexpected end of input; expected ']'"
);
}
SECTION
(
"operator<<"
)
{
std
::
stringstream
ss
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}"
;
json
j
;
CHECK_THROWS_AS
(
j
<<
ss
,
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
j
<<
ss
,
"parse error - unexpected end of input"
);
}
SECTION
(
"operator>>"
)
{
std
::
stringstream
ss
;
ss
<<
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}"
;
json
j
;
CHECK_THROWS_AS
(
ss
>>
j
,
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
ss
>>
j
,
"parse error - unexpected end of input"
);
}
SECTION
(
"user-defined string literal"
)
{
CHECK_THROWS_AS
(
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}"
_json
,
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
"[
\"
foo
\"
,1,2,3,false,{
\"
one
\"
:1}"
_json
,
"parse error - unexpected end of input; expected ']'"
);
}
}
}
}
}
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