-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate_test.cpp
More file actions
72 lines (60 loc) · 1.96 KB
/
state_test.cpp
File metadata and controls
72 lines (60 loc) · 1.96 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
66
67
68
69
70
71
72
//============================================================================
// Name : cs4511.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <cstdlib>
#include "State.h"
using namespace std;
bool testStateEval(State *s, int expected) {
if (s->stateEval() == expected) { return true;}
cout << "Failed stateEval() test. Expected: " << expected << ", but received: " << s->stateEval() << endl;
return false;
}
bool testGetActive(State *s, Pokeman *expected) {
if (s->getActivePokemon()->equals(*expected)) { return true;}
cout << "Failed getActive test. Expected: " << endl;
expected->print();
cout << "Received: " << endl;
s->getActivePokemon()->print();
return false;
}
bool testGetPassive(State *s, Pokeman *expected) {
if (s->getPassivePokemon()->equals(*expected)) { return true;}
cout << "Failed getActive test. Expected: " << endl;
expected->print();
cout << "Received: " << endl;
s->getActivePokemon()->print();
return false;
}
void runTests() {
TinyAttack *ta = new TinyAttack("damage", -5, 25, 10);
Pokeman *p = new Pokeman(25, 25, ta, ta, ta, ta);
Pokeman *p2 = new Pokeman(10, 10, ta, ta, ta, ta);
State *s = new State(p, p2, 0);
double testsRun = 0;
double testsPassed = 0;
cout << "Running test 1" << endl;
testsRun++;
if(testStateEval(s, 0)) {
testsPassed++;
}
cout << "Running test 2" << endl;
testsRun++;
if(testGetActive(s, p)) {
testsPassed++;
}
cout << "Running test 3" << endl;
testsRun++;
if(testGetPassive(s, p2)) {
testsPassed++;
}
cout << testsRun << " tests run. " << testsPassed << " passed. Pass rate: " << testsPassed/testsRun * 100 << "%" << endl;
}
int main(int args, char** argv) {
runTests();
return 0;
}