Program: 87365
Project: 87365
Buggy source:
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;
  TextRange r;
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  assertTrue(TextUtils.equals("String_Node_Str",r.mWord));
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(TAB,ScriptUtils.SCRIPT_LATIN);
  ic.endBatchEdit();
  assertTrue(TextUtils.equals("String_Node_Str",r.mWord));
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str" + SUPPLEMENTARY_CHAR + "String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR),ScriptUtils.SCRIPT_LATIN);
  ic.endBatchEdit();
  assertTrue(TextUtils.equals("String_Node_Str",r.mWord));
  mockInputMethodService.setInputConnection(new MockConnection(HIRAGANA_WORD + "String_Node_Str","String_Node_Str" + GREEK_WORD,et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR),ScriptUtils.SCRIPT_LATIN);
  ic.endBatchEdit();
  assertTrue(TextUtils.equals("String_Node_Str",r.mWord));
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str" + GREEK_WORD,"String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR),ScriptUtils.SCRIPT_GREEK);
  ic.endBatchEdit();
  assertTrue(TextUtils.equals(GREEK_WORD,r.mWord));
}

Fixed version (ground truth):
public void testGetWordRangeAtCursor(){
  final SpacingAndPunctuations SPACE=new SpacingAndPunctuations(mSpacingAndPunctuations,new int[]{Constants.CODE_SPACE});
  final SpacingAndPunctuations TAB=new SpacingAndPunctuations(mSpacingAndPunctuations,new int[]{Constants.CODE_TAB});
  final int[] SPACE_TAB=StringUtils.toSortedCodePointArray("String_Node_Str");
  final String SUPPLEMENTARY_CHAR_STRING="String_Node_Str";
  final SpacingAndPunctuations SUPPLEMENTARY_CHAR=new SpacingAndPunctuations(mSpacingAndPunctuations,StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR_STRING));
  final String HIRAGANA_WORD="String_Node_Str";
  final String GREEK_WORD="String_Node_Str";
  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;
  TextRange r;
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  assertTrue(TextUtils.equals("String_Node_Str",r.mWord));
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(TAB,ScriptUtils.SCRIPT_LATIN);
  ic.endBatchEdit();
  assertTrue(TextUtils.equals("String_Node_Str",r.mWord));
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str" + SUPPLEMENTARY_CHAR_STRING + "String_Node_Str","String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR,ScriptUtils.SCRIPT_LATIN);
  ic.endBatchEdit();
  assertTrue(TextUtils.equals("String_Node_Str",r.mWord));
  mockInputMethodService.setInputConnection(new MockConnection(HIRAGANA_WORD + "String_Node_Str","String_Node_Str" + GREEK_WORD,et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR,ScriptUtils.SCRIPT_LATIN);
  ic.endBatchEdit();
  assertTrue(TextUtils.equals("String_Node_Str",r.mWord));
  mockInputMethodService.setInputConnection(new MockConnection("String_Node_Str" + GREEK_WORD,"String_Node_Str",et));
  ic.beginBatchEdit();
  r=ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR,ScriptUtils.SCRIPT_GREEK);
  ic.endBatchEdit();
  assertTrue(TextUtils.equals(GREEK_WORD,r.mWord));
}