|
@@ -1,119 +1,528 @@
|
1
|
1
|
import org.junit.Assert;
|
2
|
2
|
import org.junit.Test;
|
3
|
3
|
|
4
|
|
-import static org.junit.Assert.*;
|
|
4
|
+import java.util.ArrayList;
|
|
5
|
+import java.util.Arrays;
|
|
6
|
+import java.util.List;
|
|
7
|
+
|
|
8
|
+
|
5
|
9
|
|
6
|
10
|
public class ArrazTest {
|
7
|
|
- int[] spiffyHandyIntArray = new int[] {4,5,102,6,-7,12,-32,92,8};
|
|
11
|
+ Arraz arraz = new Arraz();
|
8
|
12
|
|
9
|
13
|
@Test
|
10
|
|
- public void test1SumValueOfArrayInt(){
|
11
|
|
- int[] spiffyHandyIntArray = new int[] {4,5,102,6,-7,12,-32,92,8};
|
12
|
|
-
|
13
|
|
- int expecte = 190;
|
14
|
|
- int actual = Arraz.sumValuesOfArray(spiffyHandyIntArray);
|
15
|
|
- Assert.assertEquals(expecte,actual);
|
|
14
|
+ public void test1SumValueOfArrayInt() {
|
|
15
|
+ Integer[] spiffyHandyIntArray ={4, 5, 102, 6, -7, 12, -32, 92, 8};
|
16
|
16
|
|
|
17
|
+ int expected = 190;
|
|
18
|
+ int actual = arraz.sumValuesOfArray(spiffyHandyIntArray);
|
|
19
|
+ Assert.assertEquals(expected, actual);
|
17
|
20
|
|
18
|
21
|
|
19
|
22
|
}
|
|
23
|
+
|
20
|
24
|
@Test
|
21
|
|
- public void test2SumValueOfArrayInt(){
|
22
|
|
- int[] spiffyHandyIntArray = new int[] {4,5,6,-7,12,-32,92,};
|
|
25
|
+ public void test2SumValueOfArrayInt() {
|
|
26
|
+ Integer[] spiffyHandyIntArray = { 4, 5, 6, -7, 12, -32, 92};
|
23
|
27
|
|
24
|
28
|
int expecte = 80;
|
25
|
|
- int actual = Arraz.sumValuesOfArray(spiffyHandyIntArray);
|
26
|
|
- Assert.assertEquals(expecte,actual);
|
27
|
|
-
|
|
29
|
+ int actual = arraz.sumValuesOfArray(spiffyHandyIntArray);
|
|
30
|
+ Assert.assertEquals(expecte, actual);
|
28
|
31
|
|
29
|
32
|
|
30
|
33
|
}
|
31
|
34
|
|
32
|
35
|
|
33
|
36
|
@Test
|
34
|
|
- public void test1SumValueOfArrayDouble(){
|
35
|
|
- double[] spiffyHandyDoubleArray = new double[] {1.0, 0.5, 3.6, 3.14159};
|
|
37
|
+ public void test1SumValueOfArrayDouble() {
|
|
38
|
+ double[] spiffyHandyDoubleArray = new double[]{1.0, 0.5, 3.6, 3.14159};
|
36
|
39
|
|
37
|
40
|
|
38
|
41
|
double expecte = 8.24159;
|
39
|
|
- double actual = Arraz.sumDoublesOfArray(spiffyHandyDoubleArray);
|
40
|
|
- Assert.assertEquals(expecte,actual,0.00001);
|
41
|
|
-
|
|
42
|
+ double actual = arraz.sumDoublesOfArray(spiffyHandyDoubleArray);
|
|
43
|
+ Assert.assertEquals(expecte, actual, 0.00001);
|
42
|
44
|
|
43
|
45
|
|
44
|
46
|
}
|
45
|
47
|
|
46
|
48
|
@Test
|
47
|
|
- public void test2SumValueOfArrayDouble(){
|
48
|
|
- double[] spiffyHandyDoubleArray = new double[] {1.0, 0.5, 3.6 -0.8};
|
|
49
|
+ public void test2SumValueOfArrayDouble() {
|
|
50
|
+ double[] spiffyHandyDoubleArray = new double[]{1.0, 0.5, 3.6 - 0.8};
|
49
|
51
|
|
50
|
52
|
|
51
|
53
|
double expecte = 4.3;
|
52
|
|
- double actual = Arraz.sumDoublesOfArray(spiffyHandyDoubleArray);
|
53
|
|
- Assert.assertEquals(expecte,actual,0.01);
|
|
54
|
+ double actual = arraz.sumDoublesOfArray(spiffyHandyDoubleArray);
|
|
55
|
+ Assert.assertEquals(expecte, actual, 0.01);
|
54
|
56
|
|
55
|
57
|
|
56
|
58
|
}
|
57
|
59
|
|
58
|
60
|
@Test
|
59
|
|
- public void test1AverageOfArray(){
|
60
|
|
- int[] spiffyHandyIntArray = new int[] {4,5,6,-7,12,-32,92,};
|
61
|
|
- int expected = 11;
|
62
|
|
- int actual = Arraz.averageOfArray(spiffyHandyIntArray);
|
63
|
|
- Assert.assertEquals(expected, actual);
|
|
61
|
+ public void test1AverageOfArray() {
|
|
62
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
|
|
63
|
+ int expected = 11;
|
|
64
|
+ int actual = arraz.averageOfArray(spiffyHandyIntArray);
|
|
65
|
+ Assert.assertEquals(expected, actual);
|
64
|
66
|
}
|
|
67
|
+
|
65
|
68
|
@Test
|
66
|
|
- public void test2AverageOfArray(){
|
67
|
|
- int[] spiffyHandyIntArray = new int[] {4,5,6,10};
|
|
69
|
+ public void test2AverageOfArray() {
|
|
70
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, 10};
|
68
|
71
|
int expected = 6;
|
69
|
|
- int actual = Arraz.averageOfArray(spiffyHandyIntArray);
|
|
72
|
+ int actual = arraz.averageOfArray(spiffyHandyIntArray);
|
70
|
73
|
Assert.assertEquals(expected, actual);
|
71
|
74
|
}
|
72
|
75
|
|
73
|
76
|
@Test
|
74
|
|
- public void test1DoubleAverageOfArray(){
|
75
|
|
- double[] spiffyHandyIntArray = new double[] {4.3,5.9,6.09,10.8};
|
|
77
|
+ public void test1DoubleAverageOfArray() {
|
|
78
|
+ double[] spiffyHandyIntArray = new double[]{4.3, 5.9, 6.09, 10.8};
|
76
|
79
|
double expected = 6.77;
|
77
|
|
- double actual = Arraz.doubleAverageOfArray(spiffyHandyIntArray);
|
|
80
|
+ double actual = arraz.doubleAverageOfArray(spiffyHandyIntArray);
|
78
|
81
|
Assert.assertEquals(expected, actual, 0.01);
|
79
|
82
|
}
|
80
|
83
|
|
81
|
84
|
@Test
|
82
|
|
- public void test2DoubleAverageOfArray(){
|
83
|
|
- double[] spiffyHandyIntArray = new double[] {8.0,9.9,8.009,77.06};
|
|
85
|
+ public void test2DoubleAverageOfArray() {
|
|
86
|
+ double[] spiffyHandyIntArray = new double[]{8.0, 9.9, 8.009, 77.06};
|
84
|
87
|
double expected = 25.742;
|
85
|
|
- double actual = Arraz.doubleAverageOfArray(spiffyHandyIntArray);
|
|
88
|
+ double actual = arraz.doubleAverageOfArray(spiffyHandyIntArray);
|
86
|
89
|
Assert.assertEquals(expected, actual, 0.001);
|
87
|
90
|
}
|
88
|
91
|
|
89
|
92
|
|
90
|
93
|
@Test
|
91
|
|
- public void test1ContainsValue(){
|
92
|
|
- int[] spiffyHandyIntArray = new int[] {4,5,6,-7,12,-32,92,};
|
93
|
|
- int num = -32;
|
94
|
|
- Assert.assertTrue(Arraz.containValue(spiffyHandyIntArray,num));
|
|
94
|
+ public void test1ContainsValue() {
|
|
95
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
|
|
96
|
+ int num = -32;
|
|
97
|
+ Assert.assertTrue(arraz.containValue(spiffyHandyIntArray, num));
|
95
|
98
|
|
96
|
99
|
|
97
|
100
|
}
|
98
|
101
|
|
99
|
102
|
@Test
|
100
|
|
- public void test2ContainsValue(){
|
101
|
|
- int[] spiffyHandyIntArray = new int[] {4,5,6,-7,12,-32,92,};
|
|
103
|
+ public void test2ContainsValue() {
|
|
104
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
|
102
|
105
|
int num = 6;
|
103
|
|
- Assert.assertTrue(Arraz.containValue(spiffyHandyIntArray,num));
|
|
106
|
+ Assert.assertTrue(arraz.containValue(spiffyHandyIntArray, num));
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+ @Test
|
|
113
|
+ public void test1ReverseArray() {
|
|
114
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
|
|
115
|
+
|
|
116
|
+ Integer[] expected = {92, -32, 12, -7, 6, 5, 4};
|
|
117
|
+ Integer[] actual = arraz.reverseArray(spiffyHandyIntArray);
|
|
118
|
+ Assert.assertTrue(Arrays.equals(expected,actual));
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+ }
|
|
122
|
+
|
|
123
|
+ @Test
|
|
124
|
+ public void test2ReverseArray() {
|
|
125
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
|
|
126
|
+
|
|
127
|
+ Integer[] expected = {92, -32, 12, -7, 6, 5, 4};
|
|
128
|
+ Integer[] actual = arraz.reverseArray(spiffyHandyIntArray);
|
|
129
|
+ Assert.assertTrue(Arrays.equals(expected,actual));
|
104
|
130
|
|
105
|
131
|
|
106
|
132
|
}
|
107
|
133
|
|
|
134
|
+ @Test
|
|
135
|
+ public void test1getOddEvensOfArray() {
|
|
136
|
+
|
|
137
|
+ int[] spiffyHandyIntArray = {4, 5, 6};
|
|
138
|
+ OddEven expected = new OddEven(5, 4);
|
|
139
|
+ OddEven actual = arraz.getOddEvensOfArray(spiffyHandyIntArray);
|
|
140
|
+ Assert.assertEquals( expected, actual);
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+ }
|
|
144
|
+
|
|
145
|
+ @Test
|
|
146
|
+ public void test2getOddEvensOfArray() {
|
|
147
|
+ int[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
|
|
148
|
+ OddEven expected = new OddEven(-7, 12);
|
|
149
|
+ OddEven actual = arraz.getOddEvensOfArray(spiffyHandyIntArray);
|
|
150
|
+ Assert.assertEquals(expected, actual);
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+ }
|
|
154
|
+
|
|
155
|
+ @Test
|
|
156
|
+ public void test1FindIndexOff() {
|
|
157
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
|
|
158
|
+
|
|
159
|
+ int expected = 3;
|
|
160
|
+ int actual = arraz.findIndexOf(spiffyHandyIntArray, -7);
|
|
161
|
+ Assert.assertEquals(expected, actual);
|
|
162
|
+ }
|
|
163
|
+
|
|
164
|
+ @Test
|
|
165
|
+ public void test2FindIndexOff() {
|
|
166
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
|
|
167
|
+ int expected = 0;
|
|
168
|
+ int actual = arraz.findIndexOf(spiffyHandyIntArray, 4);
|
|
169
|
+ Assert.assertEquals(expected, actual);
|
|
170
|
+ }
|
|
171
|
+ @Test
|
|
172
|
+ public void test1FindValueAt(){
|
|
173
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
|
|
174
|
+ int expected = 12;
|
|
175
|
+ int actual = arraz.findValueAt(spiffyHandyIntArray, 4);
|
|
176
|
+ Assert.assertEquals(expected,actual);
|
|
177
|
+ }@Test
|
|
178
|
+ public void test2FindValueAt(){
|
|
179
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
|
|
180
|
+ int expected = -32;
|
|
181
|
+ int actual = arraz.findValueAt(spiffyHandyIntArray, 5);
|
|
182
|
+ Assert.assertEquals(expected,actual);
|
|
183
|
+ }
|
|
184
|
+
|
108
|
185
|
|
|
186
|
+ @Test
|
|
187
|
+ public void test1CopyArrayByInterator() {
|
|
188
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
|
|
189
|
+ Integer[] expected = {4, 5, 6, -7, 12, -32, 92};
|
|
190
|
+ Integer[] actual = arraz.copyArrayByInterator(spiffyHandyIntArray);
|
|
191
|
+
|
|
192
|
+ Assert.assertEquals(expected, actual);
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+ }
|
|
196
|
+
|
|
197
|
+ @Test
|
|
198
|
+ public void test2CopyArrayByInterator() {
|
|
199
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
|
|
200
|
+ Integer[] expected = {4, 5, 6, -7, 12, -32, 92};
|
|
201
|
+ Integer[] actual = arraz.copyArrayByInterator(spiffyHandyIntArray);
|
|
202
|
+
|
|
203
|
+ Assert.assertEquals(expected, actual);
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+ }
|
|
207
|
+
|
|
208
|
+ @Test
|
|
209
|
+ public void test1CopyArrayByLoop() {
|
|
210
|
+ int[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
|
|
211
|
+ int[] expected = {4, 5, 6, -7, 12, -32, 92};
|
|
212
|
+ int [] actual = arraz.copyArrayByloop(spiffyHandyIntArray);
|
|
213
|
+
|
|
214
|
+ Assert.assertTrue(Arrays.equals(expected,actual));
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+ }
|
|
218
|
+
|
|
219
|
+ @Test
|
|
220
|
+ public void test2CopyArrayByLoop() {
|
|
221
|
+ int[] spiffyHandyIntArray = {4, 5, 6};
|
|
222
|
+ int[] expected = {4, 5, 6};
|
|
223
|
+ int [] actual = arraz.copyArrayByloop(spiffyHandyIntArray);
|
|
224
|
+
|
|
225
|
+ Assert.assertTrue(Arrays.equals(expected, actual));
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+ }
|
|
229
|
+ @Test
|
|
230
|
+ public void test1RemoveElementFromArray(){
|
|
231
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6};
|
|
232
|
+
|
|
233
|
+ arraz.removeElemetFromArray(spiffyHandyIntArray, 2);
|
|
234
|
+ Assert.assertFalse(arraz.containValue(spiffyHandyIntArray,2));
|
|
235
|
+ }
|
|
236
|
+ @Test
|
|
237
|
+ public void test2RemoveElementFromArray(){
|
|
238
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6};
|
|
239
|
+ int expected = 0;
|
|
240
|
+ arraz.removeElemetFromArray(spiffyHandyIntArray, 6);
|
|
241
|
+ Assert.assertEquals(arraz.findIndexOf(spiffyHandyIntArray,5), expected);
|
|
242
|
+}
|
109
|
243
|
|
110
|
244
|
@Test
|
111
|
|
- public void testReverseArray(){
|
112
|
|
- int[] spiffyHandyIntArray = {4,5,6,-7,12,-32,92,};
|
|
245
|
+ public void test1InsertIntoArrayAt(){
|
|
246
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6};
|
|
247
|
+ Integer num = 8;
|
|
248
|
+ int expected = 0;
|
113
|
249
|
|
114
|
|
- int [] expected = {92,-32,12,-7,6,5,4};
|
115
|
|
- int [] actual = Arraz.reverseArray(spiffyHandyIntArray);
|
|
250
|
+ arraz.insertIntoArrayAt(spiffyHandyIntArray, num, 0);
|
116
|
251
|
|
|
252
|
+ Assert.assertEquals(expected, arraz.findIndexOf(spiffyHandyIntArray, 8));
|
117
|
253
|
|
118
|
254
|
}
|
|
255
|
+ @Test
|
|
256
|
+ public void test2InsertIntoArrayAt() {
|
|
257
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6};
|
|
258
|
+ Integer num = 7;
|
|
259
|
+ int expected = 0;
|
|
260
|
+
|
|
261
|
+ arraz.insertIntoArrayAt(spiffyHandyIntArray, num, 2);
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+ Assert.assertEquals(expected, arraz.findIndexOf(spiffyHandyIntArray, 8));
|
|
265
|
+ }
|
|
266
|
+ @Test
|
|
267
|
+ public void test1FindMaxMinOfArray() {
|
|
268
|
+
|
|
269
|
+ Integer[] spiffyHandyIntArray = {4, 5, 6};
|
|
270
|
+ MaxMin expected = new MaxMin(6, 4);
|
|
271
|
+ MaxMin actual = arraz.findMaxMinOfArray(spiffyHandyIntArray);
|
|
272
|
+ Assert.assertEquals(expected, actual);
|
|
273
|
+ }
|
|
274
|
+ @Test
|
|
275
|
+ public void test2FindMaxMinOfArray() {
|
|
276
|
+
|
|
277
|
+ Integer[] spiffyHandyIntArray = {8,3,90};
|
|
278
|
+ MaxMin expected = new MaxMin(90, 3);
|
|
279
|
+ MaxMin actual = arraz.findMaxMinOfArray(spiffyHandyIntArray);
|
|
280
|
+ Assert.assertEquals(expected, actual);
|
|
281
|
+ }
|
|
282
|
+@Test
|
|
283
|
+ public void test1RemoveDupesFromArray(){
|
|
284
|
+ Integer[] spiffyHandyIntArray = {8, 8, 3,90, 90,77,8};
|
|
285
|
+ Integer [] expected = {8,3,90,77};
|
|
286
|
+ Integer [] actual = arraz.removeDupesFromArray(spiffyHandyIntArray);
|
|
287
|
+ Assert.assertTrue(Arrays.equals(expected,actual));
|
|
288
|
+}
|
|
289
|
+
|
|
290
|
+ @Test
|
|
291
|
+ public void test2RemoveDupesFromArray(){
|
|
292
|
+ Integer[] spiffyHandyIntArray = {-1,-1,22,66,22,8,90,90};
|
|
293
|
+ Integer [] expected = {-1,22,66,8,90};
|
|
294
|
+ Integer [] actual = arraz.removeDupesFromArray(spiffyHandyIntArray);
|
|
295
|
+ Assert.assertTrue(Arrays.equals(expected,actual));
|
|
296
|
+ }
|
|
297
|
+ @Test
|
|
298
|
+ public void test1find2ndLargestValueFromArray(){
|
|
299
|
+ double[] spiffyHandyIntArray = {8.3, 8.7, 3.90, 90.77};
|
|
300
|
+ double expected = 8.7;
|
|
301
|
+
|
|
302
|
+ double actual = arraz.find2ndLargestValueFromArrayDouble(spiffyHandyIntArray);
|
|
303
|
+ Assert.assertEquals(expected,actual, 0.001);
|
|
304
|
+ }
|
|
305
|
+
|
|
306
|
+ @Test
|
|
307
|
+ public void test2find2ndLargestValueFromArray(){
|
|
308
|
+ double[] spiffyHandyIntArray = {4.99,99.5,8.95};
|
|
309
|
+ double expected = 8.95;
|
|
310
|
+
|
|
311
|
+ double actual = arraz.find2ndLargestValueFromArrayDouble(spiffyHandyIntArray);
|
|
312
|
+ Assert.assertEquals(expected,actual, 0.001);
|
|
313
|
+ }
|
|
314
|
+ @Test
|
|
315
|
+ public void test1makeMeAnArrayListFromArray(){
|
|
316
|
+ Integer[] spiffyHandyIntArray = {4,99,8,};
|
|
317
|
+ List<Integer> list = new ArrayList<Integer>();
|
|
318
|
+ list.add(4);
|
|
319
|
+ list.add(99);
|
|
320
|
+ list.add(8);
|
|
321
|
+ List<Integer> actual = arraz.makeMeAnArrayListFromArray(spiffyHandyIntArray);
|
|
322
|
+
|
|
323
|
+ Assert.assertEquals(list,actual);
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+ }
|
|
327
|
+ @Test
|
|
328
|
+ public void test2makeMeAnArrayListFromArray(){
|
|
329
|
+ Integer[] spiffyHandyIntArray = {22,100,3};
|
|
330
|
+ List<Integer> list = new ArrayList<Integer>();
|
|
331
|
+ list.add(22);
|
|
332
|
+ list.add(100);
|
|
333
|
+ list.add(3);
|
|
334
|
+ List<Integer> actual = arraz.makeMeAnArrayListFromArray(spiffyHandyIntArray);
|
|
335
|
+
|
|
336
|
+ Assert.assertEquals(list,actual);
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+ }
|
|
340
|
+ @Test
|
|
341
|
+ public void test1MakeAnArrayFromList(){
|
|
342
|
+
|
|
343
|
+ List<Integer> list = new ArrayList<Integer>();
|
|
344
|
+ list.add(22);
|
|
345
|
+ list.add(100);
|
|
346
|
+ list.add(3);
|
|
347
|
+ Integer [] expecte = {22,100,3};
|
|
348
|
+ Integer [] actual = arraz.makeMeAnArrayFromArrayList(list);
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+ Assert.assertEquals(expecte,actual);
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+ }
|
|
355
|
+
|
|
356
|
+ @Test
|
|
357
|
+ public void test2MakeAnArrayFromList(){
|
|
358
|
+
|
|
359
|
+ List<Integer> list = new ArrayList<Integer>();
|
|
360
|
+ list.add(1);
|
|
361
|
+ list.add(10);
|
|
362
|
+ list.add(3);
|
|
363
|
+ Integer [] expecte = {1,10,3};
|
|
364
|
+ Integer [] actual = arraz.makeMeAnArrayFromArrayList(list);
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+ Assert.assertEquals(expecte,actual);
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+ }
|
|
371
|
+ @Test
|
|
372
|
+ public void test1check2ArraysForEqual(){
|
|
373
|
+ int [] arr1 = {1,2,3};
|
|
374
|
+ int [] arr2 = { 1,2,3};
|
|
375
|
+ Assert.assertTrue(arraz.check2ArraysForEqual(arr1,arr2));
|
|
376
|
+ }
|
|
377
|
+
|
|
378
|
+ @Test
|
|
379
|
+ public void test2check2ArraysForEqual(){
|
|
380
|
+ int [] arr1 = {1,2,22,3,45};
|
|
381
|
+ int [] arr2 = { 1,2,22,3,45};
|
|
382
|
+ Assert.assertTrue(arraz.check2ArraysForEqual(arr1,arr2));
|
|
383
|
+ }
|
|
384
|
+ @Test
|
|
385
|
+ public void test1averageArrayWithoutMaxMin(){
|
|
386
|
+ Integer [] arr1 = {1,2,22,3,45,33};
|
|
387
|
+ int expected = 9;
|
|
388
|
+ int actual = arraz.averageArrayWithoutMaxMin(arr1);
|
|
389
|
+ Assert.assertEquals(expected,actual);
|
|
390
|
+ }
|
|
391
|
+ @Test
|
|
392
|
+ public void test2averageArrayWithoutMaxMin(){
|
|
393
|
+ Integer [] arr1 = {1,2,3,4,33};
|
|
394
|
+ int expected = 3;
|
|
395
|
+ int actual = arraz.averageArrayWithoutMaxMin(arr1);
|
|
396
|
+ Assert.assertEquals(expected,actual);
|
|
397
|
+ }
|
|
398
|
+ @Test
|
|
399
|
+ public void test1arrayHas65and77(){
|
|
400
|
+ Integer [] arr1 = {65,77};
|
|
401
|
+
|
|
402
|
+ Assert.assertTrue(arraz.arrayHas65and77(arr1));
|
|
403
|
+
|
|
404
|
+ }
|
|
405
|
+ @Test
|
|
406
|
+ public void test2arrayHas65and77(){
|
|
407
|
+ Integer[] arr1 = {1,2,3,4,33};
|
|
408
|
+
|
|
409
|
+ Assert.assertFalse(arraz.arrayHas65and77(arr1));
|
|
410
|
+
|
|
411
|
+ }
|
|
412
|
+
|
|
413
|
+ @Test
|
|
414
|
+ public void test1theTotalOfTensIs30(){
|
|
415
|
+ int [] arr1 = {1,20,10,4,10,5,6,10};
|
|
416
|
+ Assert.assertTrue(arraz.theTotalofTensIs30(arr1));
|
|
417
|
+ }
|
|
418
|
+ @Test
|
|
419
|
+ public void test2theTotalOfTensIs30(){
|
|
420
|
+ int [] arr1 = {1,20,10,4,5,6,10};
|
|
421
|
+ Assert.assertFalse(arraz.theTotalofTensIs30(arr1));
|
|
422
|
+ }
|
|
423
|
+
|
|
424
|
+ @Test
|
|
425
|
+ public void test1findSmallerAndSecondSmaller(){
|
|
426
|
+ Integer[] arr1 = {1,20,10,4,5,6,10};
|
|
427
|
+ int expected = 14;
|
|
428
|
+ int actual = arraz.findSmallerAndSecondSmaller(arr1);
|
|
429
|
+ Assert.assertEquals(expected,actual);
|
|
430
|
+ }
|
|
431
|
+ @Test
|
|
432
|
+ public void test2findSmallerAndSecondSmaller(){
|
|
433
|
+ Integer[] arr1 = {7,20,10,4,5,6,10};
|
|
434
|
+ int expected = 45;
|
|
435
|
+ int actual = arraz.findSmallerAndSecondSmaller(arr1);
|
|
436
|
+ Assert.assertEquals(expected,actual);
|
|
437
|
+ }
|
|
438
|
+
|
|
439
|
+ @Test
|
|
440
|
+ public void test1RemoveLastItemAndCopy(){
|
|
441
|
+ Integer[] arr1 = {1,20,10,4,5,6,10};
|
|
442
|
+ Integer[] expected= {1,20,10,4,5,6};
|
|
443
|
+ Integer [] actual = arraz.removeLastItemAndCopy(arr1);
|
|
444
|
+ Assert.assertTrue(Arrays.equals(expected,actual));
|
|
445
|
+
|
|
446
|
+ }
|
|
447
|
+ @Test
|
|
448
|
+ public void test2RemoveLastItemAndCopy(){
|
|
449
|
+ Integer[] arr1 = {5,6,10};
|
|
450
|
+ Integer[] expected= {5,6};
|
|
451
|
+ Integer [] actual = arraz.removeLastItemAndCopy(arr1);
|
|
452
|
+ Assert.assertTrue(Arrays.equals(expected,actual));
|
|
453
|
+
|
|
454
|
+ }
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+ @Test
|
|
458
|
+ public void test1RemoveFirstItemAndCopy() {
|
|
459
|
+ Integer[] arr1 = {5, 6, 10};
|
|
460
|
+ Integer[] expected = {6, 10};
|
|
461
|
+ Integer[] actual = arraz.removeFirstItemAndCopy(arr1);
|
|
462
|
+ Assert.assertTrue(Arrays.equals(expected, actual));
|
|
463
|
+
|
|
464
|
+ }
|
|
465
|
+ @Test
|
|
466
|
+ public void test2RemoveFirstItemAndCopy() {
|
|
467
|
+ Integer[] arr1 = { 6,10,88,9};
|
|
468
|
+ Integer[] expected = {10,88,9};
|
|
469
|
+ Integer[] actual = arraz.removeFirstItemAndCopy(arr1);
|
|
470
|
+ Assert.assertTrue(Arrays.equals(expected, actual));
|
|
471
|
+
|
|
472
|
+ }
|
|
473
|
+ @Test
|
|
474
|
+ public void test1InsertAtStatAndCopy() {
|
|
475
|
+ Integer [] arr1 = {6,10,88,9};
|
|
476
|
+ Integer num = 2;
|
|
477
|
+ Integer [] expected = {2,6,10,88,9};
|
|
478
|
+ Integer[] actual = arraz.insertAtStartAndCopy(arr1,num);
|
|
479
|
+ Assert.assertEquals(expected, actual);
|
|
480
|
+
|
|
481
|
+ }
|
|
482
|
+ @Test
|
|
483
|
+ public void test2InsertAtStatAndCopy() {
|
|
484
|
+ Integer [] arr1 = {6,10,88,9};
|
|
485
|
+ Integer num = 88;
|
|
486
|
+ Integer [] expected = {88,6,10,88,9};
|
|
487
|
+ Integer[] actual = arraz.insertAtStartAndCopy(arr1,num);
|
|
488
|
+ Assert.assertEquals(expected, actual);
|
|
489
|
+
|
|
490
|
+ }
|
|
491
|
+ @Test
|
|
492
|
+ public void test1InsertAtEndAndCopy() {
|
|
493
|
+ Integer [] arr1 = {6,10,88,9};
|
|
494
|
+ Integer num = 82;
|
|
495
|
+ Integer [] expected = {6,10,88,9,82};
|
|
496
|
+ Integer[] actual = arraz.insertAtEndAndCopy(arr1,num);
|
|
497
|
+ Assert.assertEquals(expected, actual);
|
|
498
|
+
|
|
499
|
+ }
|
|
500
|
+ @Test
|
|
501
|
+ public void test2InsertAtEndAndCopy() {
|
|
502
|
+ Integer [] arr1 = {6,10,88,9};
|
|
503
|
+ Integer num = 3;
|
|
504
|
+ Integer [] expected = {6,10,88,9,3};
|
|
505
|
+ Integer[] actual = arraz.insertAtEndAndCopy(arr1,num);
|
|
506
|
+ Assert.assertEquals(expected, actual);
|
|
507
|
+
|
|
508
|
+ }
|
|
509
|
+ @Test
|
|
510
|
+ public void test1SortArrayIntoEvensThenOdds(){
|
|
511
|
+ Integer [] arr1 = {1,2,3,4,5,6};
|
|
512
|
+ Integer[] expected = {2,4,6,1,3,5};
|
|
513
|
+ Integer[] actual = arraz.sortArrayIntoEvensThenOdds(arr1);
|
|
514
|
+ //System.out.println(Arrays.toString(actual));
|
|
515
|
+ Assert.assertEquals(expected,actual);
|
|
516
|
+ }
|
|
517
|
+ @Test
|
|
518
|
+ public void test2SortArrayIntoEvensThenOdds(){
|
|
519
|
+ Integer [] arr1 = {7,22,33,44,5};
|
|
520
|
+ Integer[] expected = {22,44,5,7,33};
|
|
521
|
+ Integer[] actual = arraz.sortArrayIntoEvensThenOdds(arr1);
|
|
522
|
+ //System.out.println(Arrays.toString(actual));
|
|
523
|
+ Assert.assertEquals(expected,actual);
|
|
524
|
+ }
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
119
|
528
|
}
|