diff options
Diffstat (limited to 'v3po/vpp-translate-utils')
2 files changed, 16 insertions, 10 deletions
diff --git a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java index 77e60877f..d44bf8fd5 100644 --- a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java +++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java @@ -185,4 +185,19 @@ public final class TranslateUtils { } throw new IllegalArgumentException(String.format("0 or 1 was expected but was %d", value)); } + + /** + * Reverses bytes in the byte array + * @param bytes input array + * @return reversed array + */ + public static byte[] reverseBytes(final byte[] bytes) { + final byte[] reversed = new byte[bytes.length]; + int i = 1; + for (byte aByte : bytes) { + reversed[bytes.length - i++] = aByte; + } + + return reversed; + } } diff --git a/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java b/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java index ba3861b99..89e7d9d89 100644 --- a/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java +++ b/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java @@ -1,5 +1,6 @@ package io.fd.honeycomb.v3po.translate.v3po.util; +import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.reverseBytes; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -19,16 +20,6 @@ public class TranslateUtilsTest { assertEquals(ipv4Addr, ipv4AddressNoZone); } - private byte[] reverseBytes(final byte[] bytes) { - final byte[] reversed = new byte[bytes.length]; - int i = 1; - for (byte aByte : bytes) { - reversed[bytes.length - i++] = aByte; - } - - return reversed; - } - @Test public void testToString() { final byte[] expected = "test".getBytes(); |