-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
69 lines (50 loc) · 1.91 KB
/
test.cpp
File metadata and controls
69 lines (50 loc) · 1.91 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <random>
#include <string>
#include <vector>
#include <iostream>
#include "b_tree.hpp"
#include "custom_type.hpp"
using namespace std;
void CustomTypeTest(void);
int main(void) {
CustomTypeTest();
return 0;
}
void CustomTypeTest(void) {
BTree<Student>* tree = new BTree<Student>(5);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> randomA(0, 19);
std::uniform_int_distribution<int> randomB(0, 19);
std::uniform_int_distribution<int> randomC(0, 19);
std::uniform_int_distribution<unsigned int> randomAge(18, 30);
std::uniform_int_distribution<unsigned int> randomId(20220001, 20229999);
vector<string> A = { "손", "이", "정", "김", "정", "김", "정", "김", "윤", "석", "윤", "박", "김", "최", "권", "김", "최", "김", "정", "정" };
vector<string> B = { "찬", "유", "진", "준", "치", "심", "지", "해", " ", "강", "재", "지", "해", "세", "경", "민", "현", "연", "경", "현" };
vector<string> C = { "민", "성", "민", "웅", "택", "솔", "량", "원", "현", "우", "은", "목", "구", "서", "중", "형", "솔", "웅", "영", "빈" };
Student student;
vector<Student> students;
size_t numberOfStudents = 200;
cout << "========== Insert test start ==========" << endl;
for (size_t i = 0; i < numberOfStudents; i++) {
string name = "";
name += A[randomA(rd)];
name += B[randomB(rd)];
name += C[randomC(rd)];
unsigned int age = randomAge(rd);
unsigned int id = randomId(rd);
student.setStudentInfo(name, age, id);
students.emplace_back(student);
tree->insert(student);
cout << tree->preOrder(true) << endl << endl;
}
cout << "========== Insert test done! ==========" << endl << endl;
shuffle(students.begin(), students.end(), gen);
cout << "========== Delete test start ==========" << endl;
for (auto i : students) {
tree->remove(i);
cout << tree->preOrder(true) << endl << endl;
}
cout << "========== Delete test done! ==========" << endl << endl;
delete tree;
}