wharmby Wed Jan 7 14:49:35 2009 UTC Added files: (Branch: PHP_5_3) /php-src/ext/pcre/tests preg_match_variation1.phpt preg_match_basic_002.phpt preg_last_error_error.phpt pcre.constants.phpt Log: New pcre extension tests. Tested on Windows, Linux and Linux 64-bit
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/preg_match_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/pcre/tests/preg_match_variation1.phpt +++ php-src/ext/pcre/tests/preg_match_variation1.phpt --TEST-- Test preg_match() function : variation --FILE-- <?php /* * proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]]) * Function is implemented in ext/pcre/php_pcre.c */ //test passing in the same variable where 1 is by value, the other is a different //type and by reference so should be updated to the new type. $string = "-1"; preg_match('/[\-\+]?[0-9\.]*/', $string, $string); var_dump($string); ?> ===Done=== --EXPECT-- array(1) { [0]=> unicode(2) "-1" } ===Done=== http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/preg_match_basic_002.phpt?view=markup&rev=1.1 Index: php-src/ext/pcre/tests/preg_match_basic_002.phpt +++ php-src/ext/pcre/tests/preg_match_basic_002.phpt --TEST-- preg_match() single line match with multi-line input --FILE-- <?php /* Prototype : int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags [, int $offset ]]] ) * Description: Perform a regular expression match * Source code: ext/pcre/php_pcre.c */ $string = "My\nName\nIs\nStrange"; preg_match("/M(.*)/", $string, $matches); var_dump($matches); ?> ===Done=== --EXPECTF-- array(2) { [0]=> unicode(2) "My" [1]=> unicode(1) "y" } ===Done=== http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/preg_last_error_error.phpt?view=markup&rev=1.1 Index: php-src/ext/pcre/tests/preg_last_error_error.phpt +++ php-src/ext/pcre/tests/preg_last_error_error.phpt --TEST-- Test preg_grep() function : error conditions - wrong numbers of parameters --FILE-- <?php /* Prototype : int preg_last_error ( void ) * Description: Returns the error code of the last PCRE regex execution * Source code: ext/pcre/php_pcre.c */ /* * Pass an incorrect number of arguments to preg_last_error() to test behaviour */ echo "*** Testing preg_last_error() : error conditions ***\n"; // Test preg_last_error with one more than the expected number of arguments echo "\n-- Testing preg_last_error() function with more than expected no. of arguments --\n"; $extra_arg = 10; var_dump( preg_last_error($extra_arg) ); ?> ===Done=== --EXPECTF-- *** Testing preg_last_error() : error conditions *** -- Testing preg_last_error() function with more than expected no. of arguments -- Warning: preg_last_error() expects exactly 0 parameters, 1 given in %s on line %d NULL ===Done=== http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/pcre.constants.phpt?view=markup&rev=1.1 Index: php-src/ext/pcre/tests/pcre.constants.phpt +++ php-src/ext/pcre/tests/pcre.constants.phpt --TEST-- Test for pre-defined pcre constants --FILE-- <?php echo "PCRE constants test\n"; echo "PREG_PATTERN_ORDER= ", PREG_PATTERN_ORDER, "\n"; echo "PREG_OFFSET_CAPTURE= ", PREG_OFFSET_CAPTURE, "\n"; echo "PREG_SPLIT_NO_EMPTY= ", PREG_SPLIT_NO_EMPTY, "\n"; echo "PREG_SPLIT_DELIM_CAPTURE= ", PREG_SPLIT_DELIM_CAPTURE, "\n"; echo "PREG_SPLIT_OFFSET_CAPTURE= ", PREG_SPLIT_OFFSET_CAPTURE, "\n"; echo "PREG_GREP_INVERT= ", PREG_GREP_INVERT, "\n"; echo "PREG_NO_ERROR= ", PREG_NO_ERROR, "\n"; echo "PREG_INTERNAL_ERROR= ", PREG_INTERNAL_ERROR, "\n"; echo "PREG_BACKTRACK_LIMIT_ERROR= ", PREG_BACKTRACK_LIMIT_ERROR, "\n"; echo "PREG_RECURSION_LIMIT_ERROR= ", PREG_RECURSION_LIMIT_ERROR, "\n"; echo "PREG_BAD_UTF8_ERROR= ", PREG_BAD_UTF8_ERROR, "\n"; ?> ===Done=== --EXPECT-- PCRE constants test PREG_PATTERN_ORDER= 1 PREG_OFFSET_CAPTURE= 256 PREG_SPLIT_NO_EMPTY= 1 PREG_SPLIT_DELIM_CAPTURE= 2 PREG_SPLIT_OFFSET_CAPTURE= 4 PREG_GREP_INVERT= 1 PREG_NO_ERROR= 0 PREG_INTERNAL_ERROR= 1 PREG_BACKTRACK_LIMIT_ERROR= 2 PREG_RECURSION_LIMIT_ERROR= 3 PREG_BAD_UTF8_ERROR= 4 ===Done=== -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php