Program: 87915
Project: 87915
Buggy source:
/** 
 * Test logic in getting the word range at the cursor.
 */
public void testGetWordRangeAtCursor(){
  ExtractedText et=new ExtractedText();
  final RichInputConnection ic=new RichInputConnection();
  InputConnection mockConnection;
  mockConnection=new MockConnection("String_Node_Str","String_Node_Str",et);
  et.startOffset=0;
  et.selectionStart=7;
  Range r;
  ic.beginBatchEdit(mockConnection);
  r=ic.getWordRangeAtCursor("String_Node_Str",0);
  assertEquals("String_Node_Str",r.mWord);
  r=ic.getWordRangeAtCursor("String_Node_Str",1);
  assertEquals("String_Node_Str",r.mWord);
  ic.endBatchEdit();
  mockConnection=new MockConnection("String_Node_Str","String_Node_Str",et);
  ic.beginBatchEdit(mockConnection);
  r=ic.getWordRangeAtCursor("String_Node_Str",1);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
  mockConnection=new MockConnection("String_Node_Str","String_Node_Str",et);
  ic.beginBatchEdit(mockConnection);
  r=ic.getWordRangeAtCursor("String_Node_Str",1);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
  mockConnection=new MockConnection("String_Node_Str","String_Node_Str",et);
  ic.beginBatchEdit(mockConnection);
  r=ic.getWordRangeAtCursor("String_Node_Str",1);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
  mockConnection=new MockConnection("String_Node_Str","String_Node_Str",et);
  ic.beginBatchEdit(mockConnection);
  r=ic.getWordRangeAtCursor("String_Node_Str",2);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
  final String supplementaryChar="String_Node_Str";
  mockConnection=new MockConnection("String_Node_Str" + supplementaryChar + "String_Node_Str","String_Node_Str",et);
  ic.beginBatchEdit(mockConnection);
  r=ic.getWordRangeAtCursor(supplementaryChar,0);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
}

Fixed version (ground truth):
/** 
 * Test logic in getting the word range at the cursor.
 */
public void testGetWordRangeAtCursor(){
  ExtractedText et=new ExtractedText();
  final MockInputMethodService mockInputMethodService=new MockInputMethodService();
  final RichInputConnection ic=new RichInputConnection(mockInputMethodService);
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str","String_Node_Str",et));
  et.startOffset=0;
  et.selectionStart=7;
  Range r;
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor("String_Node_Str",0);
  assertEquals("String_Node_Str",r.mWord);
  r=ic.getWordRangeAtCursor("String_Node_Str",1);
  assertEquals("String_Node_Str",r.mWord);
  ic.endBatchEdit();
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor("String_Node_Str",1);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor("String_Node_Str",1);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor("String_Node_Str",1);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor("String_Node_Str",2);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
  final String supplementaryChar="String_Node_Str";
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str" + supplementaryChar + "String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(supplementaryChar,0);
  ic.endBatchEdit();
  assertEquals("String_Node_Str",r.mWord);
}