[Checking stats] Keeping only stl like operations on json vector
This commit is contained in:
parent
c06ee977f4
commit
02c901ef11
@ -36,29 +36,21 @@ using json = nlohmann::json;
|
|||||||
// see http://llvm.org/docs/LibFuzzer.html
|
// see http://llvm.org/docs/LibFuzzer.html
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
// putting data in several STL containers
|
json j_vector2 = json::array();
|
||||||
std::vector<uint8_t> vec(data, data + size);
|
json j_vector3 = json::array();
|
||||||
|
|
||||||
// parsing from STL containers
|
for(std::size_t i = 0; i < j_vector.size(); ++i)
|
||||||
json j_vector(vec);
|
|
||||||
|
|
||||||
// iterating json array and testing get() method
|
|
||||||
for(json::iterator it = j_vector.begin(); it != j_vector.end(); ++it)
|
|
||||||
{
|
{
|
||||||
try
|
auto temp = j_vector.at(i);
|
||||||
{
|
// testing at() method
|
||||||
int temp = (*it).get<int>();
|
j_vector2.push_back(temp);
|
||||||
}
|
j_vector3.emplace_back(temp);
|
||||||
catch(const json::type_error)
|
// testing push_back and emplace back methods
|
||||||
{
|
|
||||||
// input might not be convertible to integer
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& element : j_vector)
|
// these three json vectors must be the same
|
||||||
{
|
assert(j_vector == j_vector2);
|
||||||
// range-based iteration
|
assert(j_vector == j_vector3);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user