Repository navigation
Expand file tree
/
Copy pathbogtest.cpp
More file actions
67 lines (53 loc) · 1.53 KB
/
Copy pathbogtest.cpp
File metadata and controls
67 lines (53 loc) · 1.53 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
//bogtest.cpp
/******************************************************
* Tester file to test basic functionality of your code
* ****************************************************/
#include "baseboggleplayer.h"
#include "boggleplayer.h"
#include <iostream>
#include <vector>
#include <string>
#include <set>
int main (int argc, char* argv[]) {
BaseBogglePlayer * p = new BogglePlayer();
set<string> lex;
string wordA("a");
string wordX("x");
lex.insert(wordA);
lex.insert("z");
string row0[] = {"D","C"};
string row1[] = {"b","A"};
string* board[] = {row0,row1};
set<string> words;
vector<int> locations;
p->buildLexicon(lex);
p->setBoard(2,2,board);
if(p->isInLexicon(wordX)) {
std::cerr << "Apparent problem with isInLexicon #1." << std::endl;
return -1;
}
if(!p->isInLexicon(wordA)) {
std::cerr << "Apparent problem with isInLexicon #2." << std::endl;
return -1;
}
if(p->isOnBoard(wordX).size() > 0) {
std::cerr << "Apparent problem with isOnBoard #1." << std::endl;
return -1;
}
locations.clear();
locations = p->isOnBoard(wordA);
if(locations.size() != 1 || locations[0] != 3) {
std::cerr << "Apparent problem with isOnBoard #2." << std::endl;
return -1;
}
if(!p->getAllValidWords(0,&words)) {
std::cerr << "Apparent problem with getAllValidWords #1." << std::endl;
return -1;
};
if(words.size() != 1 || words.count(wordA) != 1) {
std::cerr << "Apparent problem with getAllValidWords #2." << std::endl;
return -1;
}
delete p;
return 0;
}