Tests for Members in std::multimap.

This commit is contained in:
ylavic 2021-04-01 18:19:53 +02:00
parent 71f0fa7eb3
commit fc08f4f61b
3 changed files with 25 additions and 6 deletions

BIN
bin/types/alotofkeys.json Normal file

Binary file not shown.

View File

@ -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;
};

View File

@ -26,6 +26,7 @@
#include "rapidjson/memorystream.h"
#include <fstream>
#include <vector>
#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<const ValueType*> 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;