-
Notifications
You must be signed in to change notification settings - Fork 0
/
op_test.hpp
81 lines (65 loc) · 1.68 KB
/
op_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
74
75
76
77
78
79
80
81
#ifndef __OP_TEST_HPP__
#define __OP_TEST_HPP__
#include "gtest/gtest.h"
#include "op.hpp"
//non zero
TEST(OpTest, OpEvaluateNonZero) {
Op* test = new Op(8);
EXPECT_EQ(test->evaluate(), 8);
}
TEST(OpTest, OpEvaluateNonZeroString) {
Op* test = new Op(8);
std::string str = "8.000000";
EXPECT_EQ(test->stringify(),str);
}
//zero
TEST(OpTest, OpEvaluateZero) {
Op* test = new Op(0);
EXPECT_EQ(test->evaluate(), 0);
}
TEST(OpTest, OpEvaluateZeroString) {
Op* test = new Op(0);
std::string str = "0.000000";
EXPECT_EQ(test->stringify(),str);
}
//negative
TEST(OpTest, OpEvaluateNegative) {
Op* test = new Op(-1);
EXPECT_EQ(test->evaluate(), -1);
}
TEST(OpTest, OpEvaluateNegativeString) {
Op* test = new Op(-1);
std::string str = "-1.000000";
EXPECT_EQ(test->stringify(),str);
}
//positive double
TEST(OpTest, OpEvaluatePositiveDouble) {
Op* test = new Op(1.1);
EXPECT_DOUBLE_EQ(test->evaluate(), 1.1);
}
TEST(OpTest, OpEvaluatePositiveDoubleString) {
Op* test = new Op(1.1);
std::string str = "1.100000";
EXPECT_EQ(test->stringify(),str);
}
//zero double
TEST(OpTest, OpEvaluateZeroDouble) {
Op* test = new Op(0.0);
EXPECT_DOUBLE_EQ(test->evaluate(), 0.0);
}
TEST(OpTest, OpEvaluateZeroDoubleString) {
Op* test = new Op(0.0);
std::string str = "0.000000";
EXPECT_EQ(test->stringify(), str);
}
//negative double
TEST(OpTest, OpEvaluateNegativeDouble) {
Op* test = new Op(-0.1);
EXPECT_DOUBLE_EQ(test->evaluate(), -0.1);
}
TEST(OpTest, OpEvaluateNegativeDoubleString) {
Op* test = new Op(-0.1);
std::string str = "-0.100000";
EXPECT_EQ(test->stringify(),str);
}
#endif //__OP_TEST_HPP__