From c06ee977f41b9f81cb89a4362447c01082a33d46 Mon Sep 17 00:00:00 2001 From: Tanuj Garg Date: Fri, 5 Jun 2020 22:50:40 +0530 Subject: [PATCH] [Checking stats] Keeping only iterating a json vector container --- test/src/fuzzer-parse_stl.cpp | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/src/fuzzer-parse_stl.cpp b/test/src/fuzzer-parse_stl.cpp index 38a417c4c..13d709a3d 100644 --- a/test/src/fuzzer-parse_stl.cpp +++ b/test/src/fuzzer-parse_stl.cpp @@ -38,27 +38,27 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // putting data in several STL containers std::vector vec(data, data + size); - std::deque deq(data, data + size); - std::list lst(data, data + size); - std::forward_list flist(data, data + size); - std::set st(data, data + size); - std::unordered_set uset(data, data + size); - std::multiset multist(data, data + size); - std::unordered_multiset umultiset(data, data + size); // parsing from STL containers json j_vector(vec); - json j_deque(deq); - json j_list(lst); - json j_flist(flist); - json j_set(st); - json j_uset(uset); - json j_multiset(multist); - json j_umultiset(umultiset); - // json must be same for sequence containers - assert(j_vector == j_deque); - assert(j_vector == j_list); - assert(j_vector == j_flist); + // iterating json array and testing get() method + for(json::iterator it = j_vector.begin(); it != j_vector.end(); ++it) + { + try + { + int temp = (*it).get(); + } + catch(const json::type_error) + { + // input might not be convertible to integer + } + } + + for(auto& element : j_vector) + { + // range-based iteration + } + return 0; }