-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapDriver.cpp
More file actions
50 lines (39 loc) · 1.86 KB
/
MapDriver.cpp
File metadata and controls
50 lines (39 loc) · 1.86 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
#include "Map.h"
#include <iostream>
void testLoadMaps() {
std::cout << "=== Testing Map Loading and Validation ===\n";
// Test with valid map files
std::vector<std::string> testFiles = {
"Chicago.map",
"England.map",
"Florida.map"
};
for (const std::string& filename : testFiles) {
std::cout << "\n--- Testing: " << filename << " ---" << std::endl;
Map* map = MapLoader::loadMap(filename);
if (map) {
std::cout << "Successfully loaded map: " << *map << std::endl;
std::cout << "Territories: " << map->getTerritories().size() << std::endl;
std::cout << "Continents: " << map->getContinents().size() << std::endl;
// Perform validation
bool isValid = map->validate();
std::cout << "Map validation: " << (isValid ? "PASS" : "FAIL") << std::endl;
if (!isValid) {
std::cout << "Detailed validation results:" << std::endl;
std::cout << " - Connected graph: " << (map->isConnectedGraph() ? "YES" : "NO") << std::endl;
std::cout << " - Connected continents: " << (map->continentsAreConnectedSubgraphs() ? "YES" : "NO") << std::endl;
std::cout << " - Each country in one continent: " << (map->eachCountryInOneContinent() ? "YES" : "NO") << std::endl;
}
delete map;
} else {
std::cout << "Failed to load map: " << filename << std::endl;
}
}
// Test with invalid map file
std::cout << "\n--- Testing with invalid map file ---" << std::endl;
Map* invalidMap = MapLoader::loadMap("invalid.map");
if (!invalidMap) {
std::cout << "Correctly rejected invalid map file" << std::endl;
}
std::cout << "\n=== Map Testing Complete ===\n\n";
}