--- /dev/null
+package jalview.util;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class QuickSortTest
+{
+ private static final String c1 = "Blue";
+
+ private static final String c2 = "Yellow";
+
+ private static final String c3 = "Orange";
+
+ private static final String c4 = "Green";
+
+ private Object[] things;
+
+ private final Object[] sortedThings = new Object[]
+ { c4, c2, c1, c3 };
+
+ @Before
+ public void setUp()
+ {
+ things = new Object[]
+ { c1, c2, c3, c4 };
+ }
+
+ @Test
+ public void testSort_byIntValues()
+ {
+ int[] values = new int[]
+ { 3, 2, 4, 1 };
+ QuickSort.sort(values, things);
+ assertTrue(Arrays.equals(new int[]
+ { 1, 2, 3, 4 }, values));
+ assertTrue(Arrays.equals(sortedThings, things));
+ }
+
+ @Test
+ public void testSort_byFloatValues()
+ {
+ float[] values = new float[]
+ { 3f, 2f, 4f, 1f };
+ QuickSort.sort(values, things);
+ assertTrue(Arrays.equals(new float[]
+ { 1f, 2f, 3f, 4f }, values));
+ assertTrue(Arrays.equals(sortedThings, things));
+ }
+
+ @Test
+ public void testSort_byDoubleValues()
+ {
+ double[] values = new double[]
+ { 3d, 2d, 4d, 1d };
+ QuickSort.sort(values, things);
+ assertTrue(Arrays.equals(new double[]
+ { 1d, 2d, 3d, 4d }, values));
+ assertTrue(Arrays.equals(sortedThings, things));
+ }
+
+ /**
+ * Sort by String is descending order, case-sensitive
+ */
+ @Test
+ public void testSort_byStringValues()
+ {
+ String[] values = new String[]
+ { "JOHN", "henry", "lucy", "ALISON" };
+ QuickSort.sort(values, things);
+ assertTrue(Arrays.equals(new String[]
+ { "lucy", "henry", "JOHN", "ALISON" }, values));
+ assertTrue(Arrays.equals(new Object[]
+ { c3, c2, c1, c4 }, things));
+ }
+}