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
0d530c9d
Unverified
Commit
0d530c9d
authored
Aug 10, 2021
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
⚗
try minimal example
parent
36394cc2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
38 deletions
+11
-38
test/src/unit-disabled_exceptions.cpp
test/src/unit-disabled_exceptions.cpp
+11
-38
No files found.
test/src/unit-disabled_exceptions.cpp
View file @
0d530c9d
...
...
@@ -65,18 +65,6 @@ namespace nlohmann
namespace
detail2
{
struct
position_t
{
std
::
size_t
chars_read_total
=
0
;
std
::
size_t
chars_read_current_line
=
0
;
std
::
size_t
lines_read
=
0
;
constexpr
operator
size_t
()
const
{
return
chars_read_total
;
}
};
class
exception
:
public
std
::
exception
{
public:
...
...
@@ -85,14 +73,12 @@ class exception : public std::exception
return
m
.
what
();
}
const
int
id
;
// NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
protected:
exception
(
int
id_
,
const
char
*
what_arg
)
:
id
(
id_
),
m
(
what_arg
)
{}
exception
(
const
char
*
what_arg
)
:
m
(
what_arg
)
{}
static
std
::
string
name
(
const
std
::
string
&
ename
,
int
id_
)
static
std
::
string
name
(
const
std
::
string
&
ename
)
{
return
"[json.exception."
+
ename
+
"
."
+
std
::
to_string
(
id_
)
+
"
] "
;
return
"[json.exception."
+
ename
+
"] "
;
}
private:
...
...
@@ -102,24 +88,16 @@ class exception : public std::exception
class
parse_error
:
public
exception
{
public:
static
parse_error
create
(
int
id_
,
const
position_t
&
pos
,
const
std
::
string
&
what_arg
)
static
parse_error
create
(
const
std
::
string
&
what_arg
)
{
std
::
string
w
=
exception
::
name
(
"parse_error"
,
id_
)
+
"parse error"
+
position_string
(
pos
)
+
": "
+
what_arg
;
return
parse_error
(
id_
,
pos
.
chars_read_total
,
w
.
c_str
());
std
::
string
w
=
exception
::
name
(
"parse_error"
)
+
what_arg
;
return
parse_error
(
w
.
c_str
());
}
const
std
::
size_t
byte
;
private:
parse_error
(
int
id_
,
std
::
size_t
byte_
,
const
char
*
what_arg
)
:
exception
(
id_
,
what_arg
),
byte
(
byte_
)
{}
static
std
::
string
position_string
(
const
position_t
&
pos
)
{
return
" at line "
+
std
::
to_string
(
pos
.
lines_read
+
1
)
+
", column "
+
std
::
to_string
(
pos
.
chars_read_current_line
);
}
parse_error
(
const
char
*
what_arg
)
:
exception
(
what_arg
)
{}
};
}
// namespace detail2
...
...
@@ -140,12 +118,7 @@ TEST_CASE("Tests with disabled exceptions")
SECTION
(
"test"
)
{
nlohmann
::
detail2
::
position_t
pos
;
pos
.
chars_read_total
=
100
;
pos
.
chars_read_current_line
=
50
;
pos
.
lines_read
=
1
;
auto
error
=
nlohmann
::
detail2
::
parse_error
::
create
(
100
,
pos
,
"foo"
);
CHECK
(
std
::
string
(
error
.
what
())
==
"[json.exception.parse_error.100] parse error at line 2, column 50: foo"
);
auto
error
=
nlohmann
::
detail2
::
parse_error
::
create
(
"foo"
);
CHECK
(
std
::
string
(
error
.
what
())
==
"[json.exception.parse_error] foo"
);
}
}
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