1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00
Files
archived-php-src/ext/standard/tests/array/array_change_key_case_variation8.phpt
Peter Kokot b746e69887 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:32:30 +02:00

133 lines
2.2 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
--TEST--
Test array_change_key_case() function : usage variations - Different strings as keys
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die("skip Output tested contains chars that are not shown the same on windows concole (ESC and co)");
}
--FILE--
<?php
/* Prototype : array array_change_key_case(array $input [, int $case])
* Description: Retuns an array with all string keys lowercased [or uppercased]
* Source code: ext/standard/array.c
*/
/*
* Test how array_change_key_case() behaves with different strings
*/
echo "*** Testing array_change_key_case() : usage variations ***\n";
$inputs = array (
// group of escape sequences
array(null => 1, NULL => 2, "\a" => 3, "\cx" => 4, "\e" => 5, "\f" => 6, "\n" => 7, "\t" => 8, "\xhh" => 9, "\ddd" => 10, "\v" => 11),
// array contains combination of capital/small letters
array("lemoN" => 1, "Orange" => 2, "banana" => 3, "apple" => 4, "Test" => 5, "TTTT" => 6, "ttt" => 7, "ww" => 8, "x" => 9, "X" => 10, "oraNGe" => 11, "BANANA" => 12)
);
foreach($inputs as $input) {
echo "\n-- \$case = default --\n";
var_dump(array_change_key_case($input));
echo "-- \$case = upper --\n";
var_dump(array_change_key_case($input, CASE_UPPER));
}
echo "Done";
?>
--EXPECT--
*** Testing array_change_key_case() : usage variations ***
-- $case = default --
array(10) {
[""]=>
int(2)
["\a"]=>
int(3)
["\cx"]=>
int(4)
[""]=>
int(5)
[" "]=>
int(6)
["
"]=>
int(7)
[" "]=>
int(8)
["\xhh"]=>
int(9)
["\ddd"]=>
int(10)
[" "]=>
int(11)
}
-- $case = upper --
array(10) {
[""]=>
int(2)
["\A"]=>
int(3)
["\CX"]=>
int(4)
[""]=>
int(5)
[" "]=>
int(6)
["
"]=>
int(7)
[" "]=>
int(8)
["\XHH"]=>
int(9)
["\DDD"]=>
int(10)
[" "]=>
int(11)
}
-- $case = default --
array(9) {
["lemon"]=>
int(1)
["orange"]=>
int(11)
["banana"]=>
int(12)
["apple"]=>
int(4)
["test"]=>
int(5)
["tttt"]=>
int(6)
["ttt"]=>
int(7)
["ww"]=>
int(8)
["x"]=>
int(10)
}
-- $case = upper --
array(9) {
["LEMON"]=>
int(1)
["ORANGE"]=>
int(11)
["BANANA"]=>
int(12)
["APPLE"]=>
int(4)
["TEST"]=>
int(5)
["TTTT"]=>
int(6)
["TTT"]=>
int(7)
["WW"]=>
int(8)
["X"]=>
int(10)
}
Done