diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/storage/record_store_test_updatewithdamages.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/storage/record_store_test_updatewithdamages.cpp')
-rw-r--r-- | src/mongo/db/storage/record_store_test_updatewithdamages.cpp | 372 |
1 files changed, 180 insertions, 192 deletions
diff --git a/src/mongo/db/storage/record_store_test_updatewithdamages.cpp b/src/mongo/db/storage/record_store_test_updatewithdamages.cpp index f5dc1353f15..701d5fd58f0 100644 --- a/src/mongo/db/storage/record_store_test_updatewithdamages.cpp +++ b/src/mongo/db/storage/record_store_test_updatewithdamages.cpp @@ -41,251 +41,239 @@ using std::string; namespace mongo { - // Insert a record and try to perform an in-place update on it. - TEST( RecordStoreTestHarness, UpdateWithDamages ) { - unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); - unique_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); +// Insert a record and try to perform an in-place update on it. +TEST(RecordStoreTestHarness, UpdateWithDamages) { + unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); - if (!rs->updateWithDamagesSupported()) - return; + if (!rs->updateWithDamagesSupported()) + return; - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); + } - string data = "00010111"; - RecordId loc; - const RecordData rec(data.c_str(), data.size() + 1); + string data = "00010111"; + RecordId loc; + const RecordData rec(data.c_str(), data.size() + 1); + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - WriteUnitOfWork uow( opCtx.get() ); - StatusWith<RecordId> res = rs->insertRecord( opCtx.get(), - rec.data(), - rec.size(), - false ); - ASSERT_OK( res.getStatus() ); - loc = res.getValue(); - uow.commit(); - } + WriteUnitOfWork uow(opCtx.get()); + StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), rec.data(), rec.size(), false); + ASSERT_OK(res.getStatus()); + loc = res.getValue(); + uow.commit(); } + } - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); + } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - mutablebson::DamageVector dv( 3 ); - dv[0].sourceOffset = 5; - dv[0].targetOffset = 0; - dv[0].size = 2; - dv[1].sourceOffset = 3; - dv[1].targetOffset = 2; - dv[1].size = 3; - dv[2].sourceOffset = 0; - dv[2].targetOffset = 5; - dv[2].size = 3; - - WriteUnitOfWork uow( opCtx.get() ); - ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, data.c_str(), dv ) ); - uow.commit(); - } + mutablebson::DamageVector dv(3); + dv[0].sourceOffset = 5; + dv[0].targetOffset = 0; + dv[0].size = 2; + dv[1].sourceOffset = 3; + dv[1].targetOffset = 2; + dv[1].size = 3; + dv[2].sourceOffset = 0; + dv[2].targetOffset = 5; + dv[2].size = 3; + + WriteUnitOfWork uow(opCtx.get()); + ASSERT_OK(rs->updateWithDamages(opCtx.get(), loc, rec, data.c_str(), dv)); + uow.commit(); } + } - data = "11101000"; + data = "11101000"; + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - RecordData record = rs->dataFor( opCtx.get(), loc ); - ASSERT_EQUALS( data, record.data() ); - } + RecordData record = rs->dataFor(opCtx.get(), loc); + ASSERT_EQUALS(data, record.data()); } } +} - // Insert a record and try to perform an in-place update on it with a DamageVector - // containing overlapping DamageEvents. - TEST( RecordStoreTestHarness, UpdateWithOverlappingDamageEvents ) { - unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); - unique_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); +// Insert a record and try to perform an in-place update on it with a DamageVector +// containing overlapping DamageEvents. +TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEvents) { + unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); - if (!rs->updateWithDamagesSupported()) - return; + if (!rs->updateWithDamagesSupported()) + return; - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); + } - string data = "00010111"; - RecordId loc; - const RecordData rec(data.c_str(), data.size() + 1); + string data = "00010111"; + RecordId loc; + const RecordData rec(data.c_str(), data.size() + 1); + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - WriteUnitOfWork uow( opCtx.get() ); - StatusWith<RecordId> res = rs->insertRecord( opCtx.get(), - rec.data(), - rec.size(), - false ); - ASSERT_OK( res.getStatus() ); - loc = res.getValue(); - uow.commit(); - } + WriteUnitOfWork uow(opCtx.get()); + StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), rec.data(), rec.size(), false); + ASSERT_OK(res.getStatus()); + loc = res.getValue(); + uow.commit(); } + } - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); + } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - mutablebson::DamageVector dv( 2 ); - dv[0].sourceOffset = 3; - dv[0].targetOffset = 0; - dv[0].size = 5; - dv[1].sourceOffset = 0; - dv[1].targetOffset = 3; - dv[1].size = 5; - - WriteUnitOfWork uow( opCtx.get() ); - ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, data.c_str(), dv ) ); - uow.commit(); - } + mutablebson::DamageVector dv(2); + dv[0].sourceOffset = 3; + dv[0].targetOffset = 0; + dv[0].size = 5; + dv[1].sourceOffset = 0; + dv[1].targetOffset = 3; + dv[1].size = 5; + + WriteUnitOfWork uow(opCtx.get()); + ASSERT_OK(rs->updateWithDamages(opCtx.get(), loc, rec, data.c_str(), dv)); + uow.commit(); } + } - data = "10100010"; + data = "10100010"; + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - RecordData record = rs->dataFor( opCtx.get(), loc ); - ASSERT_EQUALS( data, record.data() ); - } + RecordData record = rs->dataFor(opCtx.get(), loc); + ASSERT_EQUALS(data, record.data()); } } +} - // Insert a record and try to perform an in-place update on it with a DamageVector - // containing overlapping DamageEvents. The changes should be applied in the order - // specified by the DamageVector, and not -- for instance -- by the targetOffset. - TEST( RecordStoreTestHarness, UpdateWithOverlappingDamageEventsReversed ) { - unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); - unique_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); +// Insert a record and try to perform an in-place update on it with a DamageVector +// containing overlapping DamageEvents. The changes should be applied in the order +// specified by the DamageVector, and not -- for instance -- by the targetOffset. +TEST(RecordStoreTestHarness, UpdateWithOverlappingDamageEventsReversed) { + unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); - if (!rs->updateWithDamagesSupported()) - return; + if (!rs->updateWithDamagesSupported()) + return; - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); + } - string data = "00010111"; - RecordId loc; - const RecordData rec(data.c_str(), data.size() + 1); + string data = "00010111"; + RecordId loc; + const RecordData rec(data.c_str(), data.size() + 1); + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - WriteUnitOfWork uow( opCtx.get() ); - StatusWith<RecordId> res = rs->insertRecord( opCtx.get(), - rec.data(), - rec.size(), - false ); - ASSERT_OK( res.getStatus() ); - loc = res.getValue(); - uow.commit(); - } + WriteUnitOfWork uow(opCtx.get()); + StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), rec.data(), rec.size(), false); + ASSERT_OK(res.getStatus()); + loc = res.getValue(); + uow.commit(); } + } - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); + } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - mutablebson::DamageVector dv( 2 ); - dv[0].sourceOffset = 0; - dv[0].targetOffset = 3; - dv[0].size = 5; - dv[1].sourceOffset = 3; - dv[1].targetOffset = 0; - dv[1].size = 5; - - WriteUnitOfWork uow( opCtx.get() ); - ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, data.c_str(), dv ) ); - uow.commit(); - } + mutablebson::DamageVector dv(2); + dv[0].sourceOffset = 0; + dv[0].targetOffset = 3; + dv[0].size = 5; + dv[1].sourceOffset = 3; + dv[1].targetOffset = 0; + dv[1].size = 5; + + WriteUnitOfWork uow(opCtx.get()); + ASSERT_OK(rs->updateWithDamages(opCtx.get(), loc, rec, data.c_str(), dv)); + uow.commit(); } + } - data = "10111010"; + data = "10111010"; + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - RecordData record = rs->dataFor( opCtx.get(), loc ); - ASSERT_EQUALS( data, record.data() ); - } + RecordData record = rs->dataFor(opCtx.get(), loc); + ASSERT_EQUALS(data, record.data()); } } +} - // Insert a record and try to call updateWithDamages() with an empty DamageVector. - TEST( RecordStoreTestHarness, UpdateWithNoDamages ) { - unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); - unique_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); +// Insert a record and try to call updateWithDamages() with an empty DamageVector. +TEST(RecordStoreTestHarness, UpdateWithNoDamages) { + unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); - if (!rs->updateWithDamagesSupported()) - return; + if (!rs->updateWithDamagesSupported()) + return; - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); + } - string data = "my record"; - RecordId loc; - const RecordData rec(data.c_str(), data.size() + 1); + string data = "my record"; + RecordId loc; + const RecordData rec(data.c_str(), data.size() + 1); + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - WriteUnitOfWork uow( opCtx.get() ); - StatusWith<RecordId> res = rs->insertRecord( opCtx.get(), - rec.data(), - rec.size(), - false ); - ASSERT_OK( res.getStatus() ); - loc = res.getValue(); - uow.commit(); - } + WriteUnitOfWork uow(opCtx.get()); + StatusWith<RecordId> res = rs->insertRecord(opCtx.get(), rec.data(), rec.size(), false); + ASSERT_OK(res.getStatus()); + loc = res.getValue(); + uow.commit(); } + } - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(1, rs->numRecords(opCtx.get())); + } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - mutablebson::DamageVector dv; - - WriteUnitOfWork uow( opCtx.get() ); - ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, "", dv ) ); - uow.commit(); - } + mutablebson::DamageVector dv; + + WriteUnitOfWork uow(opCtx.get()); + ASSERT_OK(rs->updateWithDamages(opCtx.get(), loc, rec, "", dv)); + uow.commit(); } + } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - RecordData record = rs->dataFor( opCtx.get(), loc ); - ASSERT_EQUALS( data, record.data() ); - } + RecordData record = rs->dataFor(opCtx.get(), loc); + ASSERT_EQUALS(data, record.data()); } } +} -} // namespace mongo +} // namespace mongo |