### Question:
Cursor { public int getOffset() { return getOffset(textOffset); } Cursor(TextSegment segment); int getOffset(); int getOffset(int cursorOffset); int toCursorOffset(int documentOffset); char getChar(); char getChar(int offset); boolean hasChar(); String getText(int offset, int endIndex); char getPrevious(); boolean hasPrevious(); boolean hasPrevious(int offset); char getPrevious(int offset); char getNext(); char getNext(int offset); String getTextAtOffset(); String getTextAtOffset(int length); boolean hasNext(); boolean hasNext(int offset); Matcher matcher(Pattern pattern); Matcher matcher(int offset, Pattern pattern); void advance(); void advance(int count); void rewind(int count); void rewind(); Line getLineAtOffset();  }### Answer:
@Test public void getOffset() { Cursor cursor = new Cursor(createTextSegment("one\r\ntwo")); assertEquals(0, cursor.getOffset(0)); assertEquals(0, cursor.getOffset()); assertEquals(1, cursor.getOffset(1)); assertEquals(5, cursor.getOffset(4)); cursor.advance(4); assertEquals(5, cursor.getOffset()); cursor = new Cursor(new TextSegment(ImmutableList.of(new Line(1, 10, "abc")))); assertEquals(12, cursor.getOffset(2)); }