Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 88e9b6b

Browse files
author
Ziqi Wang
committed
Adding unique key delete test
1 parent 8c0dd12 commit 88e9b6b

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/include/index/bwtree.h

100644100755
File mode changed.

test/index/bwtree_index_test.cpp

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ TEST_F(BwTreeIndexTests, UniqueKeyInsertTest) {
3737
TestingIndexUtil::UniqueKeyInsertTest(IndexType::BWTREE);
3838
}
3939

40-
//TEST_F(BwTreeIndexTests, UniqueKeyDeleteTest) {
41-
// TestingIndexUtil::UniqueKeyDeleteTest(IndexType::BWTREE);
42-
//}
40+
TEST_F(BwTreeIndexTests, UniqueKeyDeleteTest) {
41+
TestingIndexUtil::UniqueKeyDeleteTest(IndexType::BWTREE);
42+
}
4343

4444
TEST_F(BwTreeIndexTests, NonUniqueKeyDeleteTest) {
4545
TestingIndexUtil::NonUniqueKeyDeleteTest(IndexType::BWTREE);

test/index/testing_index_util.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,32 +176,37 @@ void TestingIndexUtil::UniqueKeyDeleteTest(const IndexType index_type) {
176176
index->ScanKey(key0.get(), location_ptrs);
177177
#ifdef LOG_DEBUG_ENABLED
178178
for (auto ptr : location_ptrs) {
179-
LOG_DEBUG(" FOUND: %s", index::IndexUtil::GetInfo(ptr).c_str());
179+
LOG_DEBUG("key0 FOUND: %s", index::IndexUtil::GetInfo(ptr).c_str());
180180
}
181181
#endif
182+
LOG_DEBUG("key0 size: %lu", location_ptrs.size());
182183
EXPECT_EQ(0, location_ptrs.size());
183184
location_ptrs.clear();
184185

185186
LOG_DEBUG("ScanKey(key1=%s)", key1->GetInfo().c_str());
186187
index->ScanKey(key1.get(), location_ptrs);
187188
#ifdef LOG_DEBUG_ENABLED
188189
for (auto ptr : location_ptrs) {
189-
LOG_DEBUG(" FOUND: %s", index::IndexUtil::GetInfo(ptr).c_str());
190+
LOG_DEBUG("key1 FOUND: %s", index::IndexUtil::GetInfo(ptr).c_str());
190191
}
191192
#endif
193+
LOG_DEBUG("key1 size: %lu", location_ptrs.size());
192194
EXPECT_EQ(0, location_ptrs.size());
193195
location_ptrs.clear();
194196

195197
LOG_DEBUG("ScanKey(key2=%s)", key2->GetInfo().c_str());
196198
index->ScanKey(key2.get(), location_ptrs);
197199
#ifdef LOG_DEBUG_ENABLED
198200
for (auto ptr : location_ptrs) {
199-
LOG_DEBUG(" FOUND: %s", index::IndexUtil::GetInfo(ptr).c_str());
201+
LOG_DEBUG("key2 FOUND: %s", index::IndexUtil::GetInfo(ptr).c_str());
200202
}
201203
#endif
204+
LOG_DEBUG("key2 size: %lu", location_ptrs.size());
202205
EXPECT_EQ(1, location_ptrs.size());
203206
EXPECT_EQ(TestingIndexUtil::item1->block, location_ptrs[0]->block);
204207
location_ptrs.clear();
208+
209+
return;
205210
}
206211

207212
void TestingIndexUtil::NonUniqueKeyDeleteTest(const IndexType index_type) {
@@ -856,11 +861,13 @@ void TestingIndexUtil::DeleteHelper(index::Index *index,
856861
index->DeleteEntry(key3.get(), TestingIndexUtil::item1.get());
857862
index->DeleteEntry(key4.get(), TestingIndexUtil::item1.get());
858863

859-
// should be no key0
864+
// For non-unique key should be no key0
860865
// key1 item 0 1 2
861866
// key2 item 1
862867
// no key3
863868
// no key4
869+
870+
// For unique key should be only key2
864871
}
865872
}
866873

0 commit comments

Comments
 (0)