Program: 87476
Project: 87476
Buggy source:
public void testMoveCursor(){
  final WordComposer wc=new WordComposer();
  final String STR_WITHIN_BMP="String_Node_Str";
  final String PREVWORD="String_Node_Str";
  wc.setComposingWord(STR_WITHIN_BMP,PREVWORD,null);
  assertEquals(wc.size(),STR_WITHIN_BMP.codePointCount(0,STR_WITHIN_BMP.length()));
  assertFalse(wc.isCursorFrontOrMiddleOfComposingWord());
  wc.setCursorPositionWithinWord(2);
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(2));
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(1));
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertEquals(wc.size(),6);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(1));
  assertFalse(wc.isCursorFrontOrMiddleOfComposingWord());
  assertEquals(PREVWORD,wc.getPreviousWord());
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(1));
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(15));
  wc.reset();
  assertNull(wc.getPreviousWord());
  final String STR_WITH_SUPPLEMENTARY_CHAR="String_Node_Str";
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  assertEquals(wc.size(),STR_WITH_SUPPLEMENTARY_CHAR.codePointCount(0,STR_WITH_SUPPLEMENTARY_CHAR.length()));
  assertFalse(wc.isCursorFrontOrMiddleOfComposingWord());
  wc.setCursorPositionWithinWord(3);
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(6));
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(1));
  assertFalse(wc.isCursorFrontOrMiddleOfComposingWord());
  assertNull(wc.getPreviousWord());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,STR_WITHIN_BMP,null);
  wc.setCursorPositionWithinWord(3);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(7));
  assertEquals(STR_WITHIN_BMP,wc.getPreviousWord());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,STR_WITH_SUPPLEMENTARY_CHAR,null);
  wc.setCursorPositionWithinWord(3);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(7));
  assertEquals(STR_WITH_SUPPLEMENTARY_CHAR,wc.getPreviousWord());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,STR_WITHIN_BMP,null);
  wc.setCursorPositionWithinWord(3);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(-3));
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(-1));
  assertEquals(STR_WITHIN_BMP,wc.getPreviousWord());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  wc.setCursorPositionWithinWord(3);
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(-9));
  assertNull(wc.getPreviousWord());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,STR_WITH_SUPPLEMENTARY_CHAR,null);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(-10));
  assertEquals(STR_WITH_SUPPLEMENTARY_CHAR,wc.getPreviousWord());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(-11));
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(0));
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  wc.setCursorPositionWithinWord(2);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(0));
}

Fixed version (ground truth):
public void testMoveCursor(){
  final WordComposer wc=new WordComposer();
  final String STR_WITHIN_BMP="String_Node_Str";
  final String PREVWORD="String_Node_Str";
  wc.setComposingWord(STR_WITHIN_BMP,PREVWORD,null);
  assertEquals(wc.size(),STR_WITHIN_BMP.codePointCount(0,STR_WITHIN_BMP.length()));
  assertFalse(wc.isCursorFrontOrMiddleOfComposingWord());
  wc.setCursorPositionWithinWord(2);
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(2));
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(1));
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertEquals(wc.size(),6);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(1));
  assertFalse(wc.isCursorFrontOrMiddleOfComposingWord());
  assertEquals(PREVWORD,wc.getPreviousWordForSuggestion());
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(1));
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(15));
  wc.reset();
  assertNull(wc.getPreviousWordForSuggestion());
  final String STR_WITH_SUPPLEMENTARY_CHAR="String_Node_Str";
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  assertEquals(wc.size(),STR_WITH_SUPPLEMENTARY_CHAR.codePointCount(0,STR_WITH_SUPPLEMENTARY_CHAR.length()));
  assertFalse(wc.isCursorFrontOrMiddleOfComposingWord());
  wc.setCursorPositionWithinWord(3);
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(6));
  assertTrue(wc.isCursorFrontOrMiddleOfComposingWord());
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(1));
  assertFalse(wc.isCursorFrontOrMiddleOfComposingWord());
  assertNull(wc.getPreviousWordForSuggestion());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,STR_WITHIN_BMP,null);
  wc.setCursorPositionWithinWord(3);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(7));
  assertEquals(STR_WITHIN_BMP,wc.getPreviousWordForSuggestion());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,STR_WITH_SUPPLEMENTARY_CHAR,null);
  wc.setCursorPositionWithinWord(3);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(7));
  assertEquals(STR_WITH_SUPPLEMENTARY_CHAR,wc.getPreviousWordForSuggestion());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,STR_WITHIN_BMP,null);
  wc.setCursorPositionWithinWord(3);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(-3));
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(-1));
  assertEquals(STR_WITHIN_BMP,wc.getPreviousWordForSuggestion());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  wc.setCursorPositionWithinWord(3);
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(-9));
  assertNull(wc.getPreviousWordForSuggestion());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,STR_WITH_SUPPLEMENTARY_CHAR,null);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(-10));
  assertEquals(STR_WITH_SUPPLEMENTARY_CHAR,wc.getPreviousWordForSuggestion());
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  assertFalse(wc.moveCursorByAndReturnIfInsideComposingWord(-11));
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(0));
  wc.setComposingWord(STR_WITH_SUPPLEMENTARY_CHAR,null,null);
  wc.setCursorPositionWithinWord(2);
  assertTrue(wc.moveCursorByAndReturnIfInsideComposingWord(0));
}