From 202e7f5b28cead3bc179436edf212944dc3d9043 Mon Sep 17 00:00:00 2001 From: Robert Nicholson Date: Wed, 21 Nov 2007 18:21:19 +0000 Subject: [PATCH] Add some more pcre tests --- ext/pcre/tests/preg_grep_basic.phpt | 62 ++++++++++++++ ext/pcre/tests/preg_grep_error.phpt | 43 ++++++++++ ext/pcre/tests/preg_grep_error1.phpt | 68 +++++++++++++++ ext/pcre/tests/preg_grep_error2.phpt | 42 ++++++++++ ext/pcre/tests/preg_match_all_basic.phpt | 82 +++++++++++++++++++ ext/pcre/tests/preg_match_all_error.phpt | 45 ++++++++++ ext/pcre/tests/preg_match_all_error1.phpt | 81 ++++++++++++++++++ ext/pcre/tests/preg_match_all_error2.phpt | 54 ++++++++++++ ext/pcre/tests/preg_match_all_error3.phpt | 20 +++++ ext/pcre/tests/preg_match_basic.phpt | 52 ++++++++++++ ext/pcre/tests/preg_match_error.phpt | 44 ++++++++++ ext/pcre/tests/preg_match_error1.phpt | 61 ++++++++++++++ ext/pcre/tests/preg_match_error2.phpt | 38 +++++++++ ext/pcre/tests/preg_quote_basic.phpt | 25 ++++++ ext/pcre/tests/preg_quote_error.phpt | 33 ++++++++ ext/pcre/tests/preg_quote_error1.phpt | 36 ++++++++ ext/pcre/tests/preg_replace_basic.phpt | 25 ++++++ .../tests/preg_replace_callback_basic.phpt | 33 ++++++++ .../tests/preg_replace_callback_error.phpt | 48 +++++++++++ ext/pcre/tests/preg_replace_error.phpt | 45 ++++++++++ ext/pcre/tests/preg_replace_error1.phpt | 59 +++++++++++++ ext/pcre/tests/preg_replace_error2.phpt | 37 +++++++++ ext/pcre/tests/preg_replace_variation1.phpt | 17 ++++ ext/pcre/tests/preg_split_basic.phpt | 76 +++++++++++++++++ ext/pcre/tests/preg_split_error.phpt | 44 ++++++++++ ext/pcre/tests/preg_split_error1.phpt | 67 +++++++++++++++ ext/pcre/tests/preg_split_error2.phpt | 34 ++++++++ 27 files changed, 1271 insertions(+) create mode 100644 ext/pcre/tests/preg_grep_basic.phpt create mode 100644 ext/pcre/tests/preg_grep_error.phpt create mode 100644 ext/pcre/tests/preg_grep_error1.phpt create mode 100644 ext/pcre/tests/preg_grep_error2.phpt create mode 100644 ext/pcre/tests/preg_match_all_basic.phpt create mode 100644 ext/pcre/tests/preg_match_all_error.phpt create mode 100644 ext/pcre/tests/preg_match_all_error1.phpt create mode 100644 ext/pcre/tests/preg_match_all_error2.phpt create mode 100644 ext/pcre/tests/preg_match_all_error3.phpt create mode 100644 ext/pcre/tests/preg_match_basic.phpt create mode 100644 ext/pcre/tests/preg_match_error.phpt create mode 100644 ext/pcre/tests/preg_match_error1.phpt create mode 100644 ext/pcre/tests/preg_match_error2.phpt create mode 100644 ext/pcre/tests/preg_quote_basic.phpt create mode 100644 ext/pcre/tests/preg_quote_error.phpt create mode 100644 ext/pcre/tests/preg_quote_error1.phpt create mode 100644 ext/pcre/tests/preg_replace_basic.phpt create mode 100644 ext/pcre/tests/preg_replace_callback_basic.phpt create mode 100644 ext/pcre/tests/preg_replace_callback_error.phpt create mode 100644 ext/pcre/tests/preg_replace_error.phpt create mode 100644 ext/pcre/tests/preg_replace_error1.phpt create mode 100644 ext/pcre/tests/preg_replace_error2.phpt create mode 100644 ext/pcre/tests/preg_replace_variation1.phpt create mode 100644 ext/pcre/tests/preg_split_basic.phpt create mode 100644 ext/pcre/tests/preg_split_error.phpt create mode 100644 ext/pcre/tests/preg_split_error1.phpt create mode 100644 ext/pcre/tests/preg_split_error2.phpt diff --git a/ext/pcre/tests/preg_grep_basic.phpt b/ext/pcre/tests/preg_grep_basic.phpt new file mode 100644 index 0000000000..fe9d7ceaa7 --- /dev/null +++ b/ext/pcre/tests/preg_grep_basic.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test preg_grep() function : basic functionality +--FILE-- + +--EXPECT-- +array(5) { + [0]=> + string(22) "HTTP://WWW.EXAMPLE.COM" + [1]=> + string(11) "/index.html" + [2]=> + string(11) "/info/stat/" + [3]=> + string(29) "http://test.uk.com/index/html" + [4]=> + string(17) "/display/dept.php" +} +array(2) { + [0]=> + string(22) "HTTP://WWW.EXAMPLE.COM" + [3]=> + string(29) "http://test.uk.com/index/html" +} +array(5) { + [0]=> + string(22) "HTTP://WWW.EXAMPLE.COM" + [1]=> + string(11) "/index.html" + [2]=> + string(11) "/info/stat/" + [3]=> + string(29) "http://test.uk.com/index/html" + [4]=> + string(17) "/display/dept.php" +} +array(1) { + [3]=> + string(29) "http://test.uk.com/index/html" +} +array(0) { +} +array(3) { + [1]=> + string(11) "/index.html" + [2]=> + string(11) "/info/stat/" + [4]=> + string(17) "/display/dept.php" +} diff --git a/ext/pcre/tests/preg_grep_error.phpt b/ext/pcre/tests/preg_grep_error.phpt new file mode 100644 index 0000000000..f2afdb9d26 --- /dev/null +++ b/ext/pcre/tests/preg_grep_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test preg_grep() function : error conditions - wrong numbers of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_grep() : error conditions *** + +-- Testing preg_grep() function with Zero arguments -- + +Warning: preg_grep() expects at least 2 parameters, 0 given in %spreg_grep_error.php on line %d +NULL + +-- Testing preg_grep() function with more than expected no. of arguments -- + +Warning: preg_grep() expects at most 3 parameters, 4 given in %spreg_grep_error.php on line %d +NULL + +-- Testing preg_grep() function with less than expected no. of arguments -- + +Warning: preg_grep() expects at least 2 parameters, 1 given in %spreg_grep_error.php on line %d +NULL +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_grep_error1.phpt b/ext/pcre/tests/preg_grep_error1.phpt new file mode 100644 index 0000000000..29dfc5af1e --- /dev/null +++ b/ext/pcre/tests/preg_grep_error1.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test preg_grep() function : error conditions - bad regular expressions +--FILE-- + +--EXPECTF-- + +*** Testing preg_grep() : error conditions *** + +Arg value is abcdef + +Warning: preg_grep(): Delimiter must not be alphanumeric or backslash in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z] + +Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is [a-zA-Z]/ + +Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/F + +Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is Array + +Warning: preg_grep() expects parameter 1 to be string, array given in %spreg_grep_error1.php on line %d +NULL + +Arg value is /[a-zA-Z]/ +array(2) { + [1]=> + string(3) "abc" + [2]=> + string(4) "test" +} + +Warning: preg_grep() expects parameter 1 to be string, object given in %spreg_grep_error1.php on line %d +NULL +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_grep_error2.phpt b/ext/pcre/tests/preg_grep_error2.phpt new file mode 100644 index 0000000000..aa4dae98a0 --- /dev/null +++ b/ext/pcre/tests/preg_grep_error2.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test preg_grep() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_grep() : error conditions *** + +Arg value is: this is a string + +Warning: preg_grep() expects parameter 2 to be array, string given in %spreg_grep_error2.php on line %d +NULL + +Arg value is: Array +array(2) { + [0]=> + string(7) "this is" + [1]=> + string(10) "a subarray" +} + +Warning: preg_grep() expects parameter 2 to be array, object given in %spreg_grep_error2.php on line %d +NULL +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_match_all_basic.phpt b/ext/pcre/tests/preg_match_all_basic.phpt new file mode 100644 index 0000000000..06dec1cb45 --- /dev/null +++ b/ext/pcre/tests/preg_match_all_basic.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test preg_match_all() function : basic functionality +--FILE-- + +--EXPECTF-- +int(1) +array(1) { + [0]=> + array(1) { + [0]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + int(61) + } + } +} +int(2) +array(2) { + [0]=> + array(2) { + [0]=> + string(15) "This is a test." + [1]=> + string(5) " test" + } + [1]=> + array(2) { + [0]=> + string(21) "This is another test." + [1]=> + string(11) "nother test" + } +} +int(1) +array(2) { + [0]=> + array(1) { + [0]=> + string(21) ". \[4]. 34534 string." + } + [1]=> + array(1) { + [0]=> + string(17) "[4]. 34534 string" + } +} +int(0) +array(1) { + [0]=> + array(0) { + } +} +int(0) +array(3) { + [0]=> + array(0) { + } + [1]=> + array(0) { + } + [2]=> + array(0) { + } +} diff --git a/ext/pcre/tests/preg_match_all_error.phpt b/ext/pcre/tests/preg_match_all_error.phpt new file mode 100644 index 0000000000..2371ccfef1 --- /dev/null +++ b/ext/pcre/tests/preg_match_all_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test preg_match_all() function : error conditions - incorrect number of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_match_all() : error conditions *** + +-- Testing preg_match_all() function with Zero arguments -- + +Warning: preg_match_all() expects at least 3 parameters, 0 given in %spreg_match_all_error.php on line %d +bool(false) + +-- Testing preg_match_all() function with more than expected no. of arguments -- + +Warning: preg_match_all() expects at most 5 parameters, 6 given in %spreg_match_all_error.php on line %d +bool(false) + +-- Testing preg_match_all() function with less than expected no. of arguments -- + +Warning: preg_match_all() expects at least 3 parameters, 2 given in %spreg_match_all_error.php on line %d +bool(false) +Done diff --git a/ext/pcre/tests/preg_match_all_error1.phpt b/ext/pcre/tests/preg_match_all_error1.phpt new file mode 100644 index 0000000000..a3cb684044 --- /dev/null +++ b/ext/pcre/tests/preg_match_all_error1.phpt @@ -0,0 +1,81 @@ +--TEST-- +Test preg_match_all() function : error conditions - bad regular expressions +--FILE-- + +--EXPECTF-- +*** Testing preg_match_all() : error conditions *** + +Arg value is abcdef + +Warning: preg_match_all(): Delimiter must not be alphanumeric or backslash in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z] + +Warning: preg_match_all(): No ending delimiter '/' found in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is [a-zA-Z]/ + +Warning: preg_match_all(): Unknown modifier '/' in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z]/F + +Warning: preg_match_all(): Unknown modifier 'F' in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is Array + +Warning: preg_match_all() expects parameter 1 to be string, array given in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z]/ +int(4) +array(1) { + [0]=> + array(4) { + [0]=> + string(1) "t" + [1]=> + string(1) "e" + [2]=> + string(1) "s" + [3]=> + string(1) "t" + } +} + +Warning: preg_match_all() expects parameter 1 to be string, object given in %spreg_match_all_error1.php on line %d +bool(false) +NULL diff --git a/ext/pcre/tests/preg_match_all_error2.phpt b/ext/pcre/tests/preg_match_all_error2.phpt new file mode 100644 index 0000000000..1c55cce64e --- /dev/null +++ b/ext/pcre/tests/preg_match_all_error2.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test preg_match_all() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_match_all() : error conditions *** + +Warning: preg_match_all() expects parameter 2 to be string, object given in %spreg_match_all_error2.php on line %d +bool(false) +NULL + +Arg value is: Array + +Warning: preg_match_all() expects parameter 2 to be string, array given in %spreg_match_all_error2.php on line %d +bool(false) +NULL + +Arg value is: test +int(4) +array(1) { + [0]=> + array(4) { + [0]=> + string(1) "t" + [1]=> + string(1) "e" + [2]=> + string(1) "s" + [3]=> + string(1) "t" + } +} +Done diff --git a/ext/pcre/tests/preg_match_all_error3.phpt b/ext/pcre/tests/preg_match_all_error3.phpt new file mode 100644 index 0000000000..b8b2ea211b --- /dev/null +++ b/ext/pcre/tests/preg_match_all_error3.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test preg_match_all() function : error conditions +--FILE-- + +--EXPECTF-- + +Fatal error: Only variables can be passed by reference in %spreg_match_all_error3.php on line %d diff --git a/ext/pcre/tests/preg_match_basic.phpt b/ext/pcre/tests/preg_match_basic.phpt new file mode 100644 index 0000000000..ddf54a0aaf --- /dev/null +++ b/ext/pcre/tests/preg_match_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test preg_match() function : basic functionality +--FILE-- + + +--EXPECTF-- + +int(1) +array(1) { + [0]=> + string(7) "Hello, " +} +int(0) +array(0) { +} +int(1) +array(2) { + [0]=> + string(23) "[*], this is \ a string" + [1]=> + string(18) "this is \ a string" +} +int(1) +array(1) { + [0]=> + array(2) { + [0]=> + string(18) "this is \ a string" + [1]=> + int(19) + } +} +int(0) +array(0) { +} + diff --git a/ext/pcre/tests/preg_match_error.phpt b/ext/pcre/tests/preg_match_error.phpt new file mode 100644 index 0000000000..ca1f128ada --- /dev/null +++ b/ext/pcre/tests/preg_match_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test preg_match() function : error conditions - wrong numbers of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_match() : error conditions *** + +-- Testing preg_match() function with Zero arguments -- + +Warning: preg_match() expects at least 2 parameters, 0 given in %spreg_match_error.php on line %d +bool(false) + +-- Testing preg_match() function with more than expected no. of arguments -- + +Warning: preg_match() expects at most 5 parameters, 6 given in %spreg_match_error.php on line %d +bool(false) + +-- Testing preg_match() function with less than expected no. of arguments -- + +Warning: preg_match() expects at least 2 parameters, 1 given in %spreg_match_error.php on line %d +bool(false) +Done diff --git a/ext/pcre/tests/preg_match_error1.phpt b/ext/pcre/tests/preg_match_error1.phpt new file mode 100644 index 0000000000..7630481517 --- /dev/null +++ b/ext/pcre/tests/preg_match_error1.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test preg_match() function : error conditions - bad regular expressions +--FILE-- + +--EXPECTF-- + +*** Testing preg_match() : error conditions *** + +Arg value is abcdef + +Warning: preg_match(): Delimiter must not be alphanumeric or backslash in %spreg_match_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z] + +Warning: preg_match(): No ending delimiter '/' found in %spreg_match_error1.php on line %d +bool(false) + +Arg value is [a-zA-Z]/ + +Warning: preg_match(): Unknown modifier '/' in %spreg_match_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/F + +Warning: preg_match(): Unknown modifier 'F' in %spreg_match_error1.php on line %d +bool(false) + +Arg value is Array + +Warning: preg_match() expects parameter 1 to be string, array given in %spreg_match_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/ +int(1) + +Warning: preg_match() expects parameter 1 to be string, object given in %spreg_match_error1.php on line %d +bool(false) diff --git a/ext/pcre/tests/preg_match_error2.phpt b/ext/pcre/tests/preg_match_error2.phpt new file mode 100644 index 0000000000..f30fb48037 --- /dev/null +++ b/ext/pcre/tests/preg_match_error2.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test preg_match() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- + +*** Testing preg_match() : error conditions *** + +Arg value is: this is a string +int(1) + +Arg value is: Array + +Warning: preg_match() expects parameter 2 to be string, array given in %spreg_match_error2.php on line %d +bool(false) + +Warning: preg_match() expects parameter 2 to be string, object given in %spreg_match_error2.php on line %d +bool(false) +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_quote_basic.phpt b/ext/pcre/tests/preg_quote_basic.phpt new file mode 100644 index 0000000000..d4bbe96616 --- /dev/null +++ b/ext/pcre/tests/preg_quote_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test preg_quote() function : basic functionality +--FILE-- + +--EXPECT-- + +$string_before looks like: /this *-has \ metacharacters^ in $ +$string_after looks like: \/this \*-has \\ metacharacters\^ in \$, with metacharacters and / (set as delimiter) escaped +int(1) +array(1) { + [0]=> + string(58) "testing - /this *-has \ metacharacters^ in $ should work" +} \ No newline at end of file diff --git a/ext/pcre/tests/preg_quote_error.phpt b/ext/pcre/tests/preg_quote_error.phpt new file mode 100644 index 0000000000..30b832dbf9 --- /dev/null +++ b/ext/pcre/tests/preg_quote_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test preg_quote() function : error conditions - wrong numbers of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_quote() : error conditions *** + +-- Testing preg_quote() function with Zero arguments -- + +Warning: preg_quote() expects at least 1 parameter, 0 given in %spreg_quote_error.php on line %d +NULL + +-- Testing preg_quote() function with more than expected no. of arguments -- + +Warning: preg_quote() expects at most 2 parameters, 3 given in %spreg_quote_error.php on line %d +NULL +Done diff --git a/ext/pcre/tests/preg_quote_error1.phpt b/ext/pcre/tests/preg_quote_error1.phpt new file mode 100644 index 0000000000..a02c836707 --- /dev/null +++ b/ext/pcre/tests/preg_quote_error1.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test preg_quote() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_quote() : error conditions *** + +Arg value is: this is a string +string(16) "this is a string" + +Arg value is: Array + +Warning: preg_quote() expects parameter 1 to be string, array given in %spreg_quote_error1.php on line %d +NULL + +Warning: preg_quote() expects parameter 1 to be string, object given in %spreg_quote_error1.php on line %d +NULL +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_replace_basic.phpt b/ext/pcre/tests/preg_replace_basic.phpt new file mode 100644 index 0000000000..33fb2d4a8a --- /dev/null +++ b/ext/pcre/tests/preg_replace_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test preg_replace() function : basic functionality +--FILE-- +', 'This shouldn\'t work', $string)); //tries to find '- This is a string' at the end of a string but can't so replaces nothing and prints the unchanged $string. +var_dump(preg_replace('<[0-35-9]>', '4', $string)); //finds any number that's not 4 and replaces it with a 4 ('444444444') +var_dump(preg_replace('<\b[hH]\w{2,4}>', 'Bonjour', $string)); //finds h or H at the beginning of a word followed by 2-4 characters and replaces it with Bonjour (i.e. Hello -> Bonjour) (was finding the 'his' in This and replacing it) +var_dump(preg_replace('<(\w)\s*-\s*(\w)>', '\\1. \\2', $string)); //finds dashes with an indefinate amount of whitespace around them and replaces them with a full stop precedeby no spaces and followed by one space +var_dump(preg_replace('<(^[a-z]\w+)@(\w+)\.(\w+)\.([a-z]{2,}$)>', '\\1 at \\2 dot \\3 dot \\4', 'josmessa@uk.ibm.com')); //finds the e-mail address and replaces the @ and . with "at" and "dot" (uses backreferences) ('josmessa at uk dot ibm dot com') + +?> +--EXPECT-- + +string(54) "123456789 - Hello, world - This is a string." +string(54) "123456789 - Hello, world - This is a string." +string(54) "444444444 - Hello, world - This is a string." +string(56) "123456789 - Bonjour, world - This is a string." +string(42) "123456789. Hello, world. This is a string." +string(30) "josmessa at uk dot ibm dot com" diff --git a/ext/pcre/tests/preg_replace_callback_basic.phpt b/ext/pcre/tests/preg_replace_callback_basic.phpt new file mode 100644 index 0000000000..01d290a1b9 --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test preg_replace_callback() function : basic functionality +--FILE-- + +--EXPECTF-- +there are seven words in this sentence. +one two three 4 is now written in words +there are no numbers in this string +0 diff --git a/ext/pcre/tests/preg_replace_callback_error.phpt b/ext/pcre/tests/preg_replace_callback_error.phpt new file mode 100644 index 0000000000..8d96446d4b --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test preg_replace_callback() function : error +--FILE-- + +--EXPECTF-- +***Testing preg_replace_callback() : error conditions*** + +-- Testing preg_replace_callback() function with Zero arguments -- + +Warning: Wrong parameter count for preg_replace_callback() in %spreg_replace_callback_error.php on line %d +NULL + +-- Testing preg_replace_callback() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for preg_replace_callback() in %spreg_replace_callback_error.php on line %d +NULL + +-- Testing preg_replace_callback() function with less than expected no. of arguments -- + +Warning: Wrong parameter count for preg_replace_callback() in %spreg_replace_callback_error.php on line %d +NULL +Done diff --git a/ext/pcre/tests/preg_replace_error.phpt b/ext/pcre/tests/preg_replace_error.phpt new file mode 100644 index 0000000000..c91f500f72 --- /dev/null +++ b/ext/pcre/tests/preg_replace_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test preg_replace() function : error - incorrect number of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_replace() : error conditions *** + +-- Testing preg_replace() function with zero arguments -- + +Warning: Wrong parameter count for preg_replace() in %spreg_replace_error.php on line %d +NULL + +-- Testing preg_replace() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for preg_replace() in %spreg_replace_error.php on line %d +NULL + +-- Testing preg_replace() function with less than expected no. of arguments -- + +Warning: Wrong parameter count for preg_replace() in %spreg_replace_error.php on line %d +NULL +Done diff --git a/ext/pcre/tests/preg_replace_error1.phpt b/ext/pcre/tests/preg_replace_error1.phpt new file mode 100644 index 0000000000..7ddfcfdef8 --- /dev/null +++ b/ext/pcre/tests/preg_replace_error1.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test preg_replace() function : error - bad regular expressions +--FILE-- + +--EXPECTF-- +*** Testing preg_replace() : error conditions*** + +Arg value is abcdef + +Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in %spreg_replace_error1.php on line %d +NULL + +Arg value is /[a-zA-Z] + +Warning: preg_replace(): No ending delimiter '/' found in %spreg_replace_error1.php on line %d +NULL + +Arg value is [a-zA-Z]/ + +Warning: preg_replace(): Unknown modifier '/' in %spreg_replace_error1.php on line %d +NULL + +Arg value is /[a-zA-Z]/F + +Warning: preg_replace(): Unknown modifier 'F' in %spreg_replace_error1.php on line %d +NULL + +Arg value is Array +string(1) "a" + +Arg value is /[a-zA-Z]/ +string(1) "1" + +Catchable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error1.php on line %d + diff --git a/ext/pcre/tests/preg_replace_error2.phpt b/ext/pcre/tests/preg_replace_error2.phpt new file mode 100644 index 0000000000..bf5d3e072c --- /dev/null +++ b/ext/pcre/tests/preg_replace_error2.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test preg_replace() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_replace() : error conditions *** + +Arg value is: this is a string +string(64) "this is a stringthis is a stringthis is a stringthis is a string" + +Arg value is: Array + +Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace_error2.php on line %d +bool(false) + +Catchable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error2.php on line %d + diff --git a/ext/pcre/tests/preg_replace_variation1.phpt b/ext/pcre/tests/preg_replace_variation1.phpt new file mode 100644 index 0000000000..ac79e0bfaf --- /dev/null +++ b/ext/pcre/tests/preg_replace_variation1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test preg_replace() function : variation both arguments are arrays +--FILE-- + +--EXPECTF-- +This test a string. It contains numbers *0 to 9* test well test parentheses and some other things* diff --git a/ext/pcre/tests/preg_split_basic.phpt b/ext/pcre/tests/preg_split_basic.phpt new file mode 100644 index 0000000000..324270ac3a --- /dev/null +++ b/ext/pcre/tests/preg_split_basic.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test preg_split() function : basic functionality +--INI-- +--FILE-- + +--EXPECT-- +array(7) { + [0]=> + string(14) "this is a_list" + [1]=> + string(7) " value1" + [2]=> + string(7) " Test__" + [3]=> + string(7) " string" + [4]=> + string(6) " Hello" + [5]=> + string(8) " world!_" + [6]=> + string(11) "parentheses" +} +array(2) { + [0]=> + string(14) "this is a_list" + [1]=> + string(28) " Hello, world!_(parentheses)" +} +array(4) { + [0]=> + string(54) "this is a_list: value1, Test__, string; Hello, world!_" + [1]=> + string(1) "(" + [2]=> + string(11) "parentheses" + [3]=> + string(1) ")" +} +array(1) { + [0]=> + string(67) "this is a_list: value1, Test__, string; Hello, world!_(parentheses)" +} +array(10) { + [0]=> + string(1) " " + [1]=> + string(1) " " + [2]=> + string(2) ": " + [3]=> + string(2) ", " + [4]=> + string(2) ", " + [5]=> + string(2) "; " + [6]=> + string(2) ", " + [7]=> + string(1) "!" + [8]=> + string(1) "(" + [9]=> + string(1) ")" +} \ No newline at end of file diff --git a/ext/pcre/tests/preg_split_error.phpt b/ext/pcre/tests/preg_split_error.phpt new file mode 100644 index 0000000000..960b286c91 --- /dev/null +++ b/ext/pcre/tests/preg_split_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test preg_split() function : error conditions - incorrect number of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_split() : error conditions *** + +-- Testing preg_split() function with Zero arguments -- + +Warning: preg_split() expects at least 2 parameters, 0 given in %spreg_split_error.php on line %d +bool(false) + +-- Testing preg_split() function with more than expected no. of arguments -- + +Warning: preg_split() expects at most 4 parameters, 5 given in %spreg_split_error.php on line %d +bool(false) + +-- Testing preg_split() function with less than expected no. of arguments -- + +Warning: preg_split() expects at least 2 parameters, 1 given in %spreg_split_error.php on line %d +bool(false) +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_split_error1.phpt b/ext/pcre/tests/preg_split_error1.phpt new file mode 100644 index 0000000000..79942a9480 --- /dev/null +++ b/ext/pcre/tests/preg_split_error1.phpt @@ -0,0 +1,67 @@ +--TEST-- +Test preg_split() function : error conditions - bad regular expressions +--FILE-- + +--EXPECTF-- +*** Testing preg_split() : error conditions *** + +Arg value is abcdef + +Warning: preg_split(): Delimiter must not be alphanumeric or backslash in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z] + +Warning: preg_split(): No ending delimiter '/' found in %spreg_split_error1.php on line %d +bool(false) + +Arg value is [a-zA-Z]/ + +Warning: preg_split(): Unknown modifier '/' in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/F + +Warning: preg_split(): Unknown modifier 'F' in %spreg_split_error1.php on line %d +bool(false) + +Arg value is Array + +Warning: preg_split() expects parameter 1 to be string, array given in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/ +array(3) { + [0]=> + string(4) "1 2 " + [1]=> + string(5) " 3 4 " + [2]=> + string(4) " 5 6" +} + +Warning: preg_split() expects parameter 1 to be string, object given in %spreg_split_error1.php on line %d +bool(false) diff --git a/ext/pcre/tests/preg_split_error2.phpt b/ext/pcre/tests/preg_split_error2.phpt new file mode 100644 index 0000000000..e08182177f --- /dev/null +++ b/ext/pcre/tests/preg_split_error2.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test preg_split() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_split() : error conditions *** + +Arg value is: Array + +Warning: preg_split() expects parameter 2 to be string, array given in %spreg_split_error2.php on line %d +bool(false) + +Warning: preg_split() expects parameter 2 to be string, object given in %spreg_split_error2.php on line %d +bool(false) +Done \ No newline at end of file -- 2.40.0