1
0
mirror of https://github.com/php/php-src.git synced 2026-03-30 20:22:36 +02:00
Files
archived-php-src/ext/standard/tests/strings/chunk_split_variation6.phpt
Peter Kokot d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00

77 lines
2.4 KiB
PHP

--TEST--
Test chunk_split() function : usage variations - single quoted strings for 'str' argument
--FILE--
<?php
/* Prototype : string chunk_split(string $str [, int $chunklen [, string $ending]])
* Description: Returns split line
* Source code: ext/standard/string.c
* Alias to functions: none
*/
/*
* passing different single quoted strings as 'str' argument to the function
* 'chunklen' is set to 7 and 'ending' is '):('
*/
echo "*** Testing chunk_split() : with different single quoted 'str' ***\n";
//Initializing variables
$chunklen = 7;
$ending = "):(";
//different single quoted string for 'str'
$values = array(
'', //empty
' ', //space
'This is simple string', //regular string
'It\'s string with quotes',
'This contains @ # $ % ^ & chars', //special characters
'This string\tcontains\rwhite space\nchars', //with white space chars
'This is string with 1234 numbers',
'This is string with \0 and ".chr(0)."null chars', //for binary safe
'This is string with multiple space char',
'This is to check string with ()',
' Testing with multiple spaces ',
'Testing invalid \k and \m escape char',
'This is to check with \\n and \\t'
);
//Loop through each element of values for 'str'
for($count = 0;$count < count($values);$count++) {
echo "-- Iteration $count --\n";
var_dump( chunk_split($values[$count], $chunklen, $ending) );
}
echo "Done"
?>
--EXPECT--
*** Testing chunk_split() : with different single quoted 'str' ***
-- Iteration 0 --
string(3) "):("
-- Iteration 1 --
string(4) " ):("
-- Iteration 2 --
string(30) "This is):( simple):( string):("
-- Iteration 3 --
string(35) "It's st):(ring wi):(th quot):(es):("
-- Iteration 4 --
string(46) "This co):(ntains ):(@ # $ %):( ^ & ch):(ars):("
-- Iteration 5 --
string(59) "This st):(ring\tc):(ontains):(\rwhite):( space\):(nchars):("
-- Iteration 6 --
string(47) "This is):( string):( with 1):(234 num):(bers):("
-- Iteration 7 --
string(68) "This is):( string):( with \):(0 and "):(.chr(0)):(."null ):(chars):("
-- Iteration 8 --
string(74) "This is):( string):( with ):( multi):(ple ):( sp):(ace cha):(r):("
-- Iteration 9 --
string(46) "This is):( to che):(ck stri):(ng with):( ()):("
-- Iteration 10 --
string(59) " Te):(sting w):(ith ):(multipl):(e space):(s ):("
-- Iteration 11 --
string(55) "Testing):( invali):(d \k an):(d \m es):(cape ch):(ar):("
-- Iteration 12 --
string(46) "This is):( to che):(ck with):( \n and):( \t):("
Done