-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
137 lines (126 loc) · 2.75 KB
/
Main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream>
#include <ArcGraph.h>
#include <IGraph.h>
#include <ListGraph.h>
#include <MatrixGraph.h>
#include <SetGraph.h>
#include <gtest/gtest.h>
TEST(Graphs, EqualArc) {
ArcGraph a = ArcGraph(5);
a.AddEdge(1, 2);
a.AddEdge(3, 2);
a.AddEdge(4, 1);
a.AddEdge(1, 0);
ArcGraph b = ArcGraph(5);
b.AddEdge(4, 1);
b.AddEdge(3, 2);
b.AddEdge(1, 0);
b.AddEdge(1, 2);
EXPECT_TRUE(a == b);
}
TEST(Graphs, EqualList) {
ListGraph a = ListGraph(5);
a.AddEdge(1, 2);
a.AddEdge(3, 2);
a.AddEdge(4, 1);
a.AddEdge(1, 0);
ListGraph b = ListGraph(5);
b.AddEdge(4, 1);
b.AddEdge(3, 2);
b.AddEdge(1, 0);
b.AddEdge(1, 2);
EXPECT_TRUE(a == b);
}
TEST(Graphs, EqualMatrix) {
MatrixGraph a = MatrixGraph(5);
a.AddEdge(1, 2);
a.AddEdge(3, 2);
a.AddEdge(4, 1);
a.AddEdge(1, 0);
MatrixGraph b = MatrixGraph(5);
b.AddEdge(4, 1);
b.AddEdge(3, 2);
b.AddEdge(1, 0);
b.AddEdge(1, 2);
EXPECT_TRUE(a == b);
}
TEST(Graphs, EqualSet) {
SetGraph a = SetGraph(5);
a.AddEdge(1, 2);
a.AddEdge(3, 2);
a.AddEdge(4, 1);
a.AddEdge(1, 0);
SetGraph b = SetGraph(5);
b.AddEdge(4, 1);
b.AddEdge(3, 2);
b.AddEdge(1, 0);
b.AddEdge(1, 2);
EXPECT_TRUE(a == b);
}
TEST(Graphs, EqualArcArc) {
ArcGraph arc = ArcGraph(5);
arc.AddEdge(1, 2);
arc.AddEdge(3, 2);
arc.AddEdge(4, 2);
arc.AddEdge(1, 3);
arc.AddEdge(3, 1);
arc.AddEdge(1, 0);
arc.AddEdge(3, 0);
arc.AddEdge(3, 4);
ArcGraph arc2 = ArcGraph(arc);
EXPECT_TRUE(arc == arc2);
}
TEST(Graphs, EqualArcList) {
ArcGraph arc = ArcGraph(5);
arc.AddEdge(1, 2);
arc.AddEdge(3, 2);
arc.AddEdge(4, 2);
arc.AddEdge(1, 3);
arc.AddEdge(3, 1);
arc.AddEdge(1, 0);
arc.AddEdge(3, 0);
arc.AddEdge(3, 4);
ListGraph list = ListGraph(arc);
EXPECT_TRUE(arc == list);
}
TEST(Graphs, EqualArcMatrix) {
ArcGraph arc = ArcGraph(5);
arc.AddEdge(1, 2);
arc.AddEdge(3, 2);
arc.AddEdge(4, 2);
arc.AddEdge(1, 3);
arc.AddEdge(3, 1);
arc.AddEdge(1, 0);
MatrixGraph matrix = MatrixGraph(arc);
EXPECT_TRUE(arc == matrix);
}
TEST(Graphs, EqualArcSet) {
ArcGraph arc = ArcGraph(5);
arc.AddEdge(1, 2);
arc.AddEdge(3, 2);
arc.AddEdge(4, 2);
arc.AddEdge(1, 3);
arc.AddEdge(3, 1);
arc.AddEdge(1, 0);
SetGraph set = SetGraph(arc);
EXPECT_TRUE(arc == set);
}
TEST(Graphs, EqualBIG) {
int size = 10000;
ArcGraph arc = ArcGraph(size);
for (int i = 0; i < size; ++i) {
arc.AddEdge(i, size - i - 1);
}
ArcGraph arc2 = ArcGraph(arc);
EXPECT_TRUE(arc == arc2);
ListGraph list = ListGraph(arc);
EXPECT_TRUE(arc == list);
MatrixGraph matrix = MatrixGraph(arc);
EXPECT_TRUE(arc == matrix);
SetGraph set = SetGraph(arc);
EXPECT_TRUE(arc == set);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}