diff options
author | ADAM David Alan Martin <adam.martin@10gen.com> | 2016-12-14 14:39:44 -0500 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2016-12-14 14:41:31 -0500 |
commit | 2fd5d3f6cecc0d4f8f3816031352d69ca80e5d1c (patch) | |
tree | 8350daf4d5225504853ff19f4b0117aaac805417 /src/mongo/db/storage/sorted_data_interface_test_harness.cpp | |
parent | 0590b0da70cfdad7edf8d214bbfb5d8d8b6e502e (diff) | |
download | mongo-2fd5d3f6cecc0d4f8f3816031352d69ca80e5d1c.tar.gz |
SERVER-27257 Deduplicate symbol `newHarnessHelper`
The `newHarnessHelper` function was defined by multiple test driver
modules, each one specializing it to return a specific kind of
storage test driver's `HarnessHelper`. The two different kinds
of `HarnessHelper` class were given a common base class, and the
`newHarnessHelper` function was changed to a single implementation.
This new implementation returns the results of a `HarnessHelper`
factory function which can be registered by a MONGO_INITIALIZER
statement.
Diffstat (limited to 'src/mongo/db/storage/sorted_data_interface_test_harness.cpp')
-rw-r--r-- | src/mongo/db/storage/sorted_data_interface_test_harness.cpp | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/src/mongo/db/storage/sorted_data_interface_test_harness.cpp b/src/mongo/db/storage/sorted_data_interface_test_harness.cpp index 8e99d7d3461..57461bcf0d4 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_harness.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_harness.cpp @@ -36,9 +36,9 @@ #include "mongo/db/storage/sorted_data_interface.h" #include "mongo/unittest/unittest.h" -namespace mongo { -std::unique_ptr<SortedDataInterface> HarnessHelper::newSortedDataInterface( - bool unique, std::initializer_list<IndexKeyEntry> toInsert) { +auto mongo::SortedDataInterfaceHarnessHelper::newSortedDataInterface( + bool unique, std::initializer_list<IndexKeyEntry> toInsert) + -> std::unique_ptr<SortedDataInterface> { invariant(std::is_sorted( toInsert.begin(), toInsert.end(), IndexEntryComparison(Ordering::make(BSONObj())))); @@ -47,9 +47,9 @@ std::unique_ptr<SortedDataInterface> HarnessHelper::newSortedDataInterface( return index; } -void insertToIndex(unowned_ptr<OperationContext> txn, - unowned_ptr<SortedDataInterface> index, - std::initializer_list<IndexKeyEntry> toInsert) { +void mongo::insertToIndex(unowned_ptr<OperationContext> txn, + unowned_ptr<SortedDataInterface> index, + std::initializer_list<IndexKeyEntry> toInsert) { WriteUnitOfWork wuow(txn); for (auto&& entry : toInsert) { ASSERT_OK(index->insert(txn, entry.key, entry.loc, true)); @@ -57,9 +57,9 @@ void insertToIndex(unowned_ptr<OperationContext> txn, wuow.commit(); } -void removeFromIndex(unowned_ptr<OperationContext> txn, - unowned_ptr<SortedDataInterface> index, - std::initializer_list<IndexKeyEntry> toRemove) { +void mongo::removeFromIndex(unowned_ptr<OperationContext> txn, + unowned_ptr<SortedDataInterface> index, + std::initializer_list<IndexKeyEntry> toRemove) { WriteUnitOfWork wuow(txn); for (auto&& entry : toRemove) { index->unindex(txn, entry.key, entry.loc, true); @@ -67,8 +67,11 @@ void removeFromIndex(unowned_ptr<OperationContext> txn, wuow.commit(); } +namespace mongo { +namespace { + TEST(SortedDataInterface, InsertWithDups1) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { @@ -100,7 +103,7 @@ TEST(SortedDataInterface, InsertWithDups1) { } TEST(SortedDataInterface, InsertWithDups2) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { @@ -128,7 +131,7 @@ TEST(SortedDataInterface, InsertWithDups2) { } TEST(SortedDataInterface, InsertWithDups3AndRollback) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { @@ -156,7 +159,7 @@ TEST(SortedDataInterface, InsertWithDups3AndRollback) { } TEST(SortedDataInterface, InsertNoDups1) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { @@ -184,7 +187,7 @@ TEST(SortedDataInterface, InsertNoDups1) { } TEST(SortedDataInterface, InsertNoDups2) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true)); { @@ -212,7 +215,7 @@ TEST(SortedDataInterface, InsertNoDups2) { } TEST(SortedDataInterface, Unindex1) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { @@ -277,7 +280,7 @@ TEST(SortedDataInterface, Unindex1) { } TEST(SortedDataInterface, Unindex2Rollback) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { @@ -312,7 +315,7 @@ TEST(SortedDataInterface, Unindex2Rollback) { TEST(SortedDataInterface, CursorIterate1) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); int N = 5; @@ -338,7 +341,7 @@ TEST(SortedDataInterface, CursorIterate1) { } TEST(SortedDataInterface, CursorIterate1WithSaveRestore) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); int N = 5; @@ -367,7 +370,7 @@ TEST(SortedDataInterface, CursorIterate1WithSaveRestore) { TEST(SortedDataInterface, CursorIterateAllDupKeysWithSaveRestore) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); int N = 5; @@ -396,7 +399,7 @@ TEST(SortedDataInterface, CursorIterateAllDupKeysWithSaveRestore) { TEST(SortedDataInterface, Locate1) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); BSONObj key = BSON("" << 1); @@ -426,7 +429,7 @@ TEST(SortedDataInterface, Locate1) { } TEST(SortedDataInterface, Locate2) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { @@ -452,7 +455,7 @@ TEST(SortedDataInterface, Locate2) { } TEST(SortedDataInterface, Locate2Empty) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); { @@ -483,7 +486,7 @@ TEST(SortedDataInterface, Locate2Empty) { TEST(SortedDataInterface, Locate3Descending) { - const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + const auto harnessHelper(newSortedDataInterfaceHarnessHelper()); const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false)); auto buildEntry = [](int i) { return IndexKeyEntry(BSON("" << i), RecordId(1, i * 2)); }; @@ -526,7 +529,7 @@ TEST(SortedDataInterface, Locate3Descending) { } TEST(SortedDataInterface, Locate4) { - auto harnessHelper = newHarnessHelper(); + const auto harnessHelper = newSortedDataInterfaceHarnessHelper(); auto sorted = harnessHelper->newSortedDataInterface(false, { {BSON("" << 1), RecordId(1, 2)}, @@ -557,4 +560,5 @@ TEST(SortedDataInterface, Locate4) { } } +} // namespace } // namespace mongo |