package com.github.sbouclier.jaads.sort;

import static org.junit.Assert.assertArrayEquals;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;

import org.junit.Test;

/**
 * Bogosort test
 * 
 * @author Stéphane Bouclier
 *
 */
public class BogosortTest {

	@Test
	public void should_sort() {
		List<Integer> list = Arrays.asList(3, 2, 8, 4);
		Bogosort.sort(list);

		assertArrayEquals(new Integer[] { 2, 3, 4, 8 }, list.toArray());
	}

	@Test(expected = UnsupportedOperationException.class)
	public void should_not_instanciate_class() throws Throwable {
		final Constructor<Bogosort> constructor = Bogosort.class.getDeclaredConstructor();
		constructor.setAccessible(true);

		try {
			constructor.newInstance();
		} catch (InvocationTargetException e) {
			throw e.getTargetException();
		}
	}
}

@@ -520,16 +520,186 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void should_sort_empty_list() %7B%0A%09%09List%3CInteger%3E list = Arrays.asList();%0A%09%09Bogosort.sort(list);%0A%0A%09%09assertArrayEquals(new Integer%5B%5D %7B%7D, list.toArray());%0A%09%7D%0A%0A
 %09@Test(e

test empty list