-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore_test.cpp
69 lines (62 loc) · 1.65 KB
/
store_test.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
61
62
63
64
65
66
67
68
69
/**
* Testing ass4 movie store functions
*
* @author Olga Kuriatnyk
* @date 3/16/2021
*/
#include <cassert>
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include "store.h"
using namespace std;
void testStore1() {
cout << "Start testStore1" << endl;
// Should do something more, but lets just read files
// since each implementation will
string cfile = "testcommands-1.txt";
stringstream out;
ifstream fs(cfile);
assert(fs.is_open());
char commandType;
string discard;
while (fs >> commandType) {
out << commandType;
getline(fs, discard);
}
fs.close();
string result = "IHHBRIBBIH";
assert(out.str() == result);
cout << "End testStore1" << endl;
}
void testStore2() {
cout << "Start testStore2" << endl;
string customersFile = "customers.txt";
string moviesFile = "movies.txt";
string commandsFile = "commands.txt";
Store store;
store.readCustomersFromFile(customersFile);
store.readMoviesFromFile(moviesFile);
store.readCommandsFromFile(commandsFile);
cout << "End testStore2" << endl;
}
void testStoreFinal() {
cout << "=====================================" << endl;
cout << "Start testStoreFinal" << endl;
string customersFile = "data4customers.txt";
string moviesFile = "data4movies.txt";
string commandsFile = "data4commands.txt";
Store store;
store.readCustomersFromFile(customersFile);
store.readMoviesFromFile(moviesFile);
store.readCommandsFromFile(commandsFile);
store.processCommands();
cout << "End testStoreFinal" << endl;
cout << "=====================================" << endl;
}
void testAll() {
testStore1();
testStore2();
testStoreFinal();
}