public BufferAssert hasCapacity(int expectedCapacity) { isNotNull(); if (expectedCapacity != actual.capacity()) { failWithMessage("Expected capacity " + expectedCapacity + " but was " + actual.capacity()); } return this; }
public BufferAssert hasCapacity(int expectedCapacity) { isNotNull(); if (expectedCapacity != actual.capacity()) { failWithMessage("Expected capacity " + expectedCapacity + " but was " + actual.capacity()); } return this; }
public BufferAssert hasBytes(byte[] expected, int position) { isNotNull(); final byte[] actualBytes = new byte[expected.length]; try { actual.getBytes(position, actualBytes, 0, actualBytes.length); } catch (final Exception e) { e.printStackTrace(); failWithMessage( "Unable to read %d bytes from actual: %s", actualBytes.length, e.getMessage()); } if (!Arrays.equals(expected, actualBytes)) { failWithMessage( "Expected byte array match bytes <%s> but was <%s>", bytesAsHexString(expected, NO_WRAP), bytesAsHexString(actualBytes, NO_WRAP)); } return this; }
public BufferAssert hasBytes(byte[] expected, int position) { isNotNull(); final byte[] actualBytes = new byte[expected.length]; try { actual.getBytes(position, actualBytes, 0, actualBytes.length); } catch (final Exception e) { e.printStackTrace(); failWithMessage( "Unable to read %d bytes from actual: %s", actualBytes.length, e.getMessage()); } if (!Arrays.equals(expected, actualBytes)) { failWithMessage( "Expected byte array match bytes <%s> but was <%s>", bytesAsHexString(expected, NO_WRAP), bytesAsHexString(actualBytes, NO_WRAP)); } return this; }