Annotation of embedaddon/php/ext/standard/tests/strings/rtrim.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Testing rtrim() function
3: --FILE--
4: <?php
5:
6: /* Testing for Error conditions */
7:
8: /* Invalid Number of Arguments */
9:
10: echo "\n *** Output for Error Conditions ***\n";
11: rtrim();
12: rtrim("", " ", 1);
13:
14: /* Testing the Normal behaviour of rtrim() function */
15:
16: echo "\n *** Output for Normal Behaviour ***\n";
17: var_dump ( rtrim("rtrim test \t\0 ") ); /* without second Argument */
18: var_dump ( rtrim("rtrim test " , "") ); /* no characters in second Argument */
19: var_dump ( rtrim("rtrim test ", NULL) ); /* with NULL as second Argument */
20: var_dump ( rtrim("rtrim test ", true) ); /* with boolean value as second Argument */
21: var_dump ( rtrim("rtrim test ", " ") ); /* with single space as second Argument */
22: var_dump ( rtrim("rtrim test \t\n\r\0\x0B", "\t\n\r\0\x0B") ); /* with multiple escape sequences as second Argument */
23: var_dump ( rtrim("rtrim testABCXYZ", "A..Z") ); /* with characters range as second Argument */
24: var_dump ( rtrim("rtrim test0123456789", "0..9") ); /* with numbers range as second Argument */
25: var_dump ( rtrim("rtrim test$#@", "#@$") ); /* with some special characters as second Argument */
26:
27:
28: /* Use of class and objects */
29: echo "\n*** Checking with OBJECTS ***\n";
30: class string1 {
31: public function __toString() {
32: return "Object";
33: }
34: }
35: $obj = new string1;
36: var_dump( rtrim($obj, "tc") );
37:
38: /* String with embedded NULL */
39: echo "\n*** String with embedded NULL ***\n";
40: var_dump( rtrim("234\x0005678\x0000efgh\xijkl\x0n1", "\x0n1") );
41:
42: /* heredoc string */
43: $str = <<<EOD
44: us
45: ing heredoc string
46: EOD;
47:
48: echo "\n *** Using heredoc string ***\n";
49: var_dump( rtrim($str, "ing") );
50:
51: echo "Done\n";
52: ?>
53: --EXPECTF--
54: *** Output for Error Conditions ***
55:
56: Warning: rtrim() expects at least 1 parameter, 0 given in %s on line %d
57:
58: Warning: rtrim() expects at most 2 parameters, 3 given in %s on line %d
59:
60: *** Output for Normal Behaviour ***
61: string(10) "rtrim test"
62: string(13) "rtrim test "
63: string(18) "rtrim test "
64: string(18) "rtrim test "
65: string(10) "rtrim test"
66: string(11) "rtrim test "
67: string(10) "rtrim test"
68: string(10) "rtrim test"
69: string(10) "rtrim test"
70:
71: *** Checking with OBJECTS ***
72: string(4) "Obje"
73:
74: *** String with embedded NULL ***
75: string(22) "234 05678 00efgh\xijkl"
76:
77: *** Using heredoc string ***
78: string(18) "us
79: ing heredoc str"
80: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>