|
@@ -496,4 +496,131 @@ public class ArrazTest {
|
496
|
496
|
//THEN
|
497
|
497
|
Assert.assertEquals(expected, actual);
|
498
|
498
|
}
|
|
499
|
+
|
|
500
|
+ @Test
|
|
501
|
+ public void test1averageArrayWithoutMaxMin() {
|
|
502
|
+ //GIVEN
|
|
503
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
504
|
+ //WHEN
|
|
505
|
+ double expected = 3;
|
|
506
|
+
|
|
507
|
+ double actual = arraz.averageArrayWithoutMaxMin(arr);
|
|
508
|
+ //THEN
|
|
509
|
+ Assert.assertEquals(expected, actual);
|
|
510
|
+ }
|
|
511
|
+
|
|
512
|
+ @Test
|
|
513
|
+ public void test2averageArrayWithoutMaxMin() {
|
|
514
|
+ //GIVEN
|
|
515
|
+ int[] arr = {1, 4, 3, 4, 5, 5};
|
|
516
|
+ //WHEN
|
|
517
|
+ double expected = 4;
|
|
518
|
+
|
|
519
|
+ double actual = arraz.averageArrayWithoutMaxMin(arr);
|
|
520
|
+ //THEN
|
|
521
|
+ Assert.assertEquals(expected, actual);
|
|
522
|
+ }
|
|
523
|
+
|
|
524
|
+ @Test
|
|
525
|
+ public void test1arrayHas65and77() {
|
|
526
|
+ //GIVEN
|
|
527
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
528
|
+ //WHEN
|
|
529
|
+ boolean expected = false;
|
|
530
|
+
|
|
531
|
+ boolean actual = arraz.arrayHas65and77(arr);
|
|
532
|
+ //THEN
|
|
533
|
+ Assert.assertEquals(expected, actual);
|
|
534
|
+ }
|
|
535
|
+
|
|
536
|
+ @Test
|
|
537
|
+ public void test2arrayHas65and77() {
|
|
538
|
+ //GIVEN
|
|
539
|
+ int[] arr = {1, 2, 3, 65, 5};
|
|
540
|
+ //WHEN
|
|
541
|
+ boolean expected = false;
|
|
542
|
+
|
|
543
|
+ boolean actual = arraz.arrayHas65and77(arr);
|
|
544
|
+ //THEN
|
|
545
|
+ Assert.assertEquals(expected, actual);
|
|
546
|
+ }
|
|
547
|
+
|
|
548
|
+ @Test
|
|
549
|
+ public void test3arrayHas65and77() {
|
|
550
|
+ //GIVEN
|
|
551
|
+ int[] arr = {1, 2, 3, 77, 5};
|
|
552
|
+ //WHEN
|
|
553
|
+ boolean expected = false;
|
|
554
|
+
|
|
555
|
+ boolean actual = arraz.arrayHas65and77(arr);
|
|
556
|
+ //THEN
|
|
557
|
+ Assert.assertEquals(expected, actual);
|
|
558
|
+ }
|
|
559
|
+ @Test
|
|
560
|
+ public void test4arrayHas65and77() {
|
|
561
|
+ //GIVEN
|
|
562
|
+ int[] arr = {1, 2, 3, 77, 65};
|
|
563
|
+ //WHEN
|
|
564
|
+ boolean expected = true;
|
|
565
|
+
|
|
566
|
+ boolean actual = arraz.arrayHas65and77(arr);
|
|
567
|
+ //THEN
|
|
568
|
+ Assert.assertEquals(expected, actual);
|
|
569
|
+ }
|
|
570
|
+
|
|
571
|
+ @Test
|
|
572
|
+ public void testTheTotalofTensIs30(){
|
|
573
|
+ //GIVEN
|
|
574
|
+ int[] arr = {10, 2, 10, 77, 10};
|
|
575
|
+ //WHEN
|
|
576
|
+ boolean expected = true;
|
|
577
|
+
|
|
578
|
+ boolean actual = arraz.theTotalofTensIs30(arr);
|
|
579
|
+ //THEN
|
|
580
|
+ Assert.assertEquals(expected, actual);
|
|
581
|
+ }
|
|
582
|
+
|
|
583
|
+ @Test
|
|
584
|
+ public void test2TheTotalofTensIs30(){
|
|
585
|
+ //GIVEN
|
|
586
|
+ int[] arr = {10, 2, 0, 77, 10};
|
|
587
|
+ //WHEN
|
|
588
|
+ boolean expected = false;
|
|
589
|
+
|
|
590
|
+ boolean actual = arraz.theTotalofTensIs30(arr);
|
|
591
|
+ //THEN
|
|
592
|
+ Assert.assertEquals(expected, actual);
|
|
593
|
+ }
|
|
594
|
+
|
|
595
|
+ @Test
|
|
596
|
+ public void test1FindSmallestAnd2ndSmallest() {
|
|
597
|
+ //GIVEN
|
|
598
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
599
|
+ //WHEN
|
|
600
|
+ int expectedSmallest = 1;
|
|
601
|
+ int expected2ndSmallest = 2;
|
|
602
|
+
|
|
603
|
+ int[] retArr = arraz.findSmallestAnd2ndSmallest(arr);
|
|
604
|
+ int actualSmallest = retArr[0];
|
|
605
|
+ int actual2ndSmallest = retArr[1];
|
|
606
|
+ //THEN
|
|
607
|
+ Assert.assertEquals(expectedSmallest, actualSmallest);
|
|
608
|
+ Assert.assertEquals(expected2ndSmallest, actual2ndSmallest);
|
|
609
|
+ }
|
|
610
|
+
|
|
611
|
+ @Test
|
|
612
|
+ public void test2FindSmallestAnd2ndSmallest() {
|
|
613
|
+ //GIVEN
|
|
614
|
+ int[] arr = {1, 2, 3, 4, 5, -3, -1000, 13, 13, 44444};
|
|
615
|
+ //WHEN
|
|
616
|
+ int expectedSmallest = -1000;
|
|
617
|
+ int expected2ndSmallest = -3;
|
|
618
|
+
|
|
619
|
+ int[] retArr = arraz.findSmallestAnd2ndSmallest(arr);
|
|
620
|
+ int actualSmallest = retArr[0];
|
|
621
|
+ int actual2ndSmallest = retArr[1];
|
|
622
|
+ //THEN
|
|
623
|
+ Assert.assertEquals(expectedSmallest, actualSmallest);
|
|
624
|
+ Assert.assertEquals(expected2ndSmallest, actual2ndSmallest);
|
|
625
|
+ }
|
499
|
626
|
}
|