From 78846dab8643df78e11df00b71f1e4c76212e4f8 Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Mon, 17 Aug 2009 10:37:30 +0000 Subject: [PATCH] New basic string tests - includes back-porting a few existing tests back to 5.2. All tested on Windows, Linux and Linux 64 --- ext/standard/tests/strings/soundex_basic.phpt | 46 +++++++++++ ext/standard/tests/strings/soundex_error.phpt | 34 ++++++++ .../tests/strings/str_rot13_basic.phpt | 55 +++++++++++++ .../tests/strings/str_rot13_error.phpt | 32 ++++++++ .../tests/strings/strnatcasecmp_basic.phpt | 51 ++++++++++++ .../tests/strings/strnatcasecmp_error.phpt | 33 ++++++++ .../strings/strnatcasecmp_variation1.phpt | 56 +++++++++++++ .../tests/strings/strnatcmp_basic.phpt | 80 +++++++++++++++++++ .../tests/strings/strnatcmp_error.phpt | 34 ++++++++ ext/standard/tests/strings/strpbrk_basic.phpt | 41 ++++++++++ ext/standard/tests/strings/strpbrk_error.phpt | 57 +++++++++++++ 11 files changed, 519 insertions(+) create mode 100644 ext/standard/tests/strings/soundex_basic.phpt create mode 100644 ext/standard/tests/strings/soundex_error.phpt create mode 100644 ext/standard/tests/strings/str_rot13_basic.phpt create mode 100644 ext/standard/tests/strings/str_rot13_error.phpt create mode 100644 ext/standard/tests/strings/strnatcasecmp_basic.phpt create mode 100644 ext/standard/tests/strings/strnatcasecmp_error.phpt create mode 100644 ext/standard/tests/strings/strnatcasecmp_variation1.phpt create mode 100644 ext/standard/tests/strings/strnatcmp_basic.phpt create mode 100644 ext/standard/tests/strings/strnatcmp_error.phpt create mode 100644 ext/standard/tests/strings/strpbrk_basic.phpt create mode 100644 ext/standard/tests/strings/strpbrk_error.phpt diff --git a/ext/standard/tests/strings/soundex_basic.phpt b/ext/standard/tests/strings/soundex_basic.phpt new file mode 100644 index 0000000000..65bcb64252 --- /dev/null +++ b/ext/standard/tests/strings/soundex_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test soundex() function : basic functionality +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing soundex() : basic functionality *** +string(4) "E460" +string(4) "G200" +string(4) "H416" +string(4) "K530" +string(4) "L300" +string(4) "L222" +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) + +===DONE=== diff --git a/ext/standard/tests/strings/soundex_error.phpt b/ext/standard/tests/strings/soundex_error.phpt new file mode 100644 index 0000000000..119883b04d --- /dev/null +++ b/ext/standard/tests/strings/soundex_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test soundex() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing soundex error conditions ***-- Testing soundex() function with Zero arguments -- + +Warning: soundex() expects exactly 1 parameter, 0 given in %s on line %d +NULL + + +-- Testing soundex() function with more than expected no. of arguments -- + +Warning: soundex() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/str_rot13_basic.phpt b/ext/standard/tests/strings/str_rot13_basic.phpt new file mode 100644 index 0000000000..949d725754 --- /dev/null +++ b/ext/standard/tests/strings/str_rot13_basic.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test soundex() function : basic functionality +--FILE-- +.?"), "!%^&*()_-+={}[]:;@~#<,>.?")) { + echo "Strings equal : TEST PASSED\n"; +} else { + echo "Strings unequal : TEST FAILED\n"; +} + +echo "\nEnsure strings round trip\n"; +$str = "str_rot13() tests starting"; +$encode = str_rot13($str); +$decode = str_rot13($encode); +if (strcmp($str, $decode) == 0) { + echo "Strings equal : TEST PASSED\n"; +} else { + echo "Strings unequal : TEST FAILED\n"; +} +?> +===DONE=== +--EXPECTF-- +*** Testing str_rot13() : basic functionality *** + +Basic tests +string(26) "fge_ebg13() grfgf fgnegvat" +string(26) "nopqrstuvwxyzabcdefghijklm" + +Ensure numeric characters are left untouched +Strings equal : TEST PASSED + +Ensure non-alphabetic characters are left untouched +Strings unequal : TEST FAILED + +Ensure strings round trip +Strings equal : TEST PASSED +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/str_rot13_error.phpt b/ext/standard/tests/strings/str_rot13_error.phpt new file mode 100644 index 0000000000..8f27457392 --- /dev/null +++ b/ext/standard/tests/strings/str_rot13_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test str_rot13() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing str_rot13() : error conditions *** +-- Testing str_rot13() function with Zero arguments -- + +Warning: Wrong parameter count for str_rot13() in %s on line %d +NULL + + +-- Testing str_rot13() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for str_rot13() in %s on line %d +NULL +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/strnatcasecmp_basic.phpt b/ext/standard/tests/strings/strnatcasecmp_basic.phpt new file mode 100644 index 0000000000..ae5c9e6ae0 --- /dev/null +++ b/ext/standard/tests/strings/strnatcasecmp_basic.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test strnatcasecmp() function : basic functionality +--CREDITS-- +Felix De Vliegher +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing strnatcasecmp() : basic functionality *** +int(0) +int(-1) +int(1) +int(-1) +int(1) +int(0) +int(1) +int(1) +int(-1) +int(-1) +int(0) +int(-1) +int(0) +===DONE=== diff --git a/ext/standard/tests/strings/strnatcasecmp_error.phpt b/ext/standard/tests/strings/strnatcasecmp_error.phpt new file mode 100644 index 0000000000..e9ff57310d --- /dev/null +++ b/ext/standard/tests/strings/strnatcasecmp_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test strnatcasecmp() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing strnatcasecmp() : error conditions *** +-- Testing strnatcmp() function with Zero arguments -- + +Warning: Wrong parameter count for strnatcasecmp() in %s on line %d +NULL + + +-- Testing strnatcasecmp() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for strnatcasecmp() in %s on line %d +NULL +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/strnatcasecmp_variation1.phpt b/ext/standard/tests/strings/strnatcasecmp_variation1.phpt new file mode 100644 index 0000000000..9beea5d87b --- /dev/null +++ b/ext/standard/tests/strings/strnatcasecmp_variation1.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test strnatcasecmp() function : variation +--CREDITS-- +Felix De Vliegher +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing strnatcasecmp() : variation *** +int(1) +int(6) +int(-2) +int(-1) +int(0) +int(0) +===DONE=== diff --git a/ext/standard/tests/strings/strnatcmp_basic.phpt b/ext/standard/tests/strings/strnatcmp_basic.phpt new file mode 100644 index 0000000000..140bd48d6c --- /dev/null +++ b/ext/standard/tests/strings/strnatcmp_basic.phpt @@ -0,0 +1,80 @@ +--TEST-- +Test strnatcmp() function : basic functionality +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing strnatcmp() : basic functionality *** +Less than tests +int(-1) +int(-1) +int(-1) +int(-1) +int(-1) +int(1) +int(1) +int(1) +int(1) +int(1) +Equal too tests +int(0) +int(1) +Greater than tests +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/strnatcmp_error.phpt b/ext/standard/tests/strings/strnatcmp_error.phpt new file mode 100644 index 0000000000..c0701c6d39 --- /dev/null +++ b/ext/standard/tests/strings/strnatcmp_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test strnatcmp() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing strnatcmp() : error conditions *** +-- Testing strnatcmp() function with Zero arguments -- + +Warning: Wrong parameter count for strnatcmp() in %s on line %d +NULL + + +-- Testing strnatcmp() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for strnatcmp() in %s on line %d +NULL +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/strpbrk_basic.phpt b/ext/standard/tests/strings/strpbrk_basic.phpt new file mode 100644 index 0000000000..77585aa815 --- /dev/null +++ b/ext/standard/tests/strings/strpbrk_basic.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test strpbrk() function : basic functionality +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing strpbrk() : basic functionality *** +string(20) "is is a Simple text." +string(12) "Simple text." +bool(false) +bool(false) +bool(false) +string(12) " aaa aaaSLR" +string(1) "5" +string(1) "5" +===DONE=== diff --git a/ext/standard/tests/strings/strpbrk_error.phpt b/ext/standard/tests/strings/strpbrk_error.phpt new file mode 100644 index 0000000000..0abb208b4a --- /dev/null +++ b/ext/standard/tests/strings/strpbrk_error.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test strpbrk() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing strpbrk() : error conditions *** + +-- Testing strpbrk() function with more than expected no. of arguments -- + +Warning: strpbrk() expects exactly 2 parameters, 3 given in %s on line %d +bool(false) + +-- Testing strpbrk() function with less than expected no. of arguments -- + +Warning: strpbrk() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + +-- Testing strpbrk() function with empty second argument -- + +Warning: strpbrk(): The character list cannot be empty in %s on line %d +bool(false) + +-- Testing strpbrk() function with arrays -- + +Warning: strpbrk() expects parameter 2 to be string, array given in %s on line %d +bool(false) + +Warning: strpbrk() expects parameter 1 to be string, array given in %s on line %d +bool(false) +===DONE=== -- 2.50.1