|
@@ -2,6 +2,8 @@ import org.junit.Assert;
|
2
|
2
|
import org.junit.Before;
|
3
|
3
|
import org.junit.Test;
|
4
|
4
|
|
|
5
|
+import java.util.ArrayList;
|
|
6
|
+
|
5
|
7
|
import static org.junit.Assert.*;
|
6
|
8
|
|
7
|
9
|
public class ArrazTest {
|
|
@@ -382,4 +384,116 @@ public class ArrazTest {
|
382
|
384
|
//THEN
|
383
|
385
|
Assert.assertEquals(expected, actual);
|
384
|
386
|
}
|
|
387
|
+
|
|
388
|
+ @Test
|
|
389
|
+ public void test1find2ndLargestValueFromArray() {
|
|
390
|
+ //GIVEN
|
|
391
|
+ double[] arr = {10, 20.2, 30.3, 40.4, 50};
|
|
392
|
+ //WHEN
|
|
393
|
+ double expected = 40.4;
|
|
394
|
+
|
|
395
|
+ double actual = arraz.find2ndLargestValueFromArray(arr);
|
|
396
|
+ //THEN
|
|
397
|
+ Assert.assertEquals(expected, actual);
|
|
398
|
+ }
|
|
399
|
+
|
|
400
|
+ @Test
|
|
401
|
+ public void test2find2ndLargestValueFromArray() {
|
|
402
|
+ //GIVEN
|
|
403
|
+ double[] arr = {40.5, 500, 10, 20.2, 30.3, 40.4};
|
|
404
|
+ //WHEN
|
|
405
|
+ double expected = 40.5;
|
|
406
|
+
|
|
407
|
+ double actual = arraz.find2ndLargestValueFromArray(arr);
|
|
408
|
+ //THEN
|
|
409
|
+ Assert.assertEquals(expected, actual);
|
|
410
|
+ }
|
|
411
|
+
|
|
412
|
+ @Test
|
|
413
|
+ public void test1makeMeAnArrayListFromArray() {
|
|
414
|
+ //GIVEN
|
|
415
|
+ int[] arr = {1, 2, 3, 4, 5, 3};
|
|
416
|
+ //WHEN
|
|
417
|
+ int expected = 5;
|
|
418
|
+
|
|
419
|
+ int actual = arraz.makeMeAnArrayListFromArray(arr).get(4);
|
|
420
|
+ //THEN
|
|
421
|
+ Assert.assertEquals(expected, actual);
|
|
422
|
+ }
|
|
423
|
+
|
|
424
|
+ @Test
|
|
425
|
+ public void test2makeMeAnArrayListFromArray() {
|
|
426
|
+ //GIVEN
|
|
427
|
+ int[] arr = {1, 2, 3, 4, 5, 3, 1, 1, 1, 2, 3, 4, 5};
|
|
428
|
+ //WHEN
|
|
429
|
+ int expected = 13;
|
|
430
|
+
|
|
431
|
+ int actual = arraz.makeMeAnArrayListFromArray(arr).size();
|
|
432
|
+ //THEN
|
|
433
|
+ Assert.assertEquals(expected, actual);
|
|
434
|
+ }
|
|
435
|
+
|
|
436
|
+ @Test
|
|
437
|
+ public void test1makeMeAnArrayFromArrayList() {
|
|
438
|
+ //GIVEN
|
|
439
|
+ ArrayList<Integer> arr = new ArrayList<Integer>();
|
|
440
|
+ arr.add(1); arr.add(2); arr.add(3);
|
|
441
|
+ //WHEN
|
|
442
|
+ int expected = 1;
|
|
443
|
+
|
|
444
|
+ int[] actualArr = arraz.makeMeAnArrayFromArrayList(arr);
|
|
445
|
+ int actual = actualArr[0];
|
|
446
|
+ //THEN
|
|
447
|
+ Assert.assertEquals(expected, actual);
|
|
448
|
+ }
|
|
449
|
+
|
|
450
|
+ @Test
|
|
451
|
+ public void test2makeMeAnArrayFromArrayList() {
|
|
452
|
+ //GIVEN
|
|
453
|
+ ArrayList<Integer> arr = new ArrayList<Integer>();
|
|
454
|
+ arr.add(1); arr.add(2); arr.add(3);
|
|
455
|
+ //WHEN
|
|
456
|
+ Class expected = Integer.TYPE;
|
|
457
|
+
|
|
458
|
+ Class actual = arraz.makeMeAnArrayFromArrayList(arr).getClass().getComponentType();
|
|
459
|
+ //THEN
|
|
460
|
+ Assert.assertEquals(expected, actual);
|
|
461
|
+ }
|
|
462
|
+
|
|
463
|
+ @Test
|
|
464
|
+ public void test1check2ArraysForEqual() {
|
|
465
|
+ //GIVEN
|
|
466
|
+ int[] a = {1, 2, 3, 4, 5, 3};
|
|
467
|
+ int[] b = {1, 2, 3, 4, 5, 3};
|
|
468
|
+ //WHEN
|
|
469
|
+ boolean expected = true;
|
|
470
|
+
|
|
471
|
+ boolean actual = arraz.check2ArraysForEqual(a, b);
|
|
472
|
+ //THEN
|
|
473
|
+ Assert.assertEquals(expected, actual);
|
|
474
|
+ }
|
|
475
|
+
|
|
476
|
+ @Test
|
|
477
|
+ public void test2check2ArraysForEqual() {
|
|
478
|
+ int[] a = {1, 2, 3, 4, 5, 3};
|
|
479
|
+ int[] b = {1, 2, 3, 4, 5, 3, 1};
|
|
480
|
+ //WHEN
|
|
481
|
+ boolean expected = false;
|
|
482
|
+
|
|
483
|
+ boolean actual = arraz.check2ArraysForEqual(a, b);
|
|
484
|
+ //THEN
|
|
485
|
+ Assert.assertEquals(expected, actual);
|
|
486
|
+ }
|
|
487
|
+
|
|
488
|
+ @Test
|
|
489
|
+ public void test3check2ArraysForEqual() {
|
|
490
|
+ int[] a = {1, 2, 3, 4, 5, 3};
|
|
491
|
+ int[] b = {1, 2, 2, 4, 5, 3};
|
|
492
|
+ //WHEN
|
|
493
|
+ boolean expected = false;
|
|
494
|
+
|
|
495
|
+ boolean actual = arraz.check2ArraysForEqual(a, b);
|
|
496
|
+ //THEN
|
|
497
|
+ Assert.assertEquals(expected, actual);
|
|
498
|
+ }
|
385
|
499
|
}
|