TextBufferImpl implements TextBuffer { @Override public void delete(Position start, Position end) { if (start.isAfter(end)) { throw new IllegalArgumentException("start position " + start + " is after end position " + end); } String prefix = getLinePrefix(start); String suffix = getLineSuffix(end); String stichedLine = prefix + suffix; lines.set(start.lineIndex(), stichedLine); deleteLines(start.lineIndex() + 1, end.lineIndex() + 1); incrementVersion(); } TextBufferImpl();   TextBufferImpl(String text); @Override Version getVersion(); @Override String getString(); @Override int getMaxLineIndex(); @Override String getLine(int lineIndex); @Override Position write(Position position, String text); @Override void clear(); @Override void delete(Position start, Position end);  }
@Test public void testDelete() { write(0, 0, "foo\nbar\nzoo\n"); delete(0, 2, 2, 1); assertEquals("fooo\n", textBuffer.getString()); delete(0, 4, 1, 0); assertEquals("fooo", textBuffer.getString()); delete(0, 0, 0, 4); assertEquals("", textBuffer.getString()); delete(0, 0, 0, 0); assertEquals("", textBuffer.getString()); }