-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbogtest.cpp
60 lines (49 loc) · 1.35 KB
/
bogtest.cpp
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
#include "iboggleplayer.h"
#include "boggleplayer.h"
#include <iostream>
#include <vector>
#include <string>
#include <set>
int main (int argc, char* argv[]) {
IBogglePlayer * p = new BogglePlayer();
vector<string> lex;
string wordA("a");
string wordX("x");
lex.push_back(wordA);
lex.push_back("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;
}