@Test
 public void addAndRemove() {
   cb.add((byte) 'A');
   cb.add((byte) 'B');
   cb.add((byte) 'C');
   assertEquals(3, cb.length());
   assertTrue(cb.remove() == (byte) 'A');
   assertTrue(cb.remove() == (byte) 'B');
   assertTrue(cb.remove() == (byte) 'C');
   String s = "DEFGHIJKLMNOPQRS";
   cb.add(s.getBytes(), 0, s.length());
   assertEquals(cb.length(), s.length());
   byte[] b = new byte[s.length()];
   int got = cb.remove(b, 0, b.length);
   assertEquals(got, s.length());
   assertEquals(new String(b), s);
   s = "TUVWXYZABCDEFGHIJKLMNOPQRS";
   cb.add(s.getBytes(), 0, s.length());
   assertEquals(cb.length(), s.length());
   b = new byte[s.length()];
   got = cb.remove(b, 0, b.length);
   assertEquals(got, s.length());
   assertEquals(new String(b), s);
 }
  @Test
  public void bigChunks() {
    String s16 = "ABCDEFGHIJKLMNOP";
    cb.add(s16.getBytes());
    assertEquals(s16.length(), cb.length());
    byte[] buff = new byte[cb.length()];
    int got = cb.remove(buff);
    assertEquals(s16.length(), got);
    assertTrue(Arrays.equals(s16.getBytes(), buff));

    cb.add((byte) 'Z');
    cb.add((byte) 'Z');
    cb.add((byte) 'Z');
    assertEquals((byte) 'Z', (byte) cb.remove());
    assertEquals((byte) 'Z', (byte) cb.remove());
    assertEquals((byte) 'Z', (byte) cb.remove());

    cb.add(s16.getBytes());
    assertEquals(s16.length(), cb.length());
    buff = new byte[cb.length()];
    got = cb.remove(buff);
    assertEquals(s16.length(), got);
    assertTrue(Arrays.equals(s16.getBytes(), buff));
  }
  @Test
  public void pushAndRemove() {
    cb.push((byte) 'C');
    cb.push((byte) 'B');
    cb.push((byte) 'A');

    cb.add((byte) 'D');
    cb.add((byte) 'E');

    assertEquals(5, cb.length());

    assertTrue(cb.remove() == (byte) 'A');
    assertTrue(cb.remove() == (byte) 'B');
    assertTrue(cb.remove() == (byte) 'C');
    assertTrue(cb.remove() == (byte) 'D');
    assertTrue(cb.remove() == (byte) 'E');

    assertEquals(0, cb.length());

    cb.push(AsciiString.getBytes("WXYZ"));
    cb.push(AsciiString.getBytes("JKLMNOPQRSTUV"));
    cb.push(AsciiString.getBytes("ABCDEFGHI"));
    byte[] buff = new byte[30];
    assertEquals(26, cb.remove(buff));
    assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", new String(buff, 0, 26));
  }