Package org.apache.directory.mavibot.btree.comparator

Examples of org.apache.directory.mavibot.btree.comparator.ShortArrayComparator


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 ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.mavibot.btree.comparator.ShortArrayComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.