summaryrefslogtreecommitdiff
path: root/src/mongo/db/index/sort_key_generator_test.cpp
diff options
context:
space:
mode:
authorADAM David Alan Martin <adam.martin@10gen.com>2019-06-10 01:21:01 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-06-10 01:59:35 -0400
commitc36f9ecb91e49da7e637863889804fc4e6c6c05e (patch)
tree64d8aadb6d29042d4f4e7366bc1457e4e0612383 /src/mongo/db/index/sort_key_generator_test.cpp
parentc9548e729c8fecd9d7a9a5dd341da0433194ac73 (diff)
downloadmongo-c36f9ecb91e49da7e637863889804fc4e6c6c05e.tar.gz
SERVER-39339 Remove `stdx/memory.h`
Diffstat (limited to 'src/mongo/db/index/sort_key_generator_test.cpp')
-rw-r--r--src/mongo/db/index/sort_key_generator_test.cpp80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/mongo/db/index/sort_key_generator_test.cpp b/src/mongo/db/index/sort_key_generator_test.cpp
index 1ec25d713a8..b129d99ad64 100644
--- a/src/mongo/db/index/sort_key_generator_test.cpp
+++ b/src/mongo/db/index/sort_key_generator_test.cpp
@@ -29,10 +29,11 @@
#include "mongo/platform/basic.h"
+#include <memory>
+
#include "mongo/bson/json.h"
#include "mongo/db/index/sort_key_generator.h"
#include "mongo/db/query/collation/collator_interface_mock.h"
-#include "mongo/stdx/memory.h"
#include "mongo/unittest/death_test.h"
#include "mongo/unittest/unittest.h"
@@ -40,21 +41,21 @@ namespace mongo {
namespace {
TEST(SortKeyGeneratorTest, ExtractNumberKeyForNonCompoundSortNonNested) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << 1), nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << 1), nullptr);
auto sortKey = sortKeyGen->getSortKey(fromjson("{_id: 0, a: 5}"), nullptr);
ASSERT_OK(sortKey.getStatus());
ASSERT_BSONOBJ_EQ(sortKey.getValue(), BSON("" << 5));
}
TEST(SortKeyGeneratorTest, ExtractNumberKeyFromDocWithSeveralFields) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << 1), nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << 1), nullptr);
auto sortKey = sortKeyGen->getSortKey(fromjson("{_id: 0, z: 10, a: 6, b: 16}"), nullptr);
ASSERT_OK(sortKey.getStatus());
ASSERT_BSONOBJ_EQ(sortKey.getValue(), BSON("" << 6));
}
TEST(SortKeyGeneratorTest, ExtractStringKeyNonCompoundNonNested) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << 1), nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << 1), nullptr);
auto sortKey =
sortKeyGen->getSortKey(fromjson("{_id: 0, z: 'thing1', a: 'thing2', b: 16}"), nullptr);
ASSERT_OK(sortKey.getStatus());
@@ -64,7 +65,7 @@ TEST(SortKeyGeneratorTest, ExtractStringKeyNonCompoundNonNested) {
}
TEST(SortKeyGeneratorTest, CompoundSortPattern) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << 1 << "b" << 1), nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << 1 << "b" << 1), nullptr);
auto sortKey =
sortKeyGen->getSortKey(fromjson("{_id: 0, z: 'thing1', a: 99, c: {a: 4}, b: 16}"), nullptr);
ASSERT_OK(sortKey.getStatus());
@@ -72,7 +73,7 @@ TEST(SortKeyGeneratorTest, CompoundSortPattern) {
}
TEST(SortKeyGeneratorTest, CompoundSortPatternWithDottedPath) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("c.a" << 1 << "b" << 1), nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("c.a" << 1 << "b" << 1), nullptr);
auto sortKey =
sortKeyGen->getSortKey(fromjson("{_id: 0, z: 'thing1', a: 99, c: {a: 4}, b: 16}"), nullptr);
ASSERT_OK(sortKey.getStatus());
@@ -80,7 +81,7 @@ TEST(SortKeyGeneratorTest, CompoundSortPatternWithDottedPath) {
}
TEST(SortKeyGeneratorTest, CompoundPatternLeadingFieldIsArray) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("c" << 1 << "b" << 1), nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("c" << 1 << "b" << 1), nullptr);
auto sortKey = sortKeyGen->getSortKey(
fromjson("{_id: 0, z: 'thing1', a: 99, c: [2, 4, 1], b: 16}"), nullptr);
ASSERT_OK(sortKey.getStatus());
@@ -89,7 +90,7 @@ TEST(SortKeyGeneratorTest, CompoundPatternLeadingFieldIsArray) {
TEST(SortKeyGeneratorTest, ExtractStringSortKeyWithCollatorUsesComparisonKey) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << 1), &collator);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << 1), &collator);
auto sortKey =
sortKeyGen->getSortKey(fromjson("{_id: 0, z: 'thing1', a: 'thing2', b: 16}"), nullptr);
ASSERT_OK(sortKey.getStatus());
@@ -100,14 +101,14 @@ TEST(SortKeyGeneratorTest, ExtractStringSortKeyWithCollatorUsesComparisonKey) {
TEST(SortKeyGeneratorTest, CollatorHasNoEffectWhenExtractingNonStringSortKey) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << 1), &collator);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << 1), &collator);
auto sortKey = sortKeyGen->getSortKey(fromjson("{_id: 0, z: 10, a: 6, b: 16}"), nullptr);
ASSERT_OK(sortKey.getStatus());
ASSERT_BSONOBJ_EQ(sortKey.getValue(), BSON("" << 6));
}
TEST(SortKeyGeneratorTest, SortKeyGenerationForArraysChoosesCorrectKey) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << -1), nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << -1), nullptr);
auto sortKey = sortKeyGen->getSortKey(fromjson("{_id: 0, a: [1, 2, 3, 4]}"), nullptr);
ASSERT_OK(sortKey.getStatus());
ASSERT_BSONOBJ_EQ(sortKey.getValue(), BSON("" << 4));
@@ -115,7 +116,7 @@ TEST(SortKeyGeneratorTest, SortKeyGenerationForArraysChoosesCorrectKey) {
TEST(SortKeyGeneratorTest, EnsureSortKeyGenerationForArraysRespectsCollation) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << 1), &collator);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << 1), &collator);
auto sortKey =
sortKeyGen->getSortKey(fromjson("{_id: 0, a: ['aaz', 'zza', 'yya', 'zzb']}"), nullptr);
ASSERT_OK(sortKey.getStatus());
@@ -125,7 +126,7 @@ TEST(SortKeyGeneratorTest, EnsureSortKeyGenerationForArraysRespectsCollation) {
}
TEST(SortKeyGeneratorTest, SortKeyGenerationForArraysRespectsCompoundOrdering) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a.b" << 1 << "a.c" << -1), nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a.b" << 1 << "a.c" << -1), nullptr);
auto sortKey = sortKeyGen->getSortKey(
fromjson("{_id: 0, a: [{b: 1, c: 0}, {b: 0, c: 3}, {b: 0, c: 1}]}"), nullptr);
ASSERT_OK(sortKey.getStatus());
@@ -135,63 +136,62 @@ TEST(SortKeyGeneratorTest, SortKeyGenerationForArraysRespectsCompoundOrdering) {
DEATH_TEST(SortKeyGeneratorTest,
SortPatternComponentWithStringIsFatal,
"Invariant failure elt.type() == BSONType::Object") {
- MONGO_COMPILER_VARIABLE_UNUSED auto ignored =
- stdx::make_unique<SortKeyGenerator>(BSON("a"
- << "foo"),
- nullptr);
+ MONGO_COMPILER_VARIABLE_UNUSED auto ignored = std::make_unique<SortKeyGenerator>(BSON("a"
+ << "foo"),
+ nullptr);
}
DEATH_TEST(SortKeyGeneratorTest,
SortPatternComponentWhoseObjectHasMultipleKeysIsFatal,
"Invariant failure elt.embeddedObject().nFields() == 1") {
MONGO_COMPILER_VARIABLE_UNUSED auto ignored =
- stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
- << "textScore"
- << "extra"
- << 1)),
- nullptr);
+ std::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
+ << "textScore"
+ << "extra"
+ << 1)),
+ nullptr);
}
DEATH_TEST(SortKeyGeneratorTest,
SortPatternComponentWithNonMetaObjectSortIsFatal,
"Invariant failure metaElem.fieldNameStringData() == \"$meta\"_sd") {
MONGO_COMPILER_VARIABLE_UNUSED auto ignored =
- stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$unknown"
- << "textScore")),
- nullptr);
+ std::make_unique<SortKeyGenerator>(BSON("a" << BSON("$unknown"
+ << "textScore")),
+ nullptr);
}
DEATH_TEST(SortKeyGeneratorTest,
SortPatternComponentWithUnknownMetaKeywordIsFatal,
"Invariant failure metaElem.valueStringData() == \"randVal\"_sd") {
MONGO_COMPILER_VARIABLE_UNUSED auto ignored =
- stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
- << "unknown")),
- nullptr);
+ std::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
+ << "unknown")),
+ nullptr);
}
DEATH_TEST(SortKeyGeneratorTest,
NoMetadataWhenPatternHasMetaTextScoreIsFatal,
"Invariant failure metadata") {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
- << "textScore")),
- nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
+ << "textScore")),
+ nullptr);
uassertStatusOK(sortKeyGen->getSortKey(BSONObj{}, nullptr).getStatus());
}
DEATH_TEST(SortKeyGeneratorTest,
NoMetadataWhenPatternHasMetaRandValIsFatal,
"Invariant failure metadata") {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
- << "randVal")),
- nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
+ << "randVal")),
+ nullptr);
uassertStatusOK(sortKeyGen->getSortKey(BSONObj{}, nullptr).getStatus());
}
TEST(SortKeyGeneratorTest, CanGenerateKeysForTextScoreMetaSort) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
- << "textScore")),
- nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
+ << "textScore")),
+ nullptr);
SortKeyGenerator::Metadata metadata;
metadata.textScore = 1.5;
auto sortKey = sortKeyGen->getSortKey(BSONObj{}, &metadata);
@@ -200,9 +200,9 @@ TEST(SortKeyGeneratorTest, CanGenerateKeysForTextScoreMetaSort) {
}
TEST(SortKeyGeneratorTest, CanGenerateKeysForRandValMetaSort) {
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
- << "randVal")),
- nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta"
+ << "randVal")),
+ nullptr);
SortKeyGenerator::Metadata metadata;
metadata.randVal = 0.3;
auto sortKey = sortKeyGen->getSortKey(BSONObj{}, &metadata);
@@ -213,7 +213,7 @@ TEST(SortKeyGeneratorTest, CanGenerateKeysForRandValMetaSort) {
TEST(SortKeyGeneratorTest, CanGenerateKeysForCompoundMetaSort) {
BSONObj pattern = fromjson(
"{a: 1, b: {$meta: 'randVal'}, c: {$meta: 'textScore'}, d: -1, e: {$meta: 'textScore'}}");
- auto sortKeyGen = stdx::make_unique<SortKeyGenerator>(pattern, nullptr);
+ auto sortKeyGen = std::make_unique<SortKeyGenerator>(pattern, nullptr);
SortKeyGenerator::Metadata metadata;
metadata.randVal = 0.3;
metadata.textScore = 1.5;