### Question:
TextChangeImpl implements TextChange { public void advance(int offset) throws IllegalArgumentException { if (offset == 0) { return; } int newStart = myStart + offset; if (newStart < 0) { throw new IllegalArgumentException(String.format( "Can't apply given offset (%d) to the current text change object (%s). Reason: new start index becomes negative after that (%d)", offset, this, newStart )); } setStart(newStart); setEnd(myEnd + offset); } TextChangeImpl(@NotNull CharSequence text, int start);  TextChangeImpl(@NotNull CharSequence text, int start, int end); int getStart(); void setStart(int start); int getEnd(); void setEnd(int end); @NotNull CharSequence getText(); @NotNull char[] getChars(); int getDiff(); void advance(int offset); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test(expected = IllegalArgumentException.class) public void advanceToNegativeOffset() { new TextChangeImpl("", 1, 2).advance(-2); }
@Test public void advance() { TextChangeImpl base = new TextChangeImpl("xyz", 3, 5); int[] offsets = {5, 0, -3}; for (int offset : offsets) { int start = base.getStart(); int end = base.getEnd(); base.advance(offset); assertEquals(new TextChangeImpl(base.getText(), start + offset, end + offset), base); } }