1--TEST--
2Test chunk_split() function : usage variations - different integer values for 'chunklen' argument(Bug#42796)
3--SKIPIF--
4<?php
5if (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
20echo "*** 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
39for($count = 0; $count < count($values); $count++) {
40  echo "-- Iteration $count --\n";
41  var_dump( chunk_split($str, $values[$count], $ending) );
42}
43
44echo "Done"
45?>
46--EXPECTF--
47*** Testing chunk_split() : different integer values for 'chunklen' ***
48-- Iteration 0 --
49
50Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
51bool(false)
52-- Iteration 1 --
53string(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
57Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
58bool(false)
59-- Iteration 3 --
60string(73) "This contains	and special char & numbers 123.
61It also checks for � char||"
62-- Iteration 4 --
63string(77) "This contains	and special ||char & numbers 123.
64It als||o checks for � char||"
65-- Iteration 5 --
66string(73) "This contains	and special char & numbers 123.
67It also checks for � char||"
68-- Iteration 6 --
69
70Warning: chunk_split() expects parameter 2 to be int, float given in %s on line %d
71NULL
72-- Iteration 7 --
73
74Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
75bool(false)
76Done
77