Annotation of embedaddon/php/ext/standard/tests/strings/strtok_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strtok() function : error conditions
3: --FILE--
4: <?php
5: /* Prototype : string strtok ( string $str, string $token )
6: * Description: splits a string (str) into smaller strings (tokens), with each token being delimited by any character from token
7: * Source code: ext/standard/string.c
8: */
9:
10: /*
11: * Testing strtok() for error conditions
12: */
13:
14: echo "*** Testing strtok() : error conditions ***\n";
15:
16: // Zero argument
17: echo "\n-- Testing strtok() function with Zero arguments --\n";
18: var_dump( strtok() );
19:
20: // More than expected number of arguments
21: echo "\n-- Testing strtok() function with more than expected no. of arguments --\n";
22: $str = 'sample string';
23: $token = ' ';
24: $extra_arg = 10;
25:
26: var_dump( strtok($str, $token, $extra_arg) );
27: var_dump( $str );
28:
29: // Less than expected number of arguments
30: echo "\n-- Testing strtok() with less than expected no. of arguments --\n";
31: $str = 'string val';
32:
33: var_dump( strtok($str));
34: var_dump( $str );
35:
36: echo "Done\n";
37: ?>
38: --EXPECTF--
39: *** Testing strtok() : error conditions ***
40:
41: -- Testing strtok() function with Zero arguments --
42:
43: Warning: strtok() expects at least 1 parameter, 0 given in %s on line %d
44: NULL
45:
46: -- Testing strtok() function with more than expected no. of arguments --
47:
48: Warning: strtok() expects at most 2 parameters, 3 given in %s on line %d
49: NULL
50: string(13) "sample string"
51:
52: -- Testing strtok() with less than expected no. of arguments --
53: bool(false)
54: string(10) "string val"
55: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>