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
3857e552
Commit
3857e552
authored
Jan 24, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
💄
ran "make pretty"
parent
9f103d19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
42 deletions
+42
-42
test/src/unit-udt.cpp
test/src/unit-udt.cpp
+42
-42
No files found.
test/src/unit-udt.cpp
View file @
3857e552
...
...
@@ -263,52 +263,52 @@ TEST_CASE("basic usage", "[udt]")
u8R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"
_json
;
SECTION
(
"via explicit calls to get"
)
{
const
auto
parsed_book
=
big_json
.
get
<
udt
::
contact_book
>
();
const
auto
book_name
=
big_json
[
"name"
].
get
<
udt
::
name
>
();
const
auto
contacts
=
big_json
[
"contacts"
].
get
<
std
::
vector
<
udt
::
contact
>>
();
const
auto
contact_json
=
big_json
[
"contacts"
].
at
(
0
);
const
auto
contact
=
contact_json
.
get
<
udt
::
contact
>
();
const
auto
person
=
contact_json
[
"person"
].
get
<
udt
::
person
>
();
const
auto
address
=
contact_json
[
"address"
].
get
<
udt
::
address
>
();
const
auto
age
=
contact_json
[
"person"
][
"age"
].
get
<
udt
::
age
>
();
const
auto
country
=
contact_json
[
"person"
][
"country"
].
get
<
udt
::
country
>
();
const
auto
name
=
contact_json
[
"person"
][
"name"
].
get
<
udt
::
name
>
();
CHECK
(
age
==
a
);
CHECK
(
name
==
n
);
CHECK
(
country
==
c
);
CHECK
(
address
==
addr
);
CHECK
(
person
==
sfinae_addict
);
CHECK
(
contact
==
cpp_programmer
);
CHECK
(
contacts
==
book
.
m_contacts
);
CHECK
(
book_name
==
udt
::
name
{
"C++"
});
CHECK
(
book
==
parsed_book
);
const
auto
parsed_book
=
big_json
.
get
<
udt
::
contact_book
>
();
const
auto
book_name
=
big_json
[
"name"
].
get
<
udt
::
name
>
();
const
auto
contacts
=
big_json
[
"contacts"
].
get
<
std
::
vector
<
udt
::
contact
>>
();
const
auto
contact_json
=
big_json
[
"contacts"
].
at
(
0
);
const
auto
contact
=
contact_json
.
get
<
udt
::
contact
>
();
const
auto
person
=
contact_json
[
"person"
].
get
<
udt
::
person
>
();
const
auto
address
=
contact_json
[
"address"
].
get
<
udt
::
address
>
();
const
auto
age
=
contact_json
[
"person"
][
"age"
].
get
<
udt
::
age
>
();
const
auto
country
=
contact_json
[
"person"
][
"country"
].
get
<
udt
::
country
>
();
const
auto
name
=
contact_json
[
"person"
][
"name"
].
get
<
udt
::
name
>
();
CHECK
(
age
==
a
);
CHECK
(
name
==
n
);
CHECK
(
country
==
c
);
CHECK
(
address
==
addr
);
CHECK
(
person
==
sfinae_addict
);
CHECK
(
contact
==
cpp_programmer
);
CHECK
(
contacts
==
book
.
m_contacts
);
CHECK
(
book_name
==
udt
::
name
{
"C++"
});
CHECK
(
book
==
parsed_book
);
}
SECTION
(
"implicit conversions"
)
{
const
udt
::
contact_book
parsed_book
=
big_json
;
const
udt
::
name
book_name
=
big_json
[
"name"
];
const
std
::
vector
<
udt
::
contact
>
contacts
=
big_json
[
"contacts"
];
const
auto
contact_json
=
big_json
[
"contacts"
].
at
(
0
);
const
udt
::
contact
contact
=
contact_json
;
const
udt
::
person
person
=
contact_json
[
"person"
];
const
udt
::
address
address
=
contact_json
[
"address"
];
const
udt
::
age
age
=
contact_json
[
"person"
][
"age"
];
const
udt
::
country
country
=
contact_json
[
"person"
][
"country"
];
const
udt
::
name
name
=
contact_json
[
"person"
][
"name"
];
CHECK
(
age
==
a
);
CHECK
(
name
==
n
);
CHECK
(
country
==
c
);
CHECK
(
address
==
addr
);
CHECK
(
person
==
sfinae_addict
);
CHECK
(
contact
==
cpp_programmer
);
CHECK
(
contacts
==
book
.
m_contacts
);
CHECK
(
book_name
==
udt
::
name
{
"C++"
});
CHECK
(
book
==
parsed_book
);
const
udt
::
contact_book
parsed_book
=
big_json
;
const
udt
::
name
book_name
=
big_json
[
"name"
];
const
std
::
vector
<
udt
::
contact
>
contacts
=
big_json
[
"contacts"
];
const
auto
contact_json
=
big_json
[
"contacts"
].
at
(
0
);
const
udt
::
contact
contact
=
contact_json
;
const
udt
::
person
person
=
contact_json
[
"person"
];
const
udt
::
address
address
=
contact_json
[
"address"
];
const
udt
::
age
age
=
contact_json
[
"person"
][
"age"
];
const
udt
::
country
country
=
contact_json
[
"person"
][
"country"
];
const
udt
::
name
name
=
contact_json
[
"person"
][
"name"
];
CHECK
(
age
==
a
);
CHECK
(
name
==
n
);
CHECK
(
country
==
c
);
CHECK
(
address
==
addr
);
CHECK
(
person
==
sfinae_addict
);
CHECK
(
contact
==
cpp_programmer
);
CHECK
(
contacts
==
book
.
m_contacts
);
CHECK
(
book_name
==
udt
::
name
{
"C++"
});
CHECK
(
book
==
parsed_book
);
}
}
}
...
...
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