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

Commit 9a966e8

Browse files
author
Ziqi Wang
committed
Adding unique key insert test
1 parent d922e44 commit 9a966e8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

test/include/index/testing_index_util.h

100644100755
File mode changed.

test/index/testing_index_util.cpp

100644100755
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,25 @@ void TestingIndexUtil::UniqueKeyInsertTest(const IndexType index_type) {
112112
LaunchParallelTest(1, TestingIndexUtil::InsertHelper, index.get(), pool,
113113
scale_factor);
114114

115-
// Checks
115+
// Check basic insert (key0 only has 1 value, so it is not sufficient)
116116
std::unique_ptr<storage::Tuple> key0(new storage::Tuple(key_schema, true));
117117
key0->SetValue(0, type::ValueFactory::GetIntegerValue(100), pool);
118118
key0->SetValue(1, type::ValueFactory::GetVarcharValue("a"), pool);
119119

120120
index->ScanKey(key0.get(), location_ptrs);
121121
EXPECT_EQ(1, location_ptrs.size());
122122
location_ptrs.clear();
123+
124+
// This tests non-unqie key. If scan returns more than 1 then it should fail
125+
std::unique_ptr<storage::Tuple> key1(new storage::Tuple(key_schema, true));
126+
key1->SetValue(0, type::ValueFactory::GetIntegerValue(100), pool);
127+
key1->SetValue(1, type::ValueFactory::GetVarcharValue("b"), pool);
128+
129+
index->ScanKey(key1.get(), location_ptrs);
130+
EXPECT_EQ(1, location_ptrs.size());
131+
location_ptrs.clear();
132+
133+
return;
123134
}
124135

125136
void TestingIndexUtil::UniqueKeyDeleteTest(const IndexType index_type) {

0 commit comments

Comments
 (0)