Annotation of embedaddon/php/ext/standard/tests/strings/chunk_split_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test chunk_split() function : usage variations - different integer values for 'chunklen' argument(Bug#42796)
3: --SKIPIF--
4: <?php
5: if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6: ?>
7: --FILE--
8: <?php
9: /* Prototype : string chunk_split(string $str [, int $chunklen [, string $ending]])
10: * Description: Returns split line
11: * Source code: ext/standard/string.c
12: * Alias to functions: none
13: */
14:
15: /*
16: * passsing different integer values for 'chunklen' argument to chunk_split()
17: * 'ending' is set to '||'
18: */
19:
20: echo "*** Testing chunk_split() : different integer values for 'chunklen' ***\n";
21:
22: //Initializing variables
23: $ending = "||";
24: $str = "This contains\tand special char & numbers 123.\nIt also checks for \0 char";
25:
26: // different values for chunklen
27: $values = array (
28: 0,
29: 1,
30: -123, //negative integer
31: 0234, //octal number
32: 0x1A, //hexadecimal number
33: PHP_INT_MAX, //max positive integer number
34: PHP_INT_MAX * 3, //integer overflow
35: -PHP_INT_MAX - 1, //min negative integer
36:
37: );
38:
39: for($count = 0; $count < count($values); $count++) {
40: echo "-- Iteration $count --\n";
41: var_dump( chunk_split($str, $values[$count], $ending) );
42: }
43:
44: echo "Done"
45: ?>
46: --EXPECTF--
47: *** Testing chunk_split() : different integer values for 'chunklen' ***
48: -- Iteration 0 --
49:
50: Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
51: bool(false)
52: -- Iteration 1 --
53: string(213) "T||h||i||s|| ||c||o||n||t||a||i||n||s|| ||a||n||d|| ||s||p||e||c||i||a||l|| ||c||h||a||r|| ||&|| ||n||u||m||b||e||r||s|| ||1||2||3||.||
54: ||I||t|| ||a||l||s||o|| ||c||h||e||c||k||s|| ||f||o||r|| || || ||c||h||a||r||"
55: -- Iteration 2 --
56:
57: Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
58: bool(false)
59: -- Iteration 3 --
60: string(73) "This contains and special char & numbers 123.
61: It also checks for char||"
62: -- Iteration 4 --
63: string(77) "This contains and special ||char & numbers 123.
64: It als||o checks for char||"
65: -- Iteration 5 --
66: string(73) "This contains and special char & numbers 123.
67: It also checks for char||"
68: -- Iteration 6 --
69:
70: Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
71: bool(false)
72: -- Iteration 7 --
73:
74: Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
75: bool(false)
76: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>