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