mirror of
https://github.com/php/php-src.git
synced 2026-04-20 14:31:06 +02:00
This format matches against null bytes, and prevents the test expectation from being interpreted as binary data. bless_tests.php will automatically replace \0 with %0 as well.
130 lines
1.9 KiB
PHP
130 lines
1.9 KiB
PHP
--TEST--
|
|
Test sprintf() function : usage variations - char formats with char values
|
|
--FILE--
|
|
<?php
|
|
echo "*** Testing sprintf() : char formats with char values ***\n";
|
|
|
|
// array of char values
|
|
$char_values = array( 'a', "a", 67, -67, 99, ' ', '', 'A', "A" );
|
|
|
|
// array of char formats
|
|
$char_formats = array(
|
|
"%c", "%lc", " %c", "%c ",
|
|
"\t%c", "\n%c", "%4c", "%30c",
|
|
);
|
|
|
|
$count = 1;
|
|
foreach($char_values as $char_value) {
|
|
echo "\n-- Iteration $count --\n";
|
|
|
|
foreach($char_formats as $format) {
|
|
var_dump( sprintf($format, $char_value) );
|
|
}
|
|
$count++;
|
|
};
|
|
|
|
echo "Done";
|
|
?>
|
|
--EXPECTF--
|
|
*** Testing sprintf() : char formats with char values ***
|
|
|
|
-- Iteration 1 --
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
string(2) " %0"
|
|
string(2) "%0 "
|
|
string(2) " %0"
|
|
string(2) "
|
|
%0"
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
|
|
-- Iteration 2 --
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
string(2) " %0"
|
|
string(2) "%0 "
|
|
string(2) " %0"
|
|
string(2) "
|
|
%0"
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
|
|
-- Iteration 3 --
|
|
string(1) "C"
|
|
string(1) "C"
|
|
string(2) " C"
|
|
string(2) "C "
|
|
string(2) " C"
|
|
string(2) "
|
|
C"
|
|
string(1) "C"
|
|
string(1) "C"
|
|
|
|
-- Iteration 4 --
|
|
string(1) "½"
|
|
string(1) "½"
|
|
string(2) " ½"
|
|
string(2) "½ "
|
|
string(2) " ½"
|
|
string(2) "
|
|
½"
|
|
string(1) "½"
|
|
string(1) "½"
|
|
|
|
-- Iteration 5 --
|
|
string(1) "c"
|
|
string(1) "c"
|
|
string(2) " c"
|
|
string(2) "c "
|
|
string(2) " c"
|
|
string(2) "
|
|
c"
|
|
string(1) "c"
|
|
string(1) "c"
|
|
|
|
-- Iteration 6 --
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
string(2) " %0"
|
|
string(2) "%0 "
|
|
string(2) " %0"
|
|
string(2) "
|
|
%0"
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
|
|
-- Iteration 7 --
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
string(2) " %0"
|
|
string(2) "%0 "
|
|
string(2) " %0"
|
|
string(2) "
|
|
%0"
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
|
|
-- Iteration 8 --
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
string(2) " %0"
|
|
string(2) "%0 "
|
|
string(2) " %0"
|
|
string(2) "
|
|
%0"
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
|
|
-- Iteration 9 --
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
string(2) " %0"
|
|
string(2) "%0 "
|
|
string(2) " %0"
|
|
string(2) "
|
|
%0"
|
|
string(1) "%0"
|
|
string(1) "%0"
|
|
Done
|