added parsing from vector and deque
This commit is contained in:
parent
c66806b8bc
commit
57c8851439
@ -67,7 +67,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
std::unordered_multimap<uint8_t, uint8_t> ummp;
|
||||
|
||||
// converting each consecutive entry in the vector into a key-value pair
|
||||
for(int i=1; i<vec.size(); i+=2)
|
||||
for(int i=1; i<size; i+=2)
|
||||
{
|
||||
std::pair<uint8_t, uint8_t> insert_data = std::make_pair(vec[i-1], vec[i]);
|
||||
mp.insert(insert_data);
|
||||
@ -81,6 +81,27 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
json j_multimap(mmp);
|
||||
json j_umultimap(ummp);
|
||||
|
||||
try
|
||||
{
|
||||
// parse input directly
|
||||
json j1 = json::parse(data, data + size);
|
||||
// parse using vector
|
||||
json j_vec = json::parse(vec);
|
||||
// parse using deque
|
||||
json j_deq = json::parse(deq);
|
||||
|
||||
// all three must be equal
|
||||
assert(j1 == j_vec);
|
||||
assert(j1 == j_deq);
|
||||
}
|
||||
catch (const json::parse_error&)
|
||||
{
|
||||
// parse errors are ok, because input may be random bytes
|
||||
}
|
||||
catch (const json::out_of_range&)
|
||||
{
|
||||
// out of range errors may happen if provided sizes are excessive
|
||||
}
|
||||
// try
|
||||
// {
|
||||
// // step 1: parse input
|
||||
|
||||
Loading…
Reference in New Issue
Block a user