Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
21539198
Commit
21539198
authored
Dec 28, 2014
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ more test cases
parent
1c10efb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
test/JSON_unit.cc
test/JSON_unit.cc
+20
-0
No files found.
test/JSON_unit.cc
View file @
21539198
...
...
@@ -153,7 +153,10 @@ TEST_CASE("array")
{
JSON
nonarray2
=
JSON
(
1
);
JSON
nonarray3
=
JSON
(
2
);
JSON
empty3
=
JSON
();
CHECK_THROWS_AS
(
nonarray2
.
push_back
(
nonarray3
),
std
::
runtime_error
);
CHECK_NOTHROW
(
empty3
.
push_back
(
nonarray3
));
CHECK
(
empty3
.
type
()
==
JSON
::
value_type
::
array
);
}
const
JSON
k
=
j
;
...
...
@@ -373,6 +376,18 @@ TEST_CASE("object")
bool
v4
=
j
[
std
::
string
(
"k4"
)];
CHECK
(
v4
==
true
);
}
{
const
std
::
string
v0
=
k
[
std
::
string
(
"k0"
)];
CHECK
(
v0
==
"v0"
);
auto
v1
=
k
[
std
::
string
(
"k1"
)];
CHECK
(
v1
==
nullptr
);
int
v2
=
k
[
std
::
string
(
"k2"
)];
CHECK
(
v2
==
42
);
double
v3
=
k
[
std
::
string
(
"k3"
)];
CHECK
(
v3
==
3.141
);
bool
v4
=
k
[
std
::
string
(
"k4"
)];
CHECK
(
v4
==
true
);
}
// write (replace)
j
[
"k0"
]
=
"new v0"
;
...
...
@@ -387,8 +402,13 @@ TEST_CASE("object")
// find
CHECK
(
j
.
find
(
"k0"
)
!=
j
.
end
());
CHECK
(
j
.
find
(
"v0"
)
==
j
.
end
());
CHECK
(
j
.
find
(
std
::
string
(
"v0"
))
==
j
.
end
());
JSON
::
const_iterator
i1
=
j
.
find
(
"k0"
);
JSON
::
iterator
i2
=
j
.
find
(
"k0"
);
CHECK
(
k
.
find
(
"k0"
)
!=
k
.
end
());
CHECK
(
k
.
find
(
"v0"
)
==
k
.
end
());
CHECK
(
k
.
find
(
std
::
string
(
"v0"
))
==
k
.
end
());
JSON
::
const_iterator
i22
=
k
.
find
(
"k0"
);
// at
CHECK_THROWS_AS
(
j
.
at
(
"foo"
),
std
::
out_of_range
);
...
...
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