forked from AlejandroSherman/CS100Lab4Composite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsub_test.hpp
73 lines (72 loc) · 1.85 KB
/
sub_test.hpp
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
#ifndef __SUB_TEST_HPP__
#define __SUB_TEST_HPP__
#include "gtest/gtest.h"
#include "Sub.hpp"
#include <string>
using namespace std;
TEST(SubTest, SubEvaluate_Eight_Minus_Four) {
Op* op1 = new Op(8);
Op* op2 = new Op(4);
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->evaluate(), 4);
}
TEST(SubTest, SubEvaluate_Three_Minus_Six) {
Op* op1 = new Op(3);
Op* op2 = new Op(6);
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->evaluate(), -3);
}
TEST(SubTest, SubEvaluate_Neg_One_Minus_Ten) {
Op* op1 = new Op(-1);
Op* op2 = new Op(10);
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->evaluate(), -11);
}
TEST(SubTest, SubEvaluate_One_Minus_Zero) {
Op* op1 = new Op(1);
Op* op2 = new Op(0);
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->evaluate(), 1);
}
TEST(SubTest, SubEvaluate_Neg_Two_Minus_Neg_Five) {
Op* op1 = new Op(-2);
Op* op2 = new Op(-5);
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->evaluate(),3);
}
TEST(SubTest, SubStringify_Eight_Minus_Four) {
Op* op1 = new Op(8);
Op* op2 = new Op(4);
string result = "8 - 4";
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->stringify(), result);
}
TEST(SubTest, SubStringify_Three_Minus_Six) {
Op* op1 = new Op(3);
Op* op2 = new Op(6);
string result = "3 - 6";
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->stringify(), result);
}
TEST(SubTest, SubStringify_Neg_One_Minus_Ten) {
Op* op1 = new Op(-1);
Op* op2 = new Op(10);
string result = "-1 - 10";
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->stringify(), result);
}
TEST(SubTest, SubStringify_One_Minus_Zero) {
Op* op1 = new Op(1);
Op* op2 = new Op(0);
string result = "1 - 0";
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->stringify(), result);
}
TEST(SubTest, SubStringify_Neg_Two_Minus_Neg_Five) {
Op* op1 = new Op(-2);
Op* op2 = new Op(-5);
string result = "-2 - -5";
Sub* test = new Sub(op1, op2);
EXPECT_EQ(test->stringify(), result);
}
#endif