Package com.fasterxml.sort.std

Examples of com.fasterxml.sort.std.ByteArrayComparator


public class TestByteArrayComparator
    extends SortTestBase
{
    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 }));

        // 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


    public void testLargeSort() throws IOException {
        Sorter<byte[]> sorter = new Sorter<byte[]>(
            new SortConfig().withMaxMemoryUsage(SORT_MEM_BYTES),
            RawTextLineReader.factory(),
            RawTextLineWriter.factory(),
            new ByteArrayComparator()
        );
        CountingWriter<byte[]> counter = new CountingWriter<byte[]>();
        sorter.sort(new StringGenerator(STRING_COUNT, STRING_LENGTH), counter);
        assertEquals("sorted count", STRING_COUNT, counter.getCount());
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.sort.std.ByteArrayComparator

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.