Package com.fasterxml.sort.std

Examples of com.fasterxml.sort.std.ByteArrayComparator.compare()


{
    public void testSimple()
    {
        ByteArrayComparator cmp = new ByteArrayComparator();
        // simple equality
        assertEquals(0, cmp.compare(new byte[] { }, new byte[] { }));
        assertEquals(0, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2 }));

        // longer vs shorter
        assertEquals(-1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2, 3}));
        assertEquals(1, cmp.compare(new byte[] { 1, 2, 3 }, new byte[] { 1, 2 }));
View Full Code Here


    public void testSimple()
    {
        ByteArrayComparator cmp = new ByteArrayComparator();
        // simple equality
        assertEquals(0, cmp.compare(new byte[] { }, new byte[] { }));
        assertEquals(0, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2 }));

        // longer vs shorter
        assertEquals(-1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2, 3}));
        assertEquals(1, cmp.compare(new byte[] { 1, 2, 3 }, new byte[] { 1, 2 }));
View Full Code Here

        // simple equality
        assertEquals(0, cmp.compare(new byte[] { }, new byte[] { }));
        assertEquals(0, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2 }));

        // longer vs shorter
        assertEquals(-1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2, 3}));
        assertEquals(1, cmp.compare(new byte[] { 1, 2, 3 }, new byte[] { 1, 2 }));

        // then comparisons with normal signed values
        assertEquals(1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 1 }));
        assertEquals(-1, cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, 2 }));
View Full Code Here

        assertEquals(0, cmp.compare(new byte[] { }, new byte[] { }));
        assertEquals(0, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2 }));

        // longer vs shorter
        assertEquals(-1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2, 3}));
        assertEquals(1, cmp.compare(new byte[] { 1, 2, 3 }, new byte[] { 1, 2 }));

        // then comparisons with normal signed values
        assertEquals(1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 1 }));
        assertEquals(-1, cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, 2 }));
View Full Code Here

        // longer vs shorter
        assertEquals(-1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2, 3}));
        assertEquals(1, cmp.compare(new byte[] { 1, 2, 3 }, new byte[] { 1, 2 }));

        // then comparisons with normal signed values
        assertEquals(1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 1 }));
        assertEquals(-1, cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, 2 }));

        // and finally ensure that we ignore "signed-ness" of bytes
        assertTrue(cmp.compare(new byte[] { 1, (byte) 0xFF }, new byte[] { 1, 1 }) > 0);
        assertTrue(cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, (byte) 0xFF }) < 0);
View Full Code Here

        assertEquals(-1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 2, 3}));
        assertEquals(1, cmp.compare(new byte[] { 1, 2, 3 }, new byte[] { 1, 2 }));

        // then comparisons with normal signed values
        assertEquals(1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 1 }));
        assertEquals(-1, cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, 2 }));

        // and finally ensure that we ignore "signed-ness" of bytes
        assertTrue(cmp.compare(new byte[] { 1, (byte) 0xFF }, new byte[] { 1, 1 }) > 0);
        assertTrue(cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, (byte) 0xFF }) < 0);
    }
View Full Code Here

        // then comparisons with normal signed values
        assertEquals(1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 1 }));
        assertEquals(-1, cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, 2 }));

        // and finally ensure that we ignore "signed-ness" of bytes
        assertTrue(cmp.compare(new byte[] { 1, (byte) 0xFF }, new byte[] { 1, 1 }) > 0);
        assertTrue(cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, (byte) 0xFF }) < 0);
    }
}
View Full Code Here

        assertEquals(1, cmp.compare(new byte[] { 1, 2 }, new byte[] { 1, 1 }));
        assertEquals(-1, cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, 2 }));

        // and finally ensure that we ignore "signed-ness" of bytes
        assertTrue(cmp.compare(new byte[] { 1, (byte) 0xFF }, new byte[] { 1, 1 }) > 0);
        assertTrue(cmp.compare(new byte[] { 1, 1 }, new byte[] { 1, (byte) 0xFF }) < 0);
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.