Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- */
- package server;
- import static org.junit.Assert.*;
- import java.rmi.RemoteException;
- import java.util.Arrays;
- import java.util.Random;
- import org.junit.Before;
- import org.junit.Test;
- /**
- * @author Samuel van Oostveen
- *
- */
- @SuppressWarnings("rawtypes")
- public class BubbleSortTest {
- ISorter sorter;
- Comparable[] testArray;
- Comparable[] testArray2;
- @Before
- public void setUp() throws RemoteException
- {
- sorter = new BubbleSort();
- testArray = new Comparable[10000];
- Random random = new Random();
- for(int count = 0; count < testArray.length; count++) {
- testArray[count] = random.nextInt(100000)-500000;
- }
- testArray2 = testArray.clone();
- Arrays.sort(testArray2);
- }
- /**
- * Test method for {@link server.BubbleSort#sort(java.lang.Comparable[])}.
- * @throws RemoteException
- */
- @Test
- public void testRandomInteger() throws RemoteException {
- assertArrayEquals(testArray2, sorter.sort( testArray));
- }
- @Test
- public void testIntegerArray() throws RemoteException {
- assertArrayEquals(new Comparable[]{2,3,6,230}, sorter.sort( new Comparable[]{2,3,6,230}));
- assertArrayEquals(new Comparable[]{2,3,6}, sorter.sort( new Comparable[]{6,3,2}));
- }
- @Test
- public void testStringArray() throws RemoteException {
- assertArrayEquals(new Comparable[]{"hallo","test","w"}, sorter.sort( new Comparable[]{"hallo", "test", "w"}));
- assertArrayEquals(new Comparable[]{"hallo", "test", "w"}, sorter.sort( new Comparable[]{"test","hallo","w"}));
- }
- @Test
- public void testEmptyArray() throws RemoteException {
- assertArrayEquals(new Comparable[]{}, sorter.sort( new Comparable[]{}) );
- }
- }
Add Comment
Please, Sign In to add comment