CParser::PARSE_SUCCESS, 'match' => '\\0' ]], ['\\1', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\1' ]], ['\\2', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\2' ]], ['\\3', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\3' ]], ['\\4', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\4' ]], ['\\5', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\5' ]], ['\\6', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\6' ]], ['\\7', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\7' ]], ['\\8', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\8' ]], ['\\9', 0, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\9' ]], ['\\9\\0', 0, [ 'rc' => CParser::PARSE_SUCCESS_CONT, 'match' => '\\9' ]], ['\\a\\0', 0, [ 'rc' => CParser::PARSE_FAIL, 'match' => '' ]], ['\\a\\0', 2, [ 'rc' => CParser::PARSE_SUCCESS, 'match' => '\\0' ]] ]; } /** * @dataProvider dataProvider * * @param string $source * @param int $pos * @param array $expected */ public function testParse($source, $pos, $expected) { static $replacement_parser = null; if ($replacement_parser === null) { $replacement_parser = new CReplacementParser(); } $this->assertSame($expected, [ 'rc' => $replacement_parser->parse($source, $pos), 'match' => $replacement_parser->getMatch() ]); $this->assertSame(strlen($expected['match']), $replacement_parser->getLength()); } }