@Test public void shouldUseSizeWhenComparing() { byte[] shorterContent = new byte[validByteArrayContent.length - 2]; for (int i = 0; i != shorterContent.length; ++i) { shorterContent[i] = validByteArrayContent[i]; } Binary another = new InMemoryBinary(shorterContent); assertThat(binary.equals(another), is(false)); assertThat(binary.compareTo(another), is(1)); assertThat(another.compareTo(binary), is(-1)); assertThat(another, hasContent(shorterContent)); }