Annotation of embedaddon/php/ext/standard/tests/strings/trim_error.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test trim() function : error conditions
3: --FILE--
4: <?php
5:
6: /* Prototype : string trim ( string $str [, string $charlist ] )
1.1.1.2 ! misho 7: * Description: Strip whitespace (or other characters) from the beginning and end of a string.
1.1 misho 8: * Source code: ext/standard/string.c
9: */
10:
11:
12: echo "*** Testing trim() : error conditions ***\n";
13:
14: echo "\n-- Testing trim() function with no arguments --\n";
15: var_dump( trim() );
16:
17: echo "\n-- Testing trim() function with more than expected no. of arguments --\n";
18: $extra_arg = 10;
19: var_dump( trim("Hello World", "Heo", $extra_arg) );
20:
21:
22: $hello = " Hello World\n";
23: echo "\n-- Test trim function with various invalid charlists --\n";
24: var_dump(trim($hello, "..a"));
25: var_dump(trim($hello, "a.."));
26: var_dump(trim($hello, "z..a"));
27: var_dump(trim($hello, "a..b..c"));
28:
29: ?>
30: ===DONE===
31: --EXPECTF--
32: *** Testing trim() : error conditions ***
33:
34: -- Testing trim() function with no arguments --
35:
36: Warning: trim() expects at least 1 parameter, 0 given in %s on line %d
37: NULL
38:
39: -- Testing trim() function with more than expected no. of arguments --
40:
41: Warning: trim() expects at most 2 parameters, 3 given in %s on line %d
42: NULL
43:
44: -- Test trim function with various invalid charlists --
45:
46: Warning: trim(): Invalid '..'-range, no character to the left of '..' in %s on line %d
47: string(14) " Hello World
48: "
49:
50: Warning: trim(): Invalid '..'-range, no character to the right of '..' in %s on line %d
51: string(14) " Hello World
52: "
53:
54: Warning: trim(): Invalid '..'-range, '..'-range needs to be incrementing in %s on line %d
55: string(14) " Hello World
56: "
57:
58: Warning: trim(): Invalid '..'-range in %s on line %d
59: string(14) " Hello World
60: "
61: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>