From f3c70224871b86bd90810c3978bb55338d9fc548 Mon Sep 17 00:00:00 2001 From: Tanuj Garg Date: Fri, 5 Jun 2020 23:55:50 +0530 Subject: [PATCH] [Checking stats] Keeping only map coversions to json --- test/src/fuzzer-parse_stl.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/test/src/fuzzer-parse_stl.cpp b/test/src/fuzzer-parse_stl.cpp index 3620db453..78fd617ac 100644 --- a/test/src/fuzzer-parse_stl.cpp +++ b/test/src/fuzzer-parse_stl.cpp @@ -42,21 +42,28 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // parsing from STL containers json j_vector(vec); - json j_vector2 = json::array(); - json j_vector3 = json::array(); + std::map mp; + std::unordered_map umap; + std::multimap multimp; + std::unordered_multimap umultimap; - for(std::size_t i = 0; i < j_vector.size(); ++i) + // 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) { - 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 + 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); } - // these three json vectors must be the same - assert(j_vector == j_vector2); - assert(j_vector == j_vector3); + // map -> json map + json j_map(mp); + json j_umap(umap); + json j_multimap(multimp); + json j_umultimap(umultimap); return 0; }