2
Test vprintf() function : usage variations - hexa formats with non-hexa values
5
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
9
/* Prototype : string vprintf(string format, array args)
10
* Description: Output a formatted string
11
* Source code: ext/standard/formatted_print.c
15
* Test vprintf() when different hexa formats and non-hexa values are passed to
16
* the '$format' and '$args' arguments of the function
19
echo "*** Testing vprintf() : hexa formats and non-hexa values ***\n";
21
// defining array of different hexa formats
26
%\'#2x %\'2x %\'$2x %\'_2x
29
// Arrays of non hexa values for the format defined in $format.
30
// Each sub array contains non hexa values which correspond to each format in $format
33
// array of float values
35
123456.234, 123456.234, -1234.6789, +1234.6789,
37
12345.780, 12.000000011111, -12.00000111111, -123456.234,
38
3.33, +4.44, 1.11,-2.22 ),
40
// array of int values
42
123456, 123456234, -12346789, +12346789,
43
123200, +20000, 22212,
44
12345780, 1211111, -12111111, -12345634,
48
array(" ", ' ', 'hello',
49
'123hello', "123hello", '-123hello', '+123hello',
50
"\12345678hello", "-\12345678hello", 'h123456ello',
51
"1234hello", "hello\0world", "NULL", "true",
55
array( array(0), array(1, 2), array(-1, -1),
56
array("123"), array('123'), array('-123'), array("-123"),
57
array(true), array(TRUE), array(FALSE),
58
array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
59
array("3"), array("4"), array("1"), array("2") ),
61
// array of boolean data
62
array( true, TRUE, false,
70
// looping to test vprintf() with different hexa formats from the above $format array
71
// and with non-hexa values from the above $args_array array
74
foreach($args_array as $args) {
75
echo "\n-- Iteration $counter --\n";
76
$result = vprintf($formats, $args);
85
*** Testing vprintf() : hexa formats and non-hexa values ***
91
3039 c fffffff4 fffe1dc0
97
1e240 x ff439a5b bc65a5
99
bc61b4 127ae7 ff4732f9 ff439ede