-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_index.h
29 lines (23 loc) · 933 Bytes
/
build_index.h
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
#include <gtest/gtest.h>
#include <map>
#include <set>
#include <string>
#include "search.h"
using namespace std;
TEST(BuildIndex, TinierTxt) {
string filename = "tinier.txt";
map<string, set<string>> expected = {
{"to", {"www.example.com", "www.otherexample.com"}},
{"be", {"www.example.com", "www.otherexample.com"}},
{"ora", {"www.example.com"}},
{"not", {"www.example.com"}},
{"want", {"www.otherexample.com"}},
{"free", {"www.otherexample.com"}},
};
map<string, set<string>> studentIndex;
int studentNumProcesed = buildIndex(filename, studentIndex);
string indexTestFeedback = "buildIndex(\"" + filename + "\", ...) index incorrect\n";
EXPECT_EQ(expected, studentIndex) << indexTestFeedback;
string retTestFeedback = "buildIndex(\"" + filename + "\", ...) return value incorrect\n";
EXPECT_EQ(2, studentNumProcesed) << retTestFeedback;
}