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
34430994
Unverified
Commit
34430994
authored
May 09, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
add tests for binary type
parent
b036ace2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
test/src/unit-bson.cpp
test/src/unit-bson.cpp
+19
-0
test/src/unit-constructor1.cpp
test/src/unit-constructor1.cpp
+14
-0
No files found.
test/src/unit-bson.cpp
View file @
34430994
...
...
@@ -851,6 +851,25 @@ TEST_CASE("Incomplete BSON Input")
}
}
TEST_CASE
(
"Negative size of binary value"
)
{
// invalid BSON: the size of the binary value is -1
std
::
vector
<
std
::
uint8_t
>
input
=
{
0x21
,
0x00
,
0x00
,
0x00
,
// size (little endian)
0x05
,
// entry: binary
'e'
,
'n'
,
't'
,
'r'
,
'y'
,
'\x00'
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
// size of binary (little endian)
0x05
,
// MD5 binary subtype
0xd7
,
0x7e
,
0x27
,
0x54
,
0xbe
,
0x12
,
0x37
,
0xfe
,
0xd6
,
0x0c
,
0x33
,
0x98
,
0x30
,
0x3b
,
0x8d
,
0xc4
,
0x00
// end marker
};
CHECK_THROWS_AS
(
json
::
from_bson
(
input
),
json
::
parse_error
);
CHECK_THROWS_WITH
(
json
::
from_bson
(
input
),
"[json.exception.parse_error.112] parse error at byte 15: syntax error while parsing BSON binary: byte array length cannot be negative, is -1"
);
}
TEST_CASE
(
"Unsupported BSON input"
)
{
std
::
vector
<
std
::
uint8_t
>
bson
=
...
...
test/src/unit-constructor1.cpp
View file @
34430994
...
...
@@ -1461,6 +1461,20 @@ TEST_CASE("constructors")
CHECK
(
j
==
j_new
);
}
}
SECTION
(
"binary"
)
{
{
json
j
=
json
::
binary_array
({
1
,
2
,
3
});
json
j_new
(
j
.
begin
(),
j
.
end
());
CHECK
((
j
==
j_new
));
}
{
json
j
=
json
::
binary_array
({
1
,
2
,
3
});
json
j_new
(
j
.
cbegin
(),
j
.
cend
());
CHECK
((
j
==
j_new
));
}
}
}
SECTION
(
"construct with two invalid iterators"
)
...
...
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