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
e8dba10f
Unverified
Commit
e8dba10f
authored
4 years ago
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
c190a72f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+1
-1
test/src/unit-diagnostics.cpp
test/src/unit-diagnostics.cpp
+7
-0
No files found.
single_include/nlohmann/json.hpp
View file @
e8dba10f
...
@@ -12739,7 +12739,7 @@ class json_pointer
...
@@ -12739,7 +12739,7 @@ class json_pointer
{
{
if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
{
{
JSON_THROW
(
detail
::
type_error
::
create
(
315
,
"values in object must be primitive"
,
diagnostics_t
(
element
)));
JSON_THROW(detail::type_error::create(315, "values in object must be primitive", diagnostics_t(element
.second
)));
}
}
// assign value to reference pointed to by JSON pointer; Note that if
// assign value to reference pointed to by JSON pointer; Note that if
...
...
This diff is collapsed.
Click to expand it.
test/src/unit-diagnostics.cpp
View file @
e8dba10f
...
@@ -101,4 +101,11 @@ TEST_CASE("Better diagnostics")
...
@@ -101,4 +101,11 @@ TEST_CASE("Better diagnostics")
CHECK_THROWS_WITH_AS
(
json
({
"0"
,
"0"
})[
1
].
get
<
int
>
(),
"[json.exception.type_error.302] (/1) type must be number, but is string"
,
json
::
type_error
);
CHECK_THROWS_WITH_AS
(
json
({
"0"
,
"0"
})[
1
].
get
<
int
>
(),
"[json.exception.type_error.302] (/1) type must be number, but is string"
,
json
::
type_error
);
CHECK_THROWS_WITH_AS
(
json
({
"0"
,
"1"
})[
1
].
get
<
int
>
(),
"[json.exception.type_error.302] (/1) type must be number, but is string"
,
json
::
type_error
);
CHECK_THROWS_WITH_AS
(
json
({
"0"
,
"1"
})[
1
].
get
<
int
>
(),
"[json.exception.type_error.302] (/1) type must be number, but is string"
,
json
::
type_error
);
}
}
SECTION
(
"Regression test for https://github.com/nlohmann/json/pull/2562/files/380a613f2b5d32425021129cd1f371ddcfd54ddf#r563259793"
)
{
json
j
;
j
[
"/foo"
]
=
{
1
,
2
,
3
};
CHECK_THROWS_WITH_AS
(
j
.
unflatten
(),
"[json.exception.type_error.315] (/~1foo) values in object must be primitive"
,
json
::
type_error
);
}
}
}
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