private Object[] things;
- private final Object[] sortedThings = new Object[]
- { c4, c2, c1, c3 };
+ private final Object[] sortedThings = new Object[] { c4, c2, c1, c3 };
- @BeforeMethod(alwaysRun = true)
+ @BeforeMethod(alwaysRun = true)
public void setUp()
{
- things = new Object[]
- { c1, c2, c3, c4 };
+ things = new Object[] { c1, c2, c3, c4 };
}
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testSort_byIntValues()
{
- int[] values = new int[]
- { 3, 2, 4, 1 };
+ 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(new int[] { 1, 2, 3, 4 }, values));
assertTrue(Arrays.equals(sortedThings, things));
}
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testSort_byFloatValues()
{
- float[] values = new float[]
- { 3f, 2f, 4f, 1f };
+ 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(new float[] { 1f, 2f, 3f, 4f }, values));
assertTrue(Arrays.equals(sortedThings, things));
}
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testSort_byDoubleValues()
{
- double[] values = new double[]
- { 3d, 2d, 4d, 1d };
+ 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(new double[] { 1d, 2d, 3d, 4d }, values));
assertTrue(Arrays.equals(sortedThings, things));
}
/**
* Sort by String is descending order, case-sensitive
*/
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testSort_byStringValues()
{
- String[] values = new String[]
- { "JOHN", "henry", "lucy", "ALISON" };
+ 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));
+ assertTrue(Arrays.equals(new String[] { "lucy", "henry", "JOHN",
+ "ALISON" }, values));
+ assertTrue(Arrays.equals(new Object[] { c3, c2, c1, c4 }, things));
}
/**
* Test whether sort is stable i.e. equal values retain their mutual ordering.
*/
- @Test(groups =
- { "Functional" }, enabled = false)
+ @Test(groups = { "Functional" }, enabled = false)
public void testSort_withDuplicates()
{
- int[] values = new int[]
- { 3, 4, 2, 4, 1 };
- Object [] things = new Object [] {"A", "X", "Y", "B", "Z"};
+ int[] values = new int[] { 3, 4, 2, 4, 1 };
+ Object[] things = new Object[] { "A", "X", "Y", "B", "Z" };
QuickSort.sort(values, things);
- assertTrue(Arrays.equals(new int[]
- { 1, 2, 3, 4, 4 }, values));
+ assertTrue(Arrays.equals(new int[] { 1, 2, 3, 4, 4 }, values));
// this fails - do we care?
- assertTrue(Arrays.equals(new Object[]
- { "Z", "Y", "A", "X", "B" }, things));
+ assertTrue(Arrays.equals(new Object[] { "Z", "Y", "A", "X", "B" },
+ things));
}
/**
* Test that exercises sort with a mostly zero-valued sortby array. May be of
* interest to check the sort algorithm is efficient.
*/
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testSort_MostlyZeroValues()
{
char[] residues = new char[64];