-
Notifications
You must be signed in to change notification settings - Fork 0
/
Select_And_Test.h
124 lines (111 loc) · 5.47 KB
/
Select_And_Test.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef __SELECT_AND_TEST_H__
#define __SELECT_AND_TEST_H__
#include "gtest/gtest.h"
#include "select.hpp"
#include "spreadsheet.hpp"
TEST(AndTest, TrueTest) {
Spreadsheet sheet;
sheet.set_column_names({"First","Last","Age","Major"});
sheet.add_row({"Amanda","Andrews","22","business"});
sheet.add_row({"Brian","Becker","21","computer science"});
sheet.add_row({"Carol","Conners","21","computer science"});
sheet.add_row({"Joe","Jackson","21","mathematics"});
sheet.add_row({"Sarah","Summers","21","computer science"});
sheet.add_row({"Diane","Dole","20","computer engineering"});
sheet.add_row({"David","Dole","22","electrical engineering"});
sheet.add_row({"Dominick","Dole","22","communications"});
sheet.add_row({"George","Genius","9","astrophysics"});
Select_And* test = new Select_And(new Select_Contains(&sheet, "First", "George"),
new Select_Contains(&sheet, "Last", "Genius"));
sheet.set_selection(test);
EXPECT_TRUE(test->select(&sheet, 8));
}
///*
TEST(AndTest, FalseTest) {
Spreadsheet sheet;
sheet.set_column_names({"First","Last","Age","Major"});
sheet.add_row({"Amanda","Andrews","22","business"});
sheet.add_row({"Brian","Becker","21","computer science"});
sheet.add_row({"Carol","Conners","21","computer science"});
sheet.add_row({"Joe","Jackson","21","mathematics"});
sheet.add_row({"Sarah","Summers","21","computer science"});
sheet.add_row({"Diane","Dole","20","computer engineering"});
sheet.add_row({"David","Dole","22","electrical engineering"});
sheet.add_row({"Dominick","Dole","22","communications"});
sheet.add_row({"George","Genius","9","astrophysics"});
Select_And* test = new Select_And(new Select_Contains(&sheet, "First", "Aditi"),
new Select_Contains(&sheet, "Last", "Behera"));
sheet.set_selection(test);
EXPECT_FALSE(test->select(&sheet, 0));
}
TEST(AndTest, HalfHalfTest) {
Spreadsheet sheet;
sheet.set_column_names({"First","Last","Age","Major"});
sheet.add_row({"Amanda","Andrews","22","business"});
sheet.add_row({"Brian","Becker","21","computer science"});
sheet.add_row({"Carol","Conners","21","computer science"});
sheet.add_row({"Joe","Jackson","21","mathematics"});
sheet.add_row({"Sarah","Summers","21","computer science"});
sheet.add_row({"Diane","Dole","20","computer engineering"});
sheet.add_row({"David","Dole","22","electrical engineering"});
sheet.add_row({"Dominick","Dole","22","communications"});
sheet.add_row({"George","Genius","9","astrophysics"});
Select_And* test = new Select_And(new Select_Contains(&sheet, "First", "Aditi"),
new Select_Contains(&sheet, "Last", "Andrews"));
sheet.set_selection(test);
EXPECT_FALSE(test->select(&sheet, 0));
}
TEST(AndTest, EmptyTest) {
Spreadsheet sheet;
sheet.set_column_names({"First","Last","Age","Major"});
sheet.add_row({"Amanda","Andrews","22","business"});
sheet.add_row({"Brian","Becker","21","computer science"});
sheet.add_row({"Carol","Conners","21","computer science"});
sheet.add_row({"Joe","Jackson","21","mathematics"});
sheet.add_row({"Sarah","Summers","21","computer science"});
sheet.add_row({"Diane","Dole","20","computer engineering"});
sheet.add_row({"David","Dole","22","electrical engineering"});
sheet.add_row({"Dominick","Dole","22","communications"});
sheet.add_row({"George","Genius","9","astrophysics"});
Select_And* test = new Select_And(new Select_Contains(&sheet, "First", " "),
new Select_Contains(&sheet, "Last", " "));
sheet.set_selection(test);
EXPECT_FALSE(test->select(&sheet, 1));
}
TEST(AndTest, OrTest) {
Spreadsheet sheet;
sheet.set_column_names({"First","Last","Age","Major"});
sheet.add_row({"Amanda","Andrews","22","business"});
sheet.add_row({"Brian","Becker","21","computer science"});
sheet.add_row({"Carol","Conners","21","computer science"});
sheet.add_row({"Joe","Jackson","21","mathematics"});
sheet.add_row({"Sarah","Summers","21","computer science"});
sheet.add_row({"Diane","Dole","20","computer engineering"});
sheet.add_row({"David","Dole","22","electrical engineering"});
sheet.add_row({"Dominick","Dole","22","communications"});
sheet.add_row({"George","Genius","9","astrophysics"});
Select_And* test = new Select_And(new Select_Or(new Select_Contains(&sheet, "First", "Aditi"),
new Select_Contains(&sheet, "First", "Amanda")),
new Select_Contains(&sheet, "Last", "Andrews"));
sheet.set_selection(test);
EXPECT_TRUE(test->select(&sheet, 0));
}
TEST(AndTest, NotTest) {
Spreadsheet sheet;
sheet.set_column_names({"First","Last","Age","Major"});
sheet.add_row({"Amanda","Andrews","22","business"});
sheet.add_row({"Brian","Becker","21","computer science"});
sheet.add_row({"Carol","Conners","21","computer science"});
sheet.add_row({"Joe","Jackson","21","mathematics"});
sheet.add_row({"Sarah","Summers","21","computer science"});
sheet.add_row({"Diane","Dole","20","computer engineering"});
sheet.add_row({"David","Dole","22","electrical engineering"});
sheet.add_row({"Dominick","Dole","22","communications"});
sheet.add_row({"George","Genius","9","astrophysics"});
Select_And* test = new Select_And(new Select_Not(new Select_Contains(&sheet, "First", "Aditi")),
new Select_Not(new Select_Contains(&sheet, "Last", "Behera")));
sheet.set_selection(test);
EXPECT_TRUE(test->select(&sheet, 2));
}
//*/
#endif