|
@@ -668,4 +668,104 @@ public class ArrazTest {
|
668
|
668
|
//THEN
|
669
|
669
|
Assert.assertEquals(arr[2], actual[actual.length - 1]);
|
670
|
670
|
}
|
|
671
|
+
|
|
672
|
+ @Test
|
|
673
|
+ public void test1removeFirstItemAndCopy(){
|
|
674
|
+ //GIVEN
|
|
675
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
676
|
+ //WHEN
|
|
677
|
+ int[] retArr = arraz.removeFirstItemAndCopy(arr);
|
|
678
|
+ int expected = 4;
|
|
679
|
+ int actual = retArr.length;
|
|
680
|
+ //THEN
|
|
681
|
+ Assert.assertEquals(expected, actual);
|
|
682
|
+ }
|
|
683
|
+
|
|
684
|
+ @Test
|
|
685
|
+ public void test2removeFirstItemAndCopy(){
|
|
686
|
+ //GIVEN
|
|
687
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
688
|
+ //WHEN
|
|
689
|
+ int[] retArr = arraz.removeFirstItemAndCopy(arr);
|
|
690
|
+ int expected = 2;
|
|
691
|
+ int actual = retArr[0];
|
|
692
|
+ //THEN
|
|
693
|
+ Assert.assertEquals(expected, actual);
|
|
694
|
+ }
|
|
695
|
+
|
|
696
|
+ @Test
|
|
697
|
+ public void test1insertAtStartAndCopy(){
|
|
698
|
+ //GIVEN
|
|
699
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
700
|
+ int insert = 777;
|
|
701
|
+ //WHEN
|
|
702
|
+ int[] retArr = arraz.insertAtStartAndCopy(arr, insert);
|
|
703
|
+ int expected = 6;
|
|
704
|
+ int actual = retArr.length;
|
|
705
|
+ //THEN
|
|
706
|
+ Assert.assertEquals(expected, actual);
|
|
707
|
+ }
|
|
708
|
+
|
|
709
|
+ @Test
|
|
710
|
+ public void test2insertAtStartAndCopy(){
|
|
711
|
+ //GIVEN
|
|
712
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
713
|
+ int insert = 777;
|
|
714
|
+ //WHEN
|
|
715
|
+ int[] retArr = arraz.insertAtStartAndCopy(arr, insert);
|
|
716
|
+ int expected = 777;
|
|
717
|
+ int actual = retArr[0];
|
|
718
|
+ //THEN
|
|
719
|
+ Assert.assertEquals(expected, actual);
|
|
720
|
+ }
|
|
721
|
+
|
|
722
|
+ @Test
|
|
723
|
+ public void test1insertAtEndAndCopy(){
|
|
724
|
+ //GIVEN
|
|
725
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
726
|
+ int insert = 777;
|
|
727
|
+ //WHEN
|
|
728
|
+ int[] retArr = arraz.insertAtEndAndCopy(arr, insert);
|
|
729
|
+ int expected = 777;
|
|
730
|
+ int actual = retArr[retArr.length - 1];
|
|
731
|
+ //THEN
|
|
732
|
+ Assert.assertEquals(expected, actual);
|
|
733
|
+ }
|
|
734
|
+
|
|
735
|
+ @Test
|
|
736
|
+ public void test2insertAtEndAndCopy(){
|
|
737
|
+ //GIVEN
|
|
738
|
+ int[] arr = {1, 2, 3, 4, 5};
|
|
739
|
+ int insert = 777;
|
|
740
|
+ //WHEN
|
|
741
|
+ int[] retArr = arraz.insertAtEndAndCopy(arr, insert);
|
|
742
|
+ int expected = 6;
|
|
743
|
+ int actual = retArr.length;
|
|
744
|
+ //THEN
|
|
745
|
+ Assert.assertEquals(expected, actual);
|
|
746
|
+ }
|
|
747
|
+ // sortArrayIntoEvensThenOdds
|
|
748
|
+ @Test
|
|
749
|
+ public void test1sortArrayIntoEvensThenOdds(){
|
|
750
|
+ //GIVEN
|
|
751
|
+ int[] arr = {4,5,102,6,-7,12,-32,92,8};
|
|
752
|
+ //WHEN
|
|
753
|
+ int[] retArr = arraz.sortArrayIntoEvensThenOdds(arr);
|
|
754
|
+ int expected = 4;
|
|
755
|
+ int actual = retArr[0];
|
|
756
|
+ //THEN
|
|
757
|
+ Assert.assertEquals(expected, actual);
|
|
758
|
+ }
|
|
759
|
+
|
|
760
|
+ @Test
|
|
761
|
+ public void test2sortArrayIntoEvensThenOdds(){
|
|
762
|
+ //GIVEN
|
|
763
|
+ int[] arr = {4,5,102,6,-7,12,-32,92,8};
|
|
764
|
+ //WHEN
|
|
765
|
+ int[] retArr = arraz.sortArrayIntoEvensThenOdds(arr);
|
|
766
|
+ int expected = -7;
|
|
767
|
+ int actual = retArr[retArr.length - 1];
|
|
768
|
+ //THEN
|
|
769
|
+ Assert.assertEquals(expected, actual);
|
|
770
|
+ }
|
671
|
771
|
}
|