public class IntArrayComparatorTest
{
@Test
public void testIntArrayComparator()
{
IntArrayComparator comparator = new IntArrayComparator();
// Check equality
assertEquals( 0, comparator.compare( null, null ) );
assertEquals( 0, comparator.compare( new int[]
{}, new int[]
{} ) );
assertEquals( 0, comparator.compare( new int[]
{ 1, 2 }, new int[]
{ 1, 2 } ) );
// The first int[] is > the second
assertEquals( 1, comparator.compare( new int[]
{}, null ) );
assertEquals( 1, comparator.compare( new int[]
{ 1 }, null ) );
assertEquals( 1, comparator.compare( new int[]
{ 1, 2 }, new int[]
{ 1, 1 } ) );
assertEquals( 1, comparator.compare( new int[]
{ 1, 2, 1 }, new int[]
{ 1, 2 } ) );
assertEquals( 1, comparator.compare( new int[]
{ 1, 2 }, new int[]
{ 1, 1, 2 } ) );
// The first int[] is < the second
assertEquals( -1, comparator.compare( null, new int[]
{} ) );
assertEquals( -1, comparator.compare( null, new int[]
{ 1, 2 } ) );
assertEquals( -1, comparator.compare( null, new int[]
{ -1, 2 } ) );
assertEquals( -1, comparator.compare( new int[]
{}, new int[]
{ 1, 2 } ) );
assertEquals( -1, comparator.compare( new int[]
{}, new int[]
{ -1, 2 } ) );
assertEquals( -1, comparator.compare( new int[]
{ -1, 1 }, new int[]
{ 1, 1, 2 } ) );
int[] array = new int[3];
array[0] = 1;
array[1] = 2;
assertEquals( -1, comparator.compare( new int[]
{ 1, 2 }, array ) );
}