diff options
Diffstat (limited to 'container-search/src/test/java/com/yahoo/fs4/test/HexByteIteratorTestCase.java')
-rw-r--r-- | container-search/src/test/java/com/yahoo/fs4/test/HexByteIteratorTestCase.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/container-search/src/test/java/com/yahoo/fs4/test/HexByteIteratorTestCase.java b/container-search/src/test/java/com/yahoo/fs4/test/HexByteIteratorTestCase.java new file mode 100644 index 00000000000..7675acc88fc --- /dev/null +++ b/container-search/src/test/java/com/yahoo/fs4/test/HexByteIteratorTestCase.java @@ -0,0 +1,37 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.fs4.test; + +import java.nio.ByteBuffer; + +import junit.framework.TestCase; + +import com.yahoo.fs4.HexByteIterator; + +/** + * Test of HexByteIterator + * @author tonytv + */ +public class HexByteIteratorTestCase extends TestCase { + public void testHexByteIterator() { + int[] numbers = { 0x00, 0x01, 0xDE, 0xAD, 0xBE, 0xEF, 0xFF }; + + HexByteIterator i = new HexByteIterator( + ByteBuffer.wrap(toBytes(numbers))); + + assertEquals("00", i.next()); + assertEquals("01", i.next()); + assertEquals("DE", i.next()); + assertEquals("AD", i.next()); + assertEquals("BE", i.next()); + assertEquals("EF", i.next()); + assertEquals("FF", i.next()); + assertTrue(!i.hasNext()); + } + + private byte[] toBytes(int[] ints) { + byte[] bytes = new byte[ints.length]; + for (int i=0; i<bytes.length; ++i) + bytes[i] = (byte)ints[i]; + return bytes; + } +} |