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
442cc9b6
Commit
442cc9b6
authored
Dec 11, 2013
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added debug output to test cases
parent
81367a9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
test/JSON_test.cc
test/JSON_test.cc
+24
-0
No files found.
test/JSON_test.cc
View file @
442cc9b6
...
...
@@ -6,6 +6,8 @@
#include <sstream>
void
test_null
()
{
std
::
cerr
<<
"entering test_null()
\n
"
;
/* a null object */
// construct
...
...
@@ -72,16 +74,24 @@ void test_null() {
}
catch
(
const
std
::
exception
&
ex
)
{
assert
(
ex
.
what
()
==
std
::
string
(
"cannot cast null to JSON string"
));
}
std
::
cerr
<<
"leaving test_null()
\n
"
;
}
void
test_bool
()
{
std
::
cerr
<<
"entering test_bool()
\n
"
;
JSON
True
=
true
;
JSON
False
=
false
;
bool
x
=
True
;
std
::
cerr
<<
"leaving test_bool()
\n
"
;
}
void
test_string
()
{
std
::
cerr
<<
"entering test_string()
\n
"
;
/* a string object */
// construct
...
...
@@ -149,9 +159,13 @@ void test_string() {
std
::
string
s2
=
a
;
assert
(
*
s1
==
s2
);
}
std
::
cerr
<<
"leaving test_string()
\n
"
;
}
void
test_array
()
{
std
::
cerr
<<
"entering test_array()
\n
"
;
JSON
a
;
a
+=
JSON
();
a
+=
1
;
...
...
@@ -275,9 +289,13 @@ void test_array() {
assert
(
array
->
size
()
==
a
.
size
());
assert
(
array
->
empty
()
==
a
.
empty
());
}
std
::
cerr
<<
"leaving test_array()
\n
"
;
}
void
test_object
()
{
std
::
cerr
<<
"entering test_object()
\n
"
;
// check find()
{
JSON
o
;
...
...
@@ -299,9 +317,13 @@ void test_object() {
i
=
a
.
find
(
"foo"
);
assert
(
i
==
a
.
end
());
}
std
::
cerr
<<
"leaving test_object()
\n
"
;
}
void
test_streaming
()
{
std
::
cerr
<<
"entering test_streaming()
\n
"
;
// stream text representation into stream
std
::
stringstream
i
;
i
<<
"{
\"
foo
\"
: true,
\"
baz
\"
: [1,2,3,4] }"
;
...
...
@@ -347,6 +369,8 @@ void test_streaming() {
JSON
j
;
j
<<
escaped_stream
;
}
std
::
cerr
<<
"leaving test_streaming()
\n
"
;
}
int
main
()
{
...
...
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