From f1f38cf908a94ef412afb65c9b9d3a6f13bc6ddf Mon Sep 17 00:00:00 2001 From: Tanuj Garg Date: Sat, 6 Jun 2020 00:45:03 +0530 Subject: [PATCH] [Checking stats] keeping only stl like operations --- test/src/fuzzer-parse_stl.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/test/src/fuzzer-parse_stl.cpp b/test/src/fuzzer-parse_stl.cpp index 78fd617ac..3620db453 100644 --- a/test/src/fuzzer-parse_stl.cpp +++ b/test/src/fuzzer-parse_stl.cpp @@ -42,28 +42,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // parsing from STL containers json j_vector(vec); - std::map mp; - std::unordered_map umap; - std::multimap multimp; - std::unordered_multimap umultimap; + json j_vector2 = json::array(); + json j_vector3 = json::array(); - // converting each consecutive entry in the vector into a key-value pair and adding them to map - for(std::size_t i = 1; i < vec.size(); i+=2) + for(std::size_t i = 0; i < j_vector.size(); ++i) { - int last_entry = static_cast(vec[i-1]); - std::string key_str = std::to_string(last_entry); - std::pair insert_data = std::make_pair(key_str, vec[i]); - mp.insert(insert_data); - umap.insert(insert_data); - multimp.insert(insert_data); - umultimap.insert(insert_data); + auto temp = j_vector.at(i); + // testing at() method + j_vector2.push_back(temp); + j_vector3.emplace_back(temp); + // testing push_back and emplace back methods } - // map -> json map - json j_map(mp); - json j_umap(umap); - json j_multimap(multimp); - json j_umultimap(umultimap); + // these three json vectors must be the same + assert(j_vector == j_vector2); + assert(j_vector == j_vector3); return 0; }