CommonChunk implements Chunk { public byte[] getDescription() { if (description.isPresent()) { final byte[] bytes = new byte[description.get().size()]; for (int i = 0; i < description.get().size(); i++) { bytes[i] = description.get().get(i); } return bytes; } return null; } private  CommonChunk(); private  CommonChunk(CommonChunk chunk); @Override int getPhysicalSize(); @Override ID getChunkID(); @Override SignedLong getChunkSize(); SignedShort getNumChannels(); UnsignedLong getNumSampleFrames(); SignedShort getSampleSize(); Extended getSampleRate(); ID getCodec(); byte[] getDescription(); @Override boolean equals(Object o); @Override int hashCode(); static CommonChunk readCommonChunk(IffReader reader); @Override String toString();  }
@Test public void extraPadByteIsAddedWhenDescriptionHasOddLength() throws Exception { final CommonChunk.Builder builder = new CommonChunk.Builder() .withChunkSize(SignedLong.fromInt(29)) .withNumChannels(SignedShort.fromShort((short) 1)) .withNumSampleFrames(UnsignedLong.fromLong(1024)) .withSampleSize(SignedShort.fromShort((short) 16)) .withSampleRate(Op1Constants.SAMPLE_RATE_44100) .withCodec(ID.valueOf("BLAH")) .withDescription("1234567".getBytes()); final CommonChunk commonChunk = builder.build(); assertThat(commonChunk.getDescription().length, equalTo(8)); }
@Test public void noExtraPadByteIsAddedWhenDescriptionHasEvenLength() throws Exception { final CommonChunk.Builder builder = new CommonChunk.Builder() .withChunkSize(SignedLong.fromInt(30)) .withNumChannels(SignedShort.fromShort((short) 1)) .withNumSampleFrames(UnsignedLong.fromLong(1024)) .withSampleSize(SignedShort.fromShort((short) 16)) .withSampleRate(Op1Constants.SAMPLE_RATE_44100) .withCodec(ID.valueOf("BLAH")) .withDescription("12345678".getBytes()); final CommonChunk commonChunk = builder.build(); assertThat(commonChunk.getDescription().length, equalTo(8)); }