public function testCursorPosition()
{
$context = new CompletionContext();
$context->setCommandLine('make horse --legs 4 --colour black ');
// Cursor at the start of the line
$context->setCharIndex(0);
$this->assertEquals(0, $context->getWordIndex());
// Cursor at the end of the line
$context->setCharIndex(34);
$this->assertEquals(5, $context->getWordIndex());
$this->assertEquals('black', $context->getCurrentWord());
// Cursor after space at the end of the string
$context->setCharIndex(35);
$this->assertEquals(6, $context->getWordIndex());
$this->assertEquals('', $context->getCurrentWord());
// Cursor in the middle of 'horse'
$context->setCharIndex(8);
$this->assertEquals(1, $context->getWordIndex());
$this->assertEquals('hor', $context->getCurrentWord());
// Cursor at the end of '--legs'
$context->setCharIndex(17);
$this->assertEquals(2, $context->getWordIndex());
$this->assertEquals('--legs', $context->getCurrentWord());
}