@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 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); }