|
@@ -169,4 +169,180 @@ public class ArrazTest {
|
169
|
169
|
//THEN
|
170
|
170
|
Assert.assertEquals(arr[0], actual[3]);
|
171
|
171
|
}
|
|
172
|
+
|
|
173
|
+ @Test
|
|
174
|
+ public void test1getOddEvensOfArray(){
|
|
175
|
+ //GIVEN
|
|
176
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
177
|
+
|
|
178
|
+ //WHEN
|
|
179
|
+ int expected = 2;
|
|
180
|
+ int actual = arraz.getOddEvensOfArray(arr).evens;
|
|
181
|
+
|
|
182
|
+ //THEN
|
|
183
|
+ Assert.assertEquals(expected, actual);
|
|
184
|
+ }
|
|
185
|
+
|
|
186
|
+ @Test
|
|
187
|
+ public void test2getOddEvensOfArray(){
|
|
188
|
+ //GIVEN
|
|
189
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
190
|
+
|
|
191
|
+ //WHEN
|
|
192
|
+ int expected = 3;
|
|
193
|
+ int actual = arraz.getOddEvensOfArray(arr).odds;
|
|
194
|
+
|
|
195
|
+ //THEN
|
|
196
|
+ Assert.assertEquals(expected, actual);
|
|
197
|
+ }
|
|
198
|
+
|
|
199
|
+ @Test
|
|
200
|
+ public void test1findIndexOf() {
|
|
201
|
+ //GIVEN
|
|
202
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
203
|
+ int index = 4;
|
|
204
|
+ //WHEN
|
|
205
|
+ int expected = 5;
|
|
206
|
+ int actual = arraz.findIndexOf(arr, index);
|
|
207
|
+
|
|
208
|
+ //THEN
|
|
209
|
+ Assert.assertEquals(expected, actual);
|
|
210
|
+ }
|
|
211
|
+
|
|
212
|
+ @Test
|
|
213
|
+ public void test2findIndexOf() {
|
|
214
|
+ //GIVEN
|
|
215
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
216
|
+ int index = 1;
|
|
217
|
+ //WHEN
|
|
218
|
+ int expected = 2;
|
|
219
|
+ int actual = arraz.findIndexOf(arr, index);
|
|
220
|
+
|
|
221
|
+ //THEN
|
|
222
|
+ Assert.assertEquals(expected, actual);
|
|
223
|
+ }
|
|
224
|
+
|
|
225
|
+// @Test
|
|
226
|
+// public void test1copyArrayByIterator() {
|
|
227
|
+// //GIVEN
|
|
228
|
+// Object[] arr = {1, 2, 3, 4, 5};
|
|
229
|
+// //WHEN
|
|
230
|
+// Object[] retObject = arraz.copyArrayByIterator(arr);
|
|
231
|
+// int expected = 3;
|
|
232
|
+//
|
|
233
|
+// //THEN
|
|
234
|
+// int actual = retObject.;
|
|
235
|
+// Assert.assertEquals(expected, actual);
|
|
236
|
+// }
|
|
237
|
+//
|
|
238
|
+// @Test
|
|
239
|
+// public void test2copyArrayByIterator() {
|
|
240
|
+//
|
|
241
|
+// }
|
|
242
|
+
|
|
243
|
+ @Test
|
|
244
|
+ public void test1copyArrayByLoop() {
|
|
245
|
+ //GIVEN
|
|
246
|
+ int[] expected = {1, 2, 3, 4, 5};
|
|
247
|
+ //WHEN
|
|
248
|
+ int[] actual = arraz.copyArrayByLoop(expected);
|
|
249
|
+
|
|
250
|
+ //THEN
|
|
251
|
+ Assert.assertEquals(expected[0], actual[0]);
|
|
252
|
+ }
|
|
253
|
+
|
|
254
|
+ @Test
|
|
255
|
+ public void test2copyArrayByLoop() {
|
|
256
|
+ //GIVEN
|
|
257
|
+ int[] expected = {1, 2, 3, 4, 5};
|
|
258
|
+ //WHEN
|
|
259
|
+ int[] actual = arraz.copyArrayByLoop(expected);
|
|
260
|
+
|
|
261
|
+ //THEN
|
|
262
|
+ Assert.assertEquals(expected[expected.length - 1], actual[expected.length - 1]);
|
|
263
|
+ }
|
|
264
|
+
|
|
265
|
+ @Test
|
|
266
|
+ public void test1removeElementFromArray() {
|
|
267
|
+ //GIVEN
|
|
268
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
269
|
+ int removeInt = 5;
|
|
270
|
+ //WHEN
|
|
271
|
+ int expected = 4;
|
|
272
|
+ int actual = arraz.removeElementFromArray(arr, removeInt).length;
|
|
273
|
+ //THEN
|
|
274
|
+ Assert.assertEquals(expected, actual);
|
|
275
|
+ }
|
|
276
|
+
|
|
277
|
+ @Test
|
|
278
|
+ public void test2removeElementFromArray() {
|
|
279
|
+ //GIVEN
|
|
280
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
281
|
+ int removeInt = 1;
|
|
282
|
+ //WHEN
|
|
283
|
+ int expected = 2;
|
|
284
|
+ int[] actual = arraz.removeElementFromArray(arr, removeInt);
|
|
285
|
+ //THEN
|
|
286
|
+ Assert.assertEquals(expected, actual[0]);
|
|
287
|
+ }
|
|
288
|
+
|
|
289
|
+ @Test
|
|
290
|
+ public void test1insertIntoArrayAt() {
|
|
291
|
+ //GIVEN
|
|
292
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
293
|
+ int addInt = 6;
|
|
294
|
+ int atIndex = 3;
|
|
295
|
+ //WHEN
|
|
296
|
+ int expected = 6;
|
|
297
|
+ int[] retArr = arraz.insertIntoArrayAt(arr, atIndex, addInt);
|
|
298
|
+ int actual = retArr[atIndex];
|
|
299
|
+ //THEN
|
|
300
|
+ Assert.assertEquals(expected, actual);
|
|
301
|
+ }
|
|
302
|
+
|
|
303
|
+ @Test
|
|
304
|
+ public void test2insertIntoArrayAt() {
|
|
305
|
+ //GIVEN
|
|
306
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
307
|
+ int addInt = 6;
|
|
308
|
+ int atIndex = 5;
|
|
309
|
+ //WHEN
|
|
310
|
+ int expected = 6;
|
|
311
|
+ int[] retArr = arraz.insertIntoArrayAt(arr, atIndex, addInt);
|
|
312
|
+ int actual = retArr[atIndex];
|
|
313
|
+ //THEN
|
|
314
|
+ Assert.assertEquals(expected, actual);
|
|
315
|
+ }
|
|
316
|
+
|
|
317
|
+ @Test
|
|
318
|
+ public void test1findMaxMinOfArray() {
|
|
319
|
+ //GIVEN
|
|
320
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
321
|
+ //WHEN
|
|
322
|
+ int expectedMax = 5;
|
|
323
|
+ int expectedMin = 1;
|
|
324
|
+ MaxMin maxMin = arraz.findMaxMinOfArray(arr);
|
|
325
|
+
|
|
326
|
+ int actualMax = maxMin.max;
|
|
327
|
+ int actualMin = maxMin.min;
|
|
328
|
+ //THEN
|
|
329
|
+ Assert.assertEquals(expectedMax, actualMax);
|
|
330
|
+ Assert.assertEquals(expectedMin, actualMin);
|
|
331
|
+ }
|
|
332
|
+
|
|
333
|
+ @Test
|
|
334
|
+ public void test2findMaxMinOfArray() {
|
|
335
|
+ //GIVEN
|
|
336
|
+ int[] arr = {1, -2, 300, 4, 5};
|
|
337
|
+ //WHEN
|
|
338
|
+ int expectedMax = 300;
|
|
339
|
+ int expectedMin = -2;
|
|
340
|
+ MaxMin maxMin = arraz.findMaxMinOfArray(arr);
|
|
341
|
+
|
|
342
|
+ int actualMax = maxMin.max;
|
|
343
|
+ int actualMin = maxMin.min;
|
|
344
|
+ //THEN
|
|
345
|
+ Assert.assertEquals(expectedMax, actualMax);
|
|
346
|
+ Assert.assertEquals(expectedMin, actualMin);
|
|
347
|
+ }
|
172
|
348
|
}
|