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
e2035df9
Commit
e2035df9
authored
May 30, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit test for issue #76
parent
58d7342b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
test/unit.cpp
test/unit.cpp
+32
-0
No files found.
test/unit.cpp
View file @
e2035df9
...
...
@@ -8747,4 +8747,36 @@ TEST_CASE("regression tests")
{
"game_type"
,
t
}
}));
}
SECTION
(
"issue #76 - dump() / parse() not idempotent"
)
{
// create JSON object
json
fields
;
fields
[
"one"
]
=
std
::
string
(
"one"
);
fields
[
"two"
]
=
std
::
string
(
"two three"
);
fields
[
"three"
]
=
std
::
string
(
"three
\"
four
\"
"
);
// create another JSON object by deserializing the serialization
std
::
string
payload
=
fields
.
dump
();
json
parsed_fields
=
json
::
parse
(
payload
);
// check individual fields to match both objects
CHECK
(
parsed_fields
[
"one"
]
==
fields
[
"one"
]);
CHECK
(
parsed_fields
[
"two"
]
==
fields
[
"two"
]);
CHECK
(
parsed_fields
[
"three"
]
==
fields
[
"three"
]);
// check individual fields to match original input
CHECK
(
parsed_fields
[
"one"
]
==
std
::
string
(
"one"
));
CHECK
(
parsed_fields
[
"two"
]
==
std
::
string
(
"two three"
));
CHECK
(
parsed_fields
[
"three"
]
==
std
::
string
(
"three
\"
four
\"
"
));
// check equality of the objects
CHECK
(
parsed_fields
==
fields
);
// check equality of the serialized objects
CHECK
(
fields
.
dump
()
==
parsed_fields
.
dump
());
// check everything in one line
CHECK
(
fields
==
json
::
parse
(
fields
.
dump
()));
}
}
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