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
e6013608
Unverified
Commit
e6013608
authored
Sep 12, 2021
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
improve coverage
parent
96b9877d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
0 deletions
+116
-0
test/src/unit-bon8.cpp
test/src/unit-bon8.cpp
+116
-0
No files found.
test/src/unit-bon8.cpp
View file @
e6013608
...
...
@@ -38,6 +38,84 @@ using nlohmann::json;
#include <test_data.hpp>
#include "test_utils.hpp"
namespace
{
class
SaxCountdown
{
public:
explicit
SaxCountdown
(
const
int
count
)
:
events_left
(
count
)
{}
bool
null
()
{
return
events_left
--
>
0
;
}
bool
boolean
(
bool
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
number_integer
(
json
::
number_integer_t
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
number_unsigned
(
json
::
number_unsigned_t
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
number_float
(
json
::
number_float_t
/*unused*/
,
const
std
::
string
&
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
string
(
std
::
string
&
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
binary
(
std
::
vector
<
std
::
uint8_t
>&
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
start_object
(
std
::
size_t
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
key
(
std
::
string
&
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
end_object
()
{
return
events_left
--
>
0
;
}
bool
start_array
(
std
::
size_t
/*unused*/
)
{
return
events_left
--
>
0
;
}
bool
end_array
()
{
return
events_left
--
>
0
;
}
bool
parse_error
(
std
::
size_t
/*unused*/
,
const
std
::
string
&
/*unused*/
,
const
json
::
exception
&
/*unused*/
)
// NOLINT(readability-convert-member-functions-to-static)
{
return
false
;
}
private:
int
events_left
=
0
;
};
}
// namespace
TEST_CASE
(
"BON8"
)
{
SECTION
(
"individual values"
)
...
...
@@ -732,4 +810,42 @@ TEST_CASE("BON8")
}
}
}
SECTION
(
"SAX aborts"
)
{
SECTION
(
"start_array(len)"
)
{
std
::
vector
<
uint8_t
>
v
=
{
0x80
};
SaxCountdown
scp
(
0
);
CHECK
(
!
json
::
sax_parse
(
v
,
&
scp
,
json
::
input_format_t
::
bon8
));
}
SECTION
(
"error in array"
)
{
std
::
vector
<
uint8_t
>
v
=
{
0x81
};
SaxCountdown
scp
(
1000
);
CHECK
(
!
json
::
sax_parse
(
v
,
&
scp
,
json
::
input_format_t
::
bon8
));
}
SECTION
(
"start_object(len)"
)
{
std
::
vector
<
uint8_t
>
v
=
{
0x86
};
SaxCountdown
scp
(
0
);
CHECK
(
!
json
::
sax_parse
(
v
,
&
scp
,
json
::
input_format_t
::
bon8
));
}
SECTION
(
"key()"
)
{
std
::
vector
<
uint8_t
>
v
=
{
0x87
,
'f'
,
'o'
,
'o'
,
0xFF
,
0xFA
};
SaxCountdown
scp
(
1
);
CHECK
(
!
json
::
sax_parse
(
v
,
&
scp
,
json
::
input_format_t
::
bon8
));
}
SECTION
(
"error in object"
)
{
std
::
vector
<
uint8_t
>
v
=
{
0x87
,
'f'
,
'o'
,
'o'
,
0xFF
};
SaxCountdown
scp
(
1000
);
CHECK
(
!
json
::
sax_parse
(
v
,
&
scp
,
json
::
input_format_t
::
bon8
));
}
}
}
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