blob: d2994adc8b08845da2d8f6ebd6fd8203dfd8880c (
plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#ifndef CHESS_TESTER_HPP
#define CHESS_TESTER_HPP
#define CHESS_TEST_SIZE 7
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
struct tested_pieces {
std::string piece_name;
int num_passed;
int num_failed;
friend bool operator==(const tested_pieces& tp1, const tested_pieces& tp2) {
if(tp1.piece_name == tp2.piece_name) {
return true;
}
return false;
}
friend bool operator<(const tested_pieces& tp1, const tested_pieces& tp2) {
if(tp1.piece_name < tp2.piece_name) {
return true;
}
return false;
}
};
class chess_tester {
public:
// sets all the initial values for the tester
chess_tester();
// begins the test suite so that this class can record the results and
// analyse them
void chess_begin_test_suite();
// begins the test
int chess_begin_test(std::string test_name);
// records the result of the test
void chess_end_test(int test_id, bool passed);
// analyses the results and prints them out
void chess_end_test_suite();
// see if the test is acceptable
bool is_in_arr(const std::string& test_piece) const;
// see if test is in vector
bool is_in_vec(const tested_pieces& piece) const;
private:
// checks if the test suite is running
bool ts_begin;
// list of pieces to test
const std::string chess_test_pieces[CHESS_TEST_SIZE] = {
"<INTERNAL>",
"PAWN",
"ROOK",
"KNIGHT",
"BISHOP",
"QUEEN",
"KING"
};
// vector that contains the tested pieces
std::vector<tested_pieces> test_piece;
// the test_id of the current instruction
int test_id;
// the test id of the test that has been started
int test_id_test;
// the current test that is being tested
std::string current_test;
};
#endif
|