1 | /** |
2 | * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | #include "index/delete_store.h" |
18 | #include <gtest/gtest.h> |
19 | |
20 | using namespace proxima::be; |
21 | using namespace proxima::be::index; |
22 | |
23 | |
24 | class DeleteStoreTest : public testing::Test { |
25 | protected: |
26 | void SetUp() { |
27 | char cmd_buf[100]; |
28 | snprintf(cmd_buf, 100, "rm -rf ./data.del" ); |
29 | system(cmd_buf); |
30 | } |
31 | |
32 | void TearDown() {} |
33 | }; |
34 | |
35 | TEST_F(DeleteStoreTest, TestGeneral) { |
36 | DeleteStorePtr delete_store = DeleteStore::Create("collection_test" , "./" ); |
37 | ASSERT_NE(delete_store, nullptr); |
38 | |
39 | ReadOptions read_options; |
40 | read_options.use_mmap = true; |
41 | read_options.create_new = true; |
42 | |
43 | int ret = delete_store->open(read_options); |
44 | ASSERT_EQ(ret, 0); |
45 | |
46 | for (size_t i = 0; i < 10000; i++) { |
47 | ASSERT_EQ(delete_store->insert(i), 0); |
48 | } |
49 | |
50 | for (size_t i = 0; i < 10000; i++) { |
51 | ASSERT_EQ(delete_store->has(i), true); |
52 | } |
53 | ASSERT_EQ(delete_store->close(), 0); |
54 | |
55 | ret = delete_store->open(read_options); |
56 | ASSERT_EQ(ret, 0); |
57 | |
58 | for (size_t i = 0; i < 10000; i++) { |
59 | ASSERT_EQ(delete_store->has(i), true); |
60 | } |
61 | } |
62 | |