-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
53 lines (46 loc) · 1.04 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "LSMTree.hpp"
#include <cassert>
#include <iostream>
#define RUN(TEST_NAME) \
TEST_NAME(); \
std::experimental::filesystem::remove_all("./storage"); \
std::cout << "Done: " << #TEST_NAME << std::endl
void test_simple_insert()
{
LSMTree tree("./storage");
tree.insert(10);
assert(tree.find(10));
assert(!tree.find(11));
}
void test_big_data()
{
LSMTree tree("./storage");
for (size_t i = 0; i < 250; i++) {
tree.insert(i);
}
tree.remove(23);
assert(tree.find(24));
assert(!tree.find(23));
}
void test_simple_5_insert()
{
LSMTree tree("./storage");
tree.insert(10);
tree.insert(8);
tree.insert(12);
tree.insert(11);
tree.insert(9);
tree.insert(11);
assert(tree.find(8));
assert(tree.find(9));
assert(tree.find(10));
assert(tree.find(11));
assert(tree.find(12));
assert(!tree.find(7));
}
int main()
{
RUN(test_simple_insert);
RUN(test_simple_5_insert);
RUN(test_big_data);
}