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
d1b30250
Unverified
Commit
d1b30250
authored
Feb 26, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
added missing tests
parent
f1cd15ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
unit-constructor1.cpp
test/src/unit-constructor1.cpp
+9
-0
unit-conversions.cpp
test/src/unit-conversions.cpp
+4
-0
unit-regression.cpp
test/src/unit-regression.cpp
+4
-1
No files found.
test/src/unit-constructor1.cpp
View file @
d1b30250
...
@@ -699,6 +699,15 @@ TEST_CASE("constructors")
...
@@ -699,6 +699,15 @@ TEST_CASE("constructors")
json
j
(
n
);
json
j
(
n
);
CHECK
(
j
.
type
()
==
json
::
value_t
::
number_float
);
CHECK
(
j
.
type
()
==
json
::
value_t
::
number_float
);
}
}
SECTION
(
"infinity"
)
{
// infinity is stored as null
// should change in the future: https://github.com/nlohmann/json/issues/388
json
::
number_float_t
n
(
std
::
numeric_limits
<
json
::
number_float_t
>::
infinity
());
json
j
(
n
);
CHECK
(
j
.
type
()
==
json
::
value_t
::
null
);
}
}
}
SECTION
(
"create a floating-point number (implicit)"
)
SECTION
(
"create a floating-point number (implicit)"
)
...
...
test/src/unit-conversions.cpp
View file @
d1b30250
...
@@ -182,6 +182,10 @@ TEST_CASE("value conversion")
...
@@ -182,6 +182,10 @@ TEST_CASE("value conversion")
std
::
vector
<
float
>
v
;
std
::
vector
<
float
>
v
;
CHECK_THROWS_AS
(
nlohmann
::
from_json
(
j
,
v
),
std
::
logic_error
);
CHECK_THROWS_AS
(
nlohmann
::
from_json
(
j
,
v
),
std
::
logic_error
);
CHECK
(
v
.
capacity
()
==
j
.
size
());
CHECK
(
v
.
capacity
()
==
j
.
size
());
// make sure all values are properly copied
std
::
vector
<
int
>
v2
=
json
({
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
});
CHECK
(
v2
.
size
()
==
10
);
}
}
#endif
#endif
}
}
...
...
test/src/unit-regression.cpp
View file @
d1b30250
...
@@ -63,7 +63,7 @@ TEST_CASE("regression tests")
...
@@ -63,7 +63,7 @@ TEST_CASE("regression tests")
SECTION
(
"pull request #71 - handle enum type"
)
SECTION
(
"pull request #71 - handle enum type"
)
{
{
enum
{
t
=
0
,
u
=
1
};
enum
{
t
=
0
,
u
=
1
02
};
json
j
=
json
::
array
();
json
j
=
json
::
array
();
j
.
push_back
(
t
);
j
.
push_back
(
t
);
...
@@ -73,6 +73,9 @@ TEST_CASE("regression tests")
...
@@ -73,6 +73,9 @@ TEST_CASE("regression tests")
auto
anon_enum_value
=
j2
.
get
<
decltype
(
u
)
>
();
auto
anon_enum_value
=
j2
.
get
<
decltype
(
u
)
>
();
CHECK
(
u
==
anon_enum_value
);
CHECK
(
u
==
anon_enum_value
);
// check if the actual value was stored
CHECK
(
j2
==
102
);
static_assert
(
std
::
is_same
<
decltype
(
anon_enum_value
),
decltype
(
u
)
>::
value
,
""
);
static_assert
(
std
::
is_same
<
decltype
(
anon_enum_value
),
decltype
(
u
)
>::
value
,
""
);
j
.
push_back
(
json
::
object
(
j
.
push_back
(
json
::
object
(
...
...
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