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