}
}
public static void checkCompletions(TestCommandShell cs, String line, String[] expected, int startPos) {
cs.setReadingCommand(true);
CompletionInfo ci = cs.complete(line);
SortedSet<String> completions = ci.getCompletions();
if (completions.size() != expected.length) {
err("Wrong number of completions", expected, completions);
}
int i = 0;
for (String completion : completions) {
if (!completion.equals(expected[i])) {
err("Mismatch for completion #" + i, expected, completions);
}
i++;
}
if (startPos == -1) {
assert (startPos == ci.getCompletionStart() ||
line.length() == ci.getCompletionStart());
} else {
TestCase.assertEquals(startPos, ci.getCompletionStart());
}
}