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
392c0338
Commit
392c0338
authored
7 years ago
by
Vitaliy Manushkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test refactoring
parent
51349537
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
18 deletions
+48
-18
test/src/unit-alt-string.cpp
test/src/unit-alt-string.cpp
+48
-18
No files found.
test/src/unit-alt-string.cpp
View file @
392c0338
...
...
@@ -142,24 +142,54 @@ using alt_json = nlohmann::basic_json <
TEST_CASE
(
"alternative string type"
)
{
SECTION
(
"dump"
)
{
{
alt_json
doc
;
doc
[
"pi"
]
=
3.141
;
alt_string
dump
=
doc
.
dump
();
CHECK
(
dump
==
R"({"pi":3.141})"
);
}
{
alt_json
doc
;
doc
[
"happy"
]
=
true
;
alt_string
dump
=
doc
.
dump
();
CHECK
(
dump
==
R"({"happy":true})"
);
}
{
alt_json
doc
;
doc
[
"name"
]
=
"I'm Batman"
;
alt_string
dump
=
doc
.
dump
();
CHECK
(
dump
==
R"({"name":"I'm Batman"})"
);
}
{
alt_json
doc
;
doc
[
"nothing"
]
=
nullptr
;
alt_string
dump
=
doc
.
dump
();
CHECK
(
dump
==
R"({"nothing":null})"
);
}
{
alt_json
doc
;
doc
[
"answer"
][
"everything"
]
=
42
;
doc
[
"list"
]
=
{
1
,
0
,
2
};
doc
[
"object"
]
=
{
{
"currency"
,
"USD"
},
{
"value"
,
42.99
}
};
alt_string
dump
=
doc
.
dump
();
CHECK
(
dump
==
R"({"answer":{"everything":42}})"
);
}
{
alt_json
doc
;
doc
[
"list"
]
=
{
1
,
0
,
2
};
alt_string
dump
=
doc
.
dump
();
CHECK
(
dump
==
R"({"list":[1,0,2]})"
);
}
const
char
*
const
expect_str
=
R"({"answer":{"everything":42},)"
R"("happy":true,"list":[1,0,2],)"
R"("name":"I'm Batman","nothing":null,)"
R"("object":{"currency":"USD","value":42.99},)"
R"("pi":3.141})"
;
CHECK
(
dump
==
expect_str
);
{
alt_json
doc
;
doc
[
"list"
]
=
{
1
,
0
,
2
};
alt_string
dump
=
doc
.
dump
();
CHECK
(
dump
==
R"({"list":[1,0,2]})"
);
}
}
}
This diff is collapsed.
Click to expand it.
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