-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests-2.cpp
More file actions
55 lines (47 loc) · 1.98 KB
/
tests-2.cpp
File metadata and controls
55 lines (47 loc) · 1.98 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
TEST_CASE("Check if Dijkstra's works on a single airport node") {
vector<Airport> airportDijk = readAirports("data/airports.dat~");
Graph dijkstra = Graph(airportDijk);
output = dijkstra.shortestPath(airportDijk.front(), airportDijk.front());
path = output.second();
REQUIRE(dijkstra.airports_.size() == 1);
REQUIRE(path.size() == 1);
}
TEST_CASE("Check if Dijkstra's works for direct flights") {
vector<Airport> airports = readAirports("data/test-airports.dat");
vector<Route> routes = readRoutes("data/test-routes.dat");
Graph graph = Graph(airports);
output = graph.shortestPath(airports.front(), airports.back());
path = output.second();
pathDist = output.first();
REQUIRE(general.airports_.size() == 3);
REQUIRE(pathDist == 124.48);
}
TEST_CASE("Check if Dijkstra's works for not direct flights") {
vector<Airport> airports = readAirports("data/test1-airports.dat");
vector<Route> routes = readRoutes("data/test1-routes.dat");
Graph graph = Graph(airports);
output = graph.shortestPath(airports.front(), airports.back());
path = output.second();
pathDist = output.first();
REQUIRE(graph.airports_.size() == 6);
REQUIRE(pathDist == 337.022)
}
//traversal
TEST_CASE("Check if traversal is working") {
vector<Airport> airports = readAirports("data/test1-airports.dat");
vector<Route> routes = readRoutes("data/test1-airports.dat");
Graph graph = Graph(airports);
output = graph.DFT(airports.front());
for (unsigned i = 0; i < airports.front().routes_.size(); i++) {
REQUIRE(graph.visited_[i] == true);
}
}
TEST_CASE("Check if traversal is working for unconnected components") {
vector<Airport> airports = readAirports("data/airports-dft.dat");
vector<Route> routes = readRoutes("data/routes-dft.dat");
Graph graph = Graph(airports);
output = graph.DFTDis();
for (unsigned i = 0; i < airports.front().routes_.size(); i++) {
REQUIRE(graph.visited_[i] == true);
}
}