@Test
  public void testTail1() {

    final RingBuffer<Integer> ring = new RingBufferSimple<Integer>(1);
    assertEquals(ring.length(), 1);

    ring.setTail(100, 100);
    assertEquals(ring.tail(), 100);
    assertEquals(ring.get(100), (Integer) 100);

    ring.setTail(123, 100);
    assertEquals(ring.tail(), 123);
    assertEquals(ring.get(123), (Integer) 100);
  }
  @Test
  public void testHead() {

    final RingBuffer<Integer> ring = new RingBufferSimple<Integer>(10);
    assertEquals(ring.length(), 10);

    ring.setHead(100, 100);
    assertEquals(ring.count(), 1);
    assertEquals(ring.get(100), (Integer) 100);

    for (int k = 101; k < 110; k++) {
      assertEquals(ring.get(k), null);
    }

    for (int k = 100; k < 110; k++) {
      ring.set(k, k);
    }

    assertEquals(ring.count(), 10);

    for (int k = 100; k < 110; k++) {
      assertEquals(ring.get(k), (Integer) k);
    }

    ring.setHead(105, 205);

    assertEquals(ring.count(), 5);
    assertEquals(ring.head(), 105);
    assertEquals(ring.tail(), 114);

    assertEquals(ring.get(105), (Integer) 205);

    for (int k = 106; k < 110; k++) {
      assertEquals(ring.get(k), (Integer) k);
    }

    for (int k = 110; k < 115; k++) {
      assertEquals(ring.get(k), (Integer) null);
    }

    ring.set(114, 114);

    assertEquals(ring.count(), 6);
    assertEquals(ring.get(114), (Integer) 114);
  }
  @Test
  public void testRingArray1() {

    final RingBuffer<Integer> ring = new RingBufferSimple<Integer>(10);

    int ringMemSize;
    ringMemSize = JavaSize.of(ring);
    // System.err.println("ring mem size=" + ringMemSize);
    assertEquals(ringMemSize, 72);

    //

    int basis;

    for (int k = 0; k < 10; k++) {
      ring.set(k, new Integer(k));
    }

    basis = ring.head();
    // System.err.println("ring basis=" + basis);
    assertEquals(basis, 0);

    //

    for (int k = 0; k < 10; k++) {
      assertEquals(ring.get(k), (Integer) k);
    }

    //

    assertEquals(ring.head(), 0);
    assertEquals(ring.tail(), 9);
    assertEquals(ring.get(4), (Integer) 4);

    for (int k = 5; k < 10; k++) {
      // System.err.println("ring k=" + k);
      assertEquals(ring.get(k), (Integer) (k));
    }

    //

  }
  @Test
  public void testyTail() {

    final RingBuffer<Integer> ring = new RingBufferSimple<Integer>(10);
    assertEquals(ring.length(), 10);

    ring.setTail(109, 109);
    assertEquals(ring.count(), 1);
    assertEquals(ring.get(109), (Integer) 109);

    for (int k = 100; k < 109; k++) {
      assertEquals(ring.get(k), null);
    }

    for (int k = 100; k < 110; k++) {
      ring.set(k, k);
    }

    assertEquals(ring.count(), 10);

    for (int k = 100; k < 110; k++) {
      assertEquals(ring.get(k), (Integer) k);
    }

    ring.setTail(104, 204);
    assertEquals(ring.count(), 5);
    assertEquals(ring.head(), 95);
    assertEquals(ring.tail(), 104);
    assertEquals(ring.get(104), (Integer) 204);

    for (int k = 100; k < 104; k++) {
      assertEquals(ring.get(k), (Integer) k);
    }

    for (int k = 95; k < 100; k++) {
      assertEquals(ring.get(k), (Integer) null);
    }

    ring.set(95, 95);
    assertEquals(ring.get(95), (Integer) 95);
    assertEquals(ring.count(), 6);
  }