diff --git a/bin/types/alotofkeys.json b/bin/types/alotofkeys.json new file mode 100644 index 0000000..3fc052e Binary files /dev/null and b/bin/types/alotofkeys.json differ diff --git a/test/perftest/perftest.h b/test/perftest/perftest.h index a83a6ed..31e3ca6 100644 --- a/test/perftest/perftest.h +++ b/test/perftest/perftest.h @@ -130,7 +130,8 @@ public: "integers.json", "mixed.json", "nulls.json", - "paragraphs.json" + "paragraphs.json", + "alotofkeys.json" }; for (size_t j = 0; j < sizeof(typesfilenames) / sizeof(typesfilenames[0]); j++) { @@ -158,7 +159,7 @@ public: free(whitespace_); json_ = 0; whitespace_ = 0; - for (size_t i = 0; i < 7; i++) { + for (size_t i = 0; i < 8; i++) { free(types_[i]); types_[i] = 0; } @@ -174,8 +175,8 @@ protected: size_t length_; char *whitespace_; size_t whitespace_length_; - char *types_[7]; - size_t typesLength_[7]; + char *types_[8]; + size_t typesLength_[8]; static const size_t kTrialCount = 1000; }; diff --git a/test/perftest/rapidjsontest.cpp b/test/perftest/rapidjsontest.cpp index 24e7120..ce41c10 100644 --- a/test/perftest/rapidjsontest.cpp +++ b/test/perftest/rapidjsontest.cpp @@ -26,6 +26,7 @@ #include "rapidjson/memorystream.h" #include +#include #ifdef RAPIDJSON_SSE2 #define SIMD_SUFFIX(name) name##_SSE2 @@ -52,7 +53,7 @@ public: // Parse as a document EXPECT_FALSE(doc_.Parse(json_).HasParseError()); - for (size_t i = 0; i < 7; i++) + for (size_t i = 0; i < 8; i++) EXPECT_FALSE(typesDoc_[i].Parse(types_[i]).HasParseError()); } @@ -68,7 +69,7 @@ private: protected: char *temp_; Document doc_; - Document typesDoc_[7]; + Document typesDoc_[8]; }; TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler)) { @@ -335,6 +336,23 @@ TEST_F(RapidJson, DocumentAccept) { } } +TEST_F(RapidJson, DocumentFind) { + typedef Document::ValueType ValueType; + typedef ValueType::ConstMemberIterator ConstMemberIterator; + const Document &doc = typesDoc_[7]; // alotofkeys.json + if (doc.IsObject()) { + std::vector keys; + for (ConstMemberIterator it = doc.MemberBegin(); it != doc.MemberEnd(); ++it) { + keys.push_back(&it->name); + } + for (size_t i = 0; i < kTrialCount; i++) { + for (size_t j = 0; j < keys.size(); j++) { + EXPECT_TRUE(doc.FindMember(*keys[j]) != doc.MemberEnd()); + } + } + } +} + struct NullStream { typedef char Ch;