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/*
10* passsing different integer values for 'chunklen' argument to chunk_split()
11* 'ending' is set to '||'
12*/
13
14echo "*** Testing chunk_split() : different integer values for 'chunklen' ***\n";
15
16 //Initializing variables
17$ending = "||";
18$str = "This contains\tand special char & numbers 123.\nIt also checks for \0 char";
19
20// different values for chunklen
21$values = array (
22  0,
23  1,
24  -123,  //negative integer
25  0234,  //octal number
26  0x1A,  //hexadecimal number
27  PHP_INT_MAX,  //max positive integer number
28  PHP_INT_MAX * 3,  //integer overflow
29  -PHP_INT_MAX - 1,  //min negative integer
30
31);
32
33for($count = 0; $count < count($values); $count++) {
34  echo "-- Iteration $count --\n";
35  try {
36    var_dump( chunk_split($str, $values[$count], $ending) );
37  } catch (TypeError $e) {
38    echo $e->getMessage(), "\n";
39  } catch (\ValueError $e) {
40      echo $e->getMessage() . "\n";
41  }
42}
43
44?>
45--EXPECTF--
46*** Testing chunk_split() : different integer values for 'chunklen' ***
47-- Iteration 0 --
48chunk_split(): Argument #2 ($length) must be greater than 0
49-- Iteration 1 --
50string(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||.||
51||I||t|| ||a||l||s||o|| ||c||h||e||c||k||s|| ||f||o||r|| ||%0|| ||c||h||a||r||"
52-- Iteration 2 --
53chunk_split(): Argument #2 ($length) must be greater than 0
54-- Iteration 3 --
55string(73) "This contains	and special char & numbers 123.
56It also checks for %0 char||"
57-- Iteration 4 --
58string(77) "This contains	and special ||char & numbers 123.
59It als||o checks for %0 char||"
60-- Iteration 5 --
61string(73) "This contains	and special char & numbers 123.
62It also checks for %0 char||"
63-- Iteration 6 --
64chunk_split(): Argument #2 ($length) must be of type int, float given
65-- Iteration 7 --
66chunk_split(): Argument #2 ($length) must be greater than 0
67