-
Notifications
You must be signed in to change notification settings - Fork 0
/
t01.cc
69 lines (67 loc) · 1.6 KB
/
t01.cc
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 "virus_genealogy.hpp"
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
class Virus {
public:
typedef typename std::string id_type;
Virus(id_type const &_id) : id(_id) {
}
id_type get_id() const {
return id;
}
private:
id_type id;
};
int main() {
VirusGenealogy<Virus> gen("A1H1");
Virus::id_type const id1 = gen.get_stem_id();
assert(gen.exists(id1));
assert(gen.get_parents(id1).size() == 0);
gen.create("A", id1);
gen.create("B", id1);
assert(gen.get_children(id1).size() == 2);
gen.create("C", "A");
gen.connect("C", "B");
assert(gen.get_parents("C").size() == 2);
assert(gen.get_children("A").size() == 1);
std::vector<Virus::id_type> parents;
parents.push_back("A");
parents.push_back("B");
gen.create("D", parents);
assert(gen.get_parents("D").size() == parents.size());
assert(gen.get_children("A").size() == 2);
assert("D" == gen["D"].get_id());
gen.remove("A");
std::cerr<<"tu ok"<<std::endl;
assert(!gen.exists("A"));
assert(gen.exists("B"));
assert(gen.exists("C"));
assert(gen.exists("D"));
gen.remove("B");
assert(!gen.exists("A"));
assert(!gen.exists("B"));
assert(!gen.exists("C"));
assert(!gen.exists("D"));
try {
gen["E"];
}
catch (std::exception &e) {
std::cout << e.what() << std::endl;
}
try {
gen.create("E", "A1H1");
gen.create("E", "A1H1");
}
catch (std::exception &e) {
std::cout << e.what() << std::endl;
}
try {
gen.remove("A1H1");
}
catch (std::exception &e) {
std::cout << e.what() << std::endl;
}
std::cerr<<"dupa"<<std::endl;
}