Skip to content

Commit

Permalink
Tests for Members in std::multimap.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylavic committed Apr 1, 2021
1 parent e85ea5b commit dc3d872
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
9 changes: 5 additions & 4 deletions test/perftest/perftest.h
Expand Up @@ -130,7 +130,8 @@ class PerfTest : public ::testing::Test {
"integers.json",
"mixed.json",
"nulls.json",
"paragraphs.json"
"paragraphs.json",
"alotofkeys.json"
};

for (size_t j = 0; j < sizeof(typesfilenames) / sizeof(typesfilenames[0]); j++) {
Expand Down Expand Up @@ -158,7 +159,7 @@ class PerfTest : public ::testing::Test {
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;
}
Expand All @@ -174,8 +175,8 @@ class PerfTest : public ::testing::Test {
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;
};
Expand Down
22 changes: 20 additions & 2 deletions test/perftest/rapidjsontest.cpp
Expand Up @@ -26,6 +26,7 @@
#include "rapidjson/memorystream.h"

#include <fstream>
#include <vector>

#ifdef RAPIDJSON_SSE2
#define SIMD_SUFFIX(name) name##_SSE2
Expand All @@ -52,7 +53,7 @@ class RapidJson : public PerfTest {
// 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());
}

Expand All @@ -68,7 +69,7 @@ class RapidJson : public PerfTest {
protected:
char *temp_;
Document doc_;
Document typesDoc_[7];
Document typesDoc_[8];
};

TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler)) {
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit dc3d872

Please sign in to comment.