@Test
public void testReadNullTerminatedString() {

  byte[] bytes = new byte[] {
      'f', 'o', 'o', 0, 'b', 'a', 'r', 0
  };
  // Test normal case.
  ParsableByteArray parser = new ParsableByteArray(bytes);
  assertThat(parser.readNullTerminatedString()).isEqualTo("foo");
  assertThat(parser.getPosition()).isEqualTo(4);
  assertThat(parser.readNullTerminatedString()).isEqualTo("bar");
  assertThat(parser.getPosition()).isEqualTo(8);
  assertThat(parser.readNullTerminatedString()).isNull();
  // Test with limit at NUL.
  parser = new ParsableByteArray(bytes, 4);
  assertThat(parser.readNullTerminatedString()).isEqualTo("foo");
  assertThat(parser.getPosition()).isEqualTo(4);
  assertThat(parser.readNullTerminatedString()).isNull();
  // Test with limit before NUL.
  parser = new ParsableByteArray(bytes, 3);
  assertThat(parser.readNullTerminatedString()).isEqualTo("foo");
  assertThat(parser.getPosition()).isEqualTo(3);
  assertThat(parser.readNullTerminatedString()).isNull();
}