+/EE422C
software design
git clone https://git.julia.blue/+/EE422C
ead272f
master
1/* 2* Joseph Ryan 3* jbr2558 4* 16200 5* Fall 2018 6*/ 7 8package assignment1 ; 9 10import static org .junit .Assert .assertArrayEquals ; 11import static org .junit .Assert .assertEquals ; 12import static org .junit .Assert .assertFalse ; 13 14import org .junit .Test ; 15 16public class SampleTest { 17@ Test (timeout =2000 ) 18public void testIsSorted () { 19int []x =new int []{-2 , -2 ,0 ,0 ,2 ,1 }; 20assert (SortTools .isSorted (x ,0 )); 21assert (SortTools .isSorted (x ,1 )); 22assert (SortTools .isSorted (x ,2 )); 23assert (SortTools .isSorted (x ,5 )); 24assertFalse (SortTools .isSorted (x ,6 )); 25 } 26 27@ Test (timeout =2000 ) 28public void testFind () { 29int []x =new int []{-2 , -1 ,0 ,1 ,2 ,3 }; 30assertEquals (3 ,SortTools .find (x ,6 ,1 )); 31assertEquals (-1 ,SortTools .find (x ,6 ,5 )); 32assertEquals (0 ,SortTools .find (x ,1 , -2 )); 33assertEquals (1 ,SortTools .find (x ,2 , -1 )); 34 } 35 36@ Test (timeout =2000 ) 37public void testInsertGeneral () { 38int []x =new int []{10 ,20 ,30 ,40 ,50 }; 39int []expected =new int []{10 ,20 ,30 ,35 }; 40assertArrayEquals (expected ,SortTools .insertGeneral (x ,3 ,35 )); 41expected =new int []{1 ,10 }; 42assertArrayEquals (expected ,SortTools .insertGeneral (x ,1 ,1 )); 43expected =new int []{10 ,11 }; 44assertArrayEquals (expected ,SortTools .insertGeneral (x ,1 ,11 )); 45expected =new int []{1 ,10 ,20 ,30 ,40 ,50 }; 46assertArrayEquals (expected ,SortTools .insertGeneral (x ,5 ,1 )); 47expected =new int []{10 ,20 ,30 ,40 ,50 ,1000 }; 48assertArrayEquals (expected ,SortTools .insertGeneral (x ,5 ,1000 )); 49 } 50 51@ Test (timeout =2000 ) 52public void testInsertInPlace () { 53int []x =new int []{1 ,2 ,1000 }; 54int []expected =new int []{1 ,2 ,3 }; 55assertEquals (3 ,SortTools .insertInPlace (x ,2 ,3 )); 56assertArrayEquals (expected ,x ); 57 } 58 59@ Test (timeout =2000 ) 60public void testSort () { 61int []x =new int []{6 ,1 ,2 ,8 ,9 ,3 ,0 ,5 ,4 ,7 }; 62int []y =new int []{0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 }; 63SortTools .insertSort (x ,x .length ); 64assertArrayEquals (y ,x ); 65 } 66}