context.setMatchCase(false);
textArea.setCaretPosition(end);
boolean found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 60, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(60, 65), 1, markedCount));
found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 48, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(48, 53), 1, markedCount));
found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 32, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(32, 37), 1, markedCount));
found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 26, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(26, 31), 1, markedCount));
found = findImpl(context);
assertFalse(found);
assertResult(new SearchResult(null, 0, markedCount));
// Search for "Chuck", matching case.
context.setSearchFor("Chuck");
markedCount = markAll ? 1 : 0;
context.setMatchCase(true);
textArea.setCaretPosition(end);
found = findImpl(context);
assertTrue(found);
assertSelected("Chuck", 26, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(26, 31), 1, markedCount));
found = findImpl(context);
assertFalse(found);
assertResult(new SearchResult(null, 0, markedCount));
// Search for "chuck", ignoring case, whole word
context.setSearchFor("Chuck");
markedCount = markAll ? 2 : 0;
context.setMatchCase(false);
context.setWholeWord(true);
textArea.setCaretPosition(end);
found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 60, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(60, 65), 1, markedCount));
found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 32, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(32, 37), 1, markedCount));
found = findImpl(context);
assertFalse(found);
assertResult(new SearchResult(null, 0, markedCount));
// Search for "wood", matching case, whole word
context.setSearchFor("wood");
markedCount = markAll ? 1 : 0;
context.setMatchCase(true);
context.setWholeWord(true);
textArea.setCaretPosition(end);
found = findImpl(context);
assertTrue(found);
assertSelected("wood", 9, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(9, 13), 1, markedCount));
found = findImpl(context);
assertFalse(found);
assertResult(new SearchResult(null, 0, markedCount));
// Search for ".ould", regex, ignoring case
context.setSearchFor(".ould");
markedCount = markAll ? 2 : 0;
context.setMatchCase(false);
context.setWholeWord(false);
context.setRegularExpression(true);
textArea.setCaretPosition(end);
found = findImpl(context);
assertTrue(found);
assertSelected("could", 54, true);
assertResult(new SearchResult(new DocumentRange(54, 59), 1, markedCount));
found = findImpl(context);
assertTrue(found);
assertSelected("wOuld", 14, true);
assertResult(new SearchResult(new DocumentRange(14, 19), 1, markedCount));
found = findImpl(context);
assertFalse(found);
assertResult(new SearchResult(null, 0, markedCount));
// Search for ".ould", regex, matching case
context.setSearchFor(".ould");
markedCount = markAll ? 1 : 0;
context.setMatchCase(true);
context.setWholeWord(false);
context.setRegularExpression(true);
textArea.setCaretPosition(end);
found = findImpl(context);
assertTrue(found);
assertSelected("could", 54, true);
assertResult(new SearchResult(new DocumentRange(54, 59), 1, markedCount));
found = findImpl(context);
assertFalse(found);
assertResult(new SearchResult(null, 0, markedCount));
// Search for "[cd]huck", regex, ignoring case, whole word
context.setSearchFor("[cd]hUCk");
markedCount = markAll ? 2 : 0;
context.setMatchCase(false);
context.setWholeWord(true);
context.setRegularExpression(true);
textArea.setCaretPosition(end);
found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 60, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(60, 65), 1, markedCount));
found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 32, context.getMatchCase());
assertResult(new SearchResult(new DocumentRange(32, 37), 1, markedCount));
found = findImpl(context);
assertFalse(found);
assertResult(new SearchResult(null, 0, markedCount));
// Search for "[cd]huck", regex, matching case, whole word
context.setSearchFor("[cd]huck");
markedCount = markAll ? 1 : 0;
context.setMatchCase(true);
context.setWholeWord(true);
context.setRegularExpression(true);
textArea.setCaretPosition(end);
found = findImpl(context);
assertTrue(found);
assertSelected("chuck", 60, true);
assertResult(new SearchResult(new DocumentRange(60, 65), 1, markedCount));
found = findImpl(context);
assertFalse(found);
assertResult(new SearchResult(null, 0, markedCount));
}