### Question:
NaiveSearchRingBuffer { public boolean addAndCompare(final byte data) { buffer[insertionPointer] = data; insertionPointer = (insertionPointer + 1) % lookingFor.length; bufferSize++; if (bufferSize < lookingFor.length) { return false; } for (int i = 0; i < lookingFor.length; i++) { final byte compare = (byte) buffer[(insertionPointer + i) % lookingFor.length]; if (compare != lookingFor[i]) { return false; } } return true; } NaiveSearchRingBuffer(final byte[] lookingFor); byte[] getBufferContents(); int getOldestByte(); boolean isFilled(); void clear(); boolean addAndCompare(final byte data);  }### Answer:
@Test public void testAddAndCompare() { final byte[] pattern = new byte[]{ '\r', '0', 38, 48 }; final byte[] search = new byte[]{ '\r', '0', 38, 58, 58, 83, 78, '\r', '0', 38, 48, 83, 92, 78, 4, 38 }; final NaiveSearchRingBuffer circ = new NaiveSearchRingBuffer(pattern); int counter = -1; for (final byte b : search) { counter++; final boolean matched = circ.addAndCompare(b); if (counter == 10) { assertTrue(matched); } else { assertFalse(matched); } } }