Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
87eafd8d
Unverified
Commit
87eafd8d
authored
Mar 12, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
added regression tests for #473
These tests currently pass without any adjustments to the source code.
parent
80dcf22f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
unit-regression.cpp
test/src/unit-regression.cpp
+50
-0
No files found.
test/src/unit-regression.cpp
View file @
87eafd8d
...
@@ -32,6 +32,7 @@ SOFTWARE.
...
@@ -32,6 +32,7 @@ SOFTWARE.
using
nlohmann
::
json
;
using
nlohmann
::
json
;
#include <fstream>
#include <fstream>
#include <list>
TEST_CASE
(
"regression tests"
)
TEST_CASE
(
"regression tests"
)
{
{
...
@@ -796,6 +797,55 @@ TEST_CASE("regression tests")
...
@@ -796,6 +797,55 @@ TEST_CASE("regression tests")
CHECK
(
s1
==
s2
);
CHECK
(
s1
==
s2
);
}
}
SECTION
(
"issue #473 - inconsistent behavior in conversion to array type"
)
{
json
j_array
=
{
1
,
2
,
3
,
4
};
json
j_number
=
42
;
json
j_null
=
nullptr
;
SECTION
(
"std::vector"
)
{
auto
create
=
[](
const
json
&
j
)
{
std
::
vector
<
int
>
v
=
j
;
};
CHECK_NOTHROW
(
create
(
j_array
));
CHECK_THROWS_AS
(
create
(
j_number
),
std
::
domain_error
);
CHECK_THROWS_WITH
(
create
(
j_number
),
"type must be array, but is number"
);
CHECK_THROWS_AS
(
create
(
j_null
),
std
::
domain_error
);
CHECK_THROWS_WITH
(
create
(
j_null
),
"type must be array, but is null"
);
}
SECTION
(
"std::list"
)
{
auto
create
=
[](
const
json
&
j
)
{
std
::
list
<
int
>
v
=
j
;
};
CHECK_NOTHROW
(
create
(
j_array
));
CHECK_THROWS_AS
(
create
(
j_number
),
std
::
domain_error
);
CHECK_THROWS_WITH
(
create
(
j_number
),
"type must be array, but is number"
);
CHECK_THROWS_AS
(
create
(
j_null
),
std
::
domain_error
);
CHECK_THROWS_WITH
(
create
(
j_null
),
"type must be array, but is null"
);
}
SECTION
(
"std::forward_list"
)
{
auto
create
=
[](
const
json
&
j
)
{
std
::
forward_list
<
int
>
v
=
j
;
};
CHECK_NOTHROW
(
create
(
j_array
));
CHECK_THROWS_AS
(
create
(
j_number
),
std
::
domain_error
);
CHECK_THROWS_WITH
(
create
(
j_number
),
"type must be array, but is number"
);
CHECK_THROWS_AS
(
create
(
j_null
),
std
::
domain_error
);
CHECK_THROWS_WITH
(
create
(
j_null
),
"type must be array, but is null"
);
}
}
SECTION
(
"issue #486 - json::value_t can't be a map's key type in VC++ 2015"
)
SECTION
(
"issue #486 - json::value_t can't be a map's key type in VC++ 2015"
)
{
{
// the code below must compile with MSVC
// the code below must compile with MSVC
...
...
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