@Test
public void shouldEncodeCorrectly() throws IOException, NullPointerException {

arset charset = Charset.availableCharsets().get(BoundString.Encoding.ASCII);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    BitChannel channel = new OutputStreamBitChannel(out);
    when(sizeExpr.eval(Matchers.any(Resolver.class))).thenReturn(4);
    FixedLengthStringCodec codec =
            new FixedLengthStringCodec(charset, sizeExpr, null, new BoundString.NullConverter());
    codec.encode("Whatever", channel, resolver);
    out.flush();
    byte[] result = out.toByteArray();
    assertThat(result.length, is(4));
    assertThat(new String(result, "US-ASCII"), is("What"));
}