From 5fee85753e395b357fef8e3cdfd2595d644b2c14 Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Sat, 17 Jan 2009 16:40:56 +0000 Subject: [PATCH] New trim() tests. Tested on Windows, Linux and Linux 64 bit --- ext/standard/tests/strings/trim_basic.phpt | 45 ++++++ ext/standard/tests/strings/trim_error.phpt | 61 ++++++++ .../tests/strings/trim_variation1.phpt | 138 ++++++++++++++++++ .../tests/strings/trim_variation2.phpt | 138 ++++++++++++++++++ 4 files changed, 382 insertions(+) create mode 100644 ext/standard/tests/strings/trim_basic.phpt create mode 100644 ext/standard/tests/strings/trim_error.phpt create mode 100644 ext/standard/tests/strings/trim_variation1.phpt create mode 100644 ext/standard/tests/strings/trim_variation2.phpt diff --git a/ext/standard/tests/strings/trim_basic.phpt b/ext/standard/tests/strings/trim_basic.phpt new file mode 100644 index 00000000000..c5e1e30a1a7 --- /dev/null +++ b/ext/standard/tests/strings/trim_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test trim() function : basic functionality +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing trim() : basic functionality *** + +-- Trim string with all white space characters -- +unicode(27) "---These are a few words---" + +-- Trim non-whitespace from a string -- +unicode(11) "Hello World" + +-- Trim some non-white space characters from a string -- +unicode(19) "!===Hello World===!" + +-- Trim the ASCII control characters at the beginning of a string -- +unicode(14) "Example string" +===DONE=== diff --git a/ext/standard/tests/strings/trim_error.phpt b/ext/standard/tests/strings/trim_error.phpt new file mode 100644 index 00000000000..43ac869b279 --- /dev/null +++ b/ext/standard/tests/strings/trim_error.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test trim() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing trim() : error conditions *** + +-- Testing trim() function with no arguments -- + +Warning: trim() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing trim() function with more than expected no. of arguments -- + +Warning: trim() expects at most 2 parameters, 3 given in %s on line %d +NULL + +-- Test trim function with various invalid charlists -- + +Warning: trim(): Invalid '..'-range, no character to the left of '..' in %s on line %d +unicode(14) " Hello World +" + +Warning: trim(): Invalid '..'-range, no character to the right of '..' in %s on line %d +unicode(14) " Hello World +" + +Warning: trim(): Invalid '..'-range, '..'-range needs to be incrementing in %s on line %d +unicode(14) " Hello World +" + +Warning: trim(): Invalid '..'-range in %s on line %d +unicode(14) " Hello World +" +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/trim_variation1.phpt b/ext/standard/tests/strings/trim_variation1.phpt new file mode 100644 index 00000000000..c42d138a41f --- /dev/null +++ b/ext/standard/tests/strings/trim_variation1.phpt @@ -0,0 +1,138 @@ +--TEST-- +Test trim() function : usage variations - test values for $str argument +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing trim() function: with unexpected inputs for 'str' argument *** +-- Iteration 1 -- +unicode(1) "0" +-- Iteration 2 -- +unicode(1) "1" +-- Iteration 3 -- +unicode(3) "255" +-- Iteration 4 -- +unicode(3) "256" +-- Iteration 5 -- +unicode(10) "2147483647" +-- Iteration 6 -- +unicode(10) "2147483648" +-- Iteration 7 -- +unicode(4) "10.5" +-- Iteration 8 -- +unicode(4) "20.5" +-- Iteration 9 -- +unicode(12) "101234567000" +-- Iteration 10 -- + +Warning: trim() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: trim() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: trim() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- +unicode(1) "1" +-- Iteration 14 -- +unicode(0) "" +-- Iteration 15 -- +unicode(1) "1" +-- Iteration 16 -- +unicode(0) "" +-- Iteration 17 -- +unicode(0) "" +-- Iteration 18 -- +unicode(0) "" +-- Iteration 19 -- +unicode(13) "sample object" +-- Iteration 20 -- + +Warning: trim() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 21 -- +unicode(0) "" +-- Iteration 22 -- +unicode(0) "" +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/trim_variation2.phpt b/ext/standard/tests/strings/trim_variation2.phpt new file mode 100644 index 00000000000..5166694f021 --- /dev/null +++ b/ext/standard/tests/strings/trim_variation2.phpt @@ -0,0 +1,138 @@ +--TEST-- +Test trim() function : usage variations - test values for $charlist argument +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing trim() function: with unexpected inputs for 'charlist' argument *** +-- Iteration 1 -- +unicode(19) "!---Hello World---!" +-- Iteration 2 -- +unicode(19) "!---Hello World---!" +-- Iteration 3 -- +unicode(19) "!---Hello World---!" +-- Iteration 4 -- +unicode(19) "!---Hello World---!" +-- Iteration 5 -- +unicode(19) "!---Hello World---!" +-- Iteration 6 -- +unicode(19) "!---Hello World---!" +-- Iteration 7 -- +unicode(19) "!---Hello World---!" +-- Iteration 8 -- +unicode(19) "!---Hello World---!" +-- Iteration 9 -- +unicode(19) "!---Hello World---!" +-- Iteration 10 -- + +Warning: trim() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: trim() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: trim() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- +unicode(19) "!---Hello World---!" +-- Iteration 14 -- +unicode(19) "!---Hello World---!" +-- Iteration 15 -- +unicode(19) "!---Hello World---!" +-- Iteration 16 -- +unicode(19) "!---Hello World---!" +-- Iteration 17 -- +unicode(19) "!---Hello World---!" +-- Iteration 18 -- +unicode(19) "!---Hello World---!" +-- Iteration 19 -- +unicode(19) "!---Hello World---!" +-- Iteration 20 -- + +Warning: trim() expects parameter 2 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 21 -- +unicode(19) "!---Hello World---!" +-- Iteration 22 -- +unicode(19) "!---Hello World---!" +===DONE=== \ No newline at end of file