1--TEST-- 2Test vprintf() function : usage variations - hexa formats with non-hexa values 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 * Test vprintf() when different hexa formats and non-hexa values are passed to 11 * the '$format' and '$args' arguments of the function 12*/ 13 14echo "*** Testing vprintf() : hexa formats and non-hexa values ***\n"; 15 16// defining array of different hexa formats 17$formats = 18 '%x %+x %-x 19 %lx %4x %-4x 20 %10.4x %-10.4x %.4x 21 %\'#2x %\'2x %\'$2x %\'_2x 22 %3$x %4$x %1$x %2$x'; 23 24// Arrays of non hexa values for the format defined in $format. 25// Each sub array contains non hexa values which correspond to each format in $format 26$args_array = array( 27 28 // array of float values 29 array(2.2, .2, 10.2, 30 123456.234, -1234.6789, +1234.6789, 31 2e10, +2e12, 22e+12, 32 12345.780, 12.000000011111, -12.00000111111, -123456.234, 33 3.33, +4.44, 1.11,-2.22 ), 34 35 // array of int values 36 array(2, -2, +2, 37 123456, -12346789, +12346789, 38 123200, +20000, 22212, 39 12345780, 1211111, -12111111, -12345634, 40 3, +4, 1,-2 ), 41 42 // array of strings 43 array(" ", ' ', 'hello', 44 '123hello', '-123hello', '+123hello', 45 "\12345678hello", "-\12345678hello", 'h123456ello', 46 "1234hello", "hello\0world", "NULL", "true", 47 "3", "4", '1', '2'), 48 49 // different arrays 50 array( array(0), array(1, 2), array(-1, -1), 51 array("123"), array('-123'), array("-123"), 52 array(true), array(TRUE), array(FALSE), 53 array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"), 54 array("3"), array("4"), array("1"), array("2") ), 55 56 // array of boolean data 57 array( true, TRUE, false, 58 TRUE, FALSE, 1, 59 true, TRUE, FALSE, 60 0, 1, 1, 0, 61 1, TRUE, 0, FALSE), 62 63); 64 65// looping to test vprintf() with different hexa formats from the above $format array 66// and with non-hexa values from the above $args_array array 67 68$counter = 1; 69foreach($args_array as $args) { 70 echo "\n-- Iteration $counter --\n"; 71 $result = vprintf($formats, $args); 72 echo "\n"; 73 var_dump($result); 74 $counter++; 75} 76 77?> 78--EXPECT-- 79*** Testing vprintf() : hexa formats and non-hexa values *** 80 81-- Iteration 1 -- 822 0 a 83 1e240 fffffffffffffb2e 4d2 84 85 3039 c fffffffffffffff4 fffffffffffe1dc0 86 a 1e240 2 0 87int(125) 88 89-- Iteration 2 -- 902 fffffffffffffffe 2 91 1e240 ffffffffff439a5b bc65a5 92 93 bc61b4 127ae7 ffffffffff4732f9 ffffffffff439ede 94 2 1e240 2 fffffffffffffffe 95int(164) 96 97-- Iteration 3 -- 980 0 0 99 7b ffffffffffffff85 7b 100 101 4d2 0 $0 _0 102 0 7b 0 0 103int(90) 104 105-- Iteration 4 -- 1061 1 1 107 1 1 1 108 109 #1 1 $1 _1 110 1 1 1 1 111int(75) 112 113-- Iteration 5 -- 1141 1 0 115 1 0 1 116 117 #0 1 $1 _0 118 0 1 1 1 119int(75) 120