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

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


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

TOP

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

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.