-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
202 lines (177 loc) · 4.3 KB
/
test.java
File metadata and controls
202 lines (177 loc) · 4.3 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package UnitTesting;
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Test;
public class test {
@Test
public void addtestSuccess() {
unitTesting u = new unitTesting();
long x = 2;
long y = 2;
long added = u.addInts(x, y);
long expected = 4;
assertEquals(expected, added);
}
@Test
public void addtestFail() {
unitTesting u = new unitTesting();
long x = 1;
long y = 2;
long expected = 4;
long added = u.addInts(x, y);
assertFalse(added == expected);
}
@Test
public void addtestNegative() {
unitTesting u = new unitTesting();
long x = -1;
long y = -2;
long added = u.addInts(x, y);
long expected = -3;
assertEquals(expected, added);
}
@Test
public void addtestOverflow() {
unitTesting u = new unitTesting();
long x = 2000000000;
long y = 2000000000;
long added = u.addInts(x, y);
long expected = 4000000000l;
assertEquals(expected, added);
}
@Test
public void StringsTest() {
unitTesting u = new unitTesting();
String x = "Hello";
String y = "World";
String StringAdd = u.addStrings(x, y);
String expected = "HelloWorld";
assertEquals(expected, StringAdd);
}
@Test
public void StringsTestFail() {
unitTesting u = new unitTesting();
String x = "Hell";
String y = "World";
String StringAdd = u.addStrings(x, y);
String expected = "HelloWorld";
assertFalse(StringAdd == expected);
}
@Test
public void StringsLenTest() {
unitTesting u = new unitTesting();
String x = "Hello";
String y = "World";
int nx = x.length();
int ny = x.length();
int StringAdd = (u.addStrings(x, y)).length();
int expected = nx + ny;
assertEquals(expected, StringAdd);
}
@Test
public void LenTest() {
unitTesting u = new unitTesting();
String s = "Hello";
int length = u.findLen(s);
int expected = 5;
assertEquals(expected, length);
}
@Test
public void LenTestFail() {
unitTesting u = new unitTesting();
String s = "Hello";
int length = u.findLen(s);
int expected = 4;
assertFalse(length == expected);
}
@Test
public void LenTestEmpty() {
unitTesting u = new unitTesting();
String s = "";
int length = u.findLen(s);
int expected = 0;
assertEquals(expected, length);
}
@Test
public void DivTestEquals() {
unitTesting u = new unitTesting();
int x = 4;
int y = 2;
Object divided = u.divXbyY(x, y);
int expected = 2;
assertEquals(expected, divided);
}
@Test
public void DivTestEqualsFail() {
unitTesting u = new unitTesting();
int x = 3;
int y = 2;
Object divided = u.divXbyY(x, y);
Object expected = 2;
assertFalse(divided == expected);
}
@Test
public void DivTestNull() {
unitTesting u = new unitTesting();
int x = 0;
int y = 1;
Object divided = u.divXbyY(x, y);
Object expected = null;
assertEquals(expected, divided);
}
/*@Test
public void DivTest4() {
unitTesting u = new unitTesting();
int x = 0;
int y = 1;
Object divided = u.divXbyY(x, y);
Object expected = null;
assertEquals(expected, divided);
}*/
@Test
public void Arraytest() {
unitTesting u = new unitTesting();
int IntArray[] = {0,2,4,5};
Object reversed = u.reverseIntArray(IntArray);
int[] expected = {5,4,2,0};
assertEquals(expected, reversed);
}
@Test
public void ArraytestFail() {
unitTesting u = new unitTesting();
int[] IntArray = {0,2,4,5};
Object reversed = u.reverseIntArray(IntArray);
int[] expected = {0,4,2,0};
assertFalse(reversed == expected);
}
@Test
public void ArraytestPalendrome() {
unitTesting u = new unitTesting();
int IntArray[] = {0,0,0};
Object reversed = u.reverseIntArray(IntArray);
int[] expected = {0,0,0};
assertTrue(reversed == expected);
}
@Test
public void RangeTest() {
unitTesting u = new unitTesting();
int x = 1;
int y = 1;
int z = 1;
int r = 6;
Object reversed = u.range(x, y, z, r);
int[] expected = {7, 7, 7};
assertEquals(expected, reversed);
}
@Test
public void RangeTestFail() {
unitTesting u = new unitTesting();
int x = 1;
int y = 1;
int z = 1;
int r = 6;
Object reversed = u.range(x, y, z, r);
int[] expected = {0, 0, 0};
assertFalse(reversed == expected);
}
}