summaryrefslogtreecommitdiff
path: root/src/mongo/db/index/s2_key_generator_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/index/s2_key_generator_test.cpp')
-rw-r--r--src/mongo/db/index/s2_key_generator_test.cpp51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/mongo/db/index/s2_key_generator_test.cpp b/src/mongo/db/index/s2_key_generator_test.cpp
index fc126c0272c..82fdbd9c605 100644
--- a/src/mongo/db/index/s2_key_generator_test.cpp
+++ b/src/mongo/db/index/s2_key_generator_test.cpp
@@ -35,6 +35,7 @@
#include <algorithm>
#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/bson/simple_bsonobj_comparator.h"
#include "mongo/db/index/expression_params.h"
#include "mongo/db/index/s2_common.h"
#include "mongo/db/json.h"
@@ -121,7 +122,7 @@ long long getCellID(int x, int y, bool multiPoint = false) {
const CollatorInterface* collator = nullptr;
ExpressionParams::initialize2dsphereParams(infoObj, collator, &params);
- BSONObjSet keys;
+ BSONObjSet keys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
// There's no need to compute the prefixes of the indexed fields that cause the index to be
// multikey when computing the cell id of the geo field.
MultikeyPaths* multikeyPaths = nullptr;
@@ -142,12 +143,12 @@ TEST(S2KeyGeneratorTest, GetS2KeysFromSubobjectWithArrayOfGeoAndNonGeoSubobjects
CollatorInterfaceMock* collator = nullptr;
ExpressionParams::initialize2dsphereParams(infoObj, collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(
genKeysFrom, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << 1 << "" << getCellID(0, 0)));
expectedKeys.insert(BSON("" << 1 << "" << getCellID(3, 3)));
expectedKeys.insert(BSON("" << 2 << "" << getCellID(0, 0)));
@@ -168,12 +169,12 @@ TEST(S2KeyGeneratorTest, GetS2KeysFromArrayOfNonGeoSubobjectsWithArrayValues) {
CollatorInterfaceMock* collator = nullptr;
ExpressionParams::initialize2dsphereParams(infoObj, collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(
genKeysFrom, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << 1 << "" << getCellID(0, 0)));
expectedKeys.insert(BSON("" << 2 << "" << getCellID(0, 0)));
expectedKeys.insert(BSON("" << 3 << "" << getCellID(0, 0)));
@@ -191,13 +192,13 @@ TEST(S2KeyGeneratorTest, GetS2KeysFromMultiPointInGeoField) {
CollatorInterfaceMock* collator = nullptr;
ExpressionParams::initialize2dsphereParams(infoObj, collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(
genKeysFrom, keyPattern, params, &actualKeys, &actualMultikeyPaths);
const bool multiPoint = true;
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << 1 << "" << getCellID(0, 0, multiPoint)));
expectedKeys.insert(BSON("" << 1 << "" << getCellID(1, 0, multiPoint)));
expectedKeys.insert(BSON("" << 1 << "" << getCellID(1, 1, multiPoint)));
@@ -214,11 +215,11 @@ TEST(S2KeyGeneratorTest, CollationAppliedToNonGeoStringFieldAfterGeoField) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
ExpressionParams::initialize2dsphereParams(infoObj, &collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << getCellID(0, 0) << ""
<< "gnirts"));
@@ -235,11 +236,11 @@ TEST(S2KeyGeneratorTest, CollationAppliedToNonGeoStringFieldBeforeGeoField) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
ExpressionParams::initialize2dsphereParams(infoObj, &collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON(""
<< "gnirts"
<< ""
@@ -258,11 +259,11 @@ TEST(S2KeyGeneratorTest, CollationAppliedToAllNonGeoStringFields) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
ExpressionParams::initialize2dsphereParams(infoObj, &collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON(""
<< "gnirts"
<< ""
@@ -284,11 +285,11 @@ TEST(S2KeyGeneratorTest, CollationAppliedToNonGeoStringFieldWithMultiplePathComp
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
ExpressionParams::initialize2dsphereParams(infoObj, &collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << getCellID(0, 0) << ""
<< "gnirts"));
@@ -305,11 +306,11 @@ TEST(S2KeyGeneratorTest, CollationAppliedToStringsInArray) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
ExpressionParams::initialize2dsphereParams(infoObj, &collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << getCellID(0, 0) << ""
<< "gnirts"));
expectedKeys.insert(BSON("" << getCellID(0, 0) << ""
@@ -328,11 +329,11 @@ TEST(S2KeyGeneratorTest, CollationAppliedToStringsInAllArrays) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
ExpressionParams::initialize2dsphereParams(infoObj, &collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << getCellID(0, 0) << ""
<< "gnirts"
<< ""
@@ -362,11 +363,11 @@ TEST(S2KeyGeneratorTest, CollationDoesNotAffectNonStringFields) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
ExpressionParams::initialize2dsphereParams(infoObj, &collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << getCellID(0, 0) << "" << 5));
assertKeysetsEqual(expectedKeys, actualKeys);
@@ -382,11 +383,11 @@ TEST(S2KeyGeneratorTest, CollationAppliedToStringsInNestedObjects) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
ExpressionParams::initialize2dsphereParams(infoObj, &collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << getCellID(0, 0) << "" << BSON("c"
<< "gnirts")));
@@ -403,11 +404,11 @@ TEST(S2KeyGeneratorTest, NoCollation) {
const CollatorInterface* collator = nullptr;
ExpressionParams::initialize2dsphereParams(infoObj, collator, &params);
- BSONObjSet actualKeys;
+ BSONObjSet actualKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
MultikeyPaths actualMultikeyPaths;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths);
- BSONObjSet expectedKeys;
+ BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
expectedKeys.insert(BSON("" << getCellID(0, 0) << ""
<< "string"));