-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
62 lines (42 loc) · 1.52 KB
/
test.cpp
File metadata and controls
62 lines (42 loc) · 1.52 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
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include "../src/HPFolding.hpp"
#include "testFilenames.h"
using namespace std;
const string testInputsFilePath = test13InputsFilePath;
const string testResultsFilePath = test13ResultsFilePath;
int main(int argc, char * argv[]) {
ifstream testInputsFile;
ifstream testResultsFile;
testInputsFile.open(testInputsFilePath);
testResultsFile.open(testResultsFilePath);
string chain;
string expectedScoreBuf;
int expectedScore;
int failed = 0;
int passed = 0;
if (testInputsFile.is_open() && testResultsFile.is_open()) {
HPFolding hp;
while (getline(testInputsFile, chain) && getline(testResultsFile, expectedScoreBuf)) {
stringstream(expectedScoreBuf) >> expectedScore;
//cout << passed << endl;
hp.setChain(chain);
hp.fold();
if (hp.getScore() == expectedScore) {
passed++;
} else {
cout << "Fail: " << chain << endl;
cout << "\t Expected score: " << expectedScore << "\t Produced: " << hp.getScore() << endl;
failed++;
}
}
testInputsFile.close();
testInputsFile.close();
cout << "Result: " << passed << "/" << (passed+failed) << " successfull tests" << endl; // TODO: Time elapsed
} else {
cout << "Couldn't open test files." << endl;
}
return 0;
}