-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (52 loc) · 1.82 KB
/
main.cpp
File metadata and controls
65 lines (52 loc) · 1.82 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
#include "Board.h"
#include "Solver.h"
#include "Game.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <chrono>
int main() {
Solver s1;
int passed = 0;
std::ifstream inputFile("../Testing_Suite/Begin_Easy.txt");
if (!inputFile.is_open()) {
std::cerr << "Error opening file!" << '\n';
return 1;
}
std::string line;
int testNum = 1;
auto start = std::chrono::high_resolution_clock::now();
while (std::getline(inputFile, line)) {
if (line.empty()) continue;
std::istringstream ss(line);
std::string position;
int expected;
if (!(ss >> position >> expected)) {
std::cerr << "Error parsing line: " << line << '\n';
continue;
}
Board b1(position);
int result = s1.solve(b1);
if (result == expected) {
std::cout << "Test " << testNum << ": PASS" << '\n';
passed++;
} else {
std::cout << "Test " << testNum << ": FAIL (expected "
<< expected << ", got " << result << ")" << '\n';
}
testNum++;
}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = end - start;
int totalTests = testNum - 1;
std::cout << '\n' << "Pass rate: "
<< (double) passed / totalTests * 100 << "%" << '\n';
std::cout << "Total time: " << elapsed.count() << " seconds" << '\n';
std::cout << "Average time per test: "
<< (elapsed.count() / totalTests) << " seconds" << '\n';
std::cout << "Total node count: " << s1.getNodeCount() << '\n';
std::cout << "Average node count per test: "
<< (double) s1.getNodeCount() / totalTests << '\n';
inputFile.close();
return 0;
}