Annotation of embedaddon/php/ext/standard/tests/strings/wordwrap_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test wordwrap() function : error conditions
3: --FILE--
4: <?php
5: /* Prototype : string wordwrap ( string $str [, int $width [, string $break [, bool $cut]]] )
6: * Description: Wraps buffer to selected number of characters using string break char
7: * Source code: ext/standard/string.c
8: */
9:
10: echo "*** Testing wordwrap() : error conditions ***\n";
11:
12: // Zero argument
13: echo "\n-- Testing wordwrap() function with Zero arguments --\n";
14: var_dump( wordwrap() );
15:
16: // More than expected number of arguments
17: echo "\n-- Testing wordwrap() function with more than expected no. of arguments --\n";
18: $str = 'testing wordwrap function';
19: $width = 10;
20: $break = '<br />\n';
21: $cut = true;
22: $extra_arg = "extra_arg";
23:
24: var_dump( wordwrap($str, $width, $break, $cut, $extra_arg) );
25:
26: // $width arg as negative value
27: echo "\n-- Testing wordwrap() function with negative/zero value for width argument --\n";
28: echo "-- width = 0 & cut = false --\n";
29: // width as zero and cut as false
30: $width = 0;
31: $cut = false;
32: var_dump( wordwrap($str, $width, $break, $cut) );
33:
34: echo "-- width = 0 & cut = true --\n";
35: // width as zero and cut as true
36: $width = 0;
37: $cut = true;
38: var_dump( wordwrap($str, $width, $break, $cut) );
39:
40: echo "-- width = -10 & cut = false --\n";
41: // width as -ne and cut as false
42: $width = -10;
43: $cut = false;
44: var_dump( wordwrap($str, $width, $break, $cut) );
45:
46: echo "-- width = -10 & cut = true --\n";
47: // width as -ne and cut as true
48: $width = -10;
49: $cut = true;
50: var_dump( wordwrap($str, $width, $break, $cut) );
51:
52: echo "Done\n";
53: ?>
54: --EXPECTF--
55: *** Testing wordwrap() : error conditions ***
56:
57: -- Testing wordwrap() function with Zero arguments --
58:
59: Warning: wordwrap() expects at least 1 parameter, 0 given in %s on line %d
60: NULL
61:
62: -- Testing wordwrap() function with more than expected no. of arguments --
63:
64: Warning: wordwrap() expects at most 4 parameters, 5 given in %s on line %d
65: NULL
66:
67: -- Testing wordwrap() function with negative/zero value for width argument --
68: -- width = 0 & cut = false --
69: string(39) "testing<br />\nwordwrap<br />\nfunction"
70: -- width = 0 & cut = true --
71:
72: Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
73: bool(false)
74: -- width = -10 & cut = false --
75: string(39) "testing<br />\nwordwrap<br />\nfunction"
76: -- width = -10 & cut = true --
77: string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
78: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>