### Question:
Cursor { public char getPrevious() { return getPrevious(1); } 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 getPrevious() { Cursor cursor = new Cursor(createTextSegment("123")); assertFalse(cursor.hasPrevious()); assertFalse(cursor.hasPrevious(2)); cursor.advance(); assertTrue(cursor.hasPrevious()); assertTrue(cursor.hasPrevious(1)); assertFalse(cursor.hasPrevious(2)); assertEquals('1', cursor.getPrevious()); assertEquals('1', cursor.getPrevious(1)); cursor.advance(); assertTrue(cursor.hasPrevious()); assertTrue(cursor.hasPrevious(1)); assertTrue(cursor.hasPrevious(2)); assertFalse(cursor.hasPrevious(3)); assertEquals('2', cursor.getPrevious()); assertEquals('2', cursor.getPrevious(1)); assertEquals('1', cursor.getPrevious(2)); cursor.advance(); assertEquals('3', cursor.getPrevious()); cursor.advance(); assertEquals('3', cursor.getPrevious()); }