1--TEST-- 2Test vprintf() function : usage variations - hexa formats with 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 hexa values are passed to 11 * the '$format' and '$args' arguments of the function 12*/ 13 14echo "*** Testing vprintf() : hexa formats with hexa values ***\n"; 15 16// defining array of different hexa formats 17$formats = array( 18 "%x", 19 "%+x %-x %X", 20 "%lx %4x %-4x", 21 "%10.4x %-10.4x %04x %04.4x", 22 "%'#2x %'2x %'$2x %'_2x", 23 "%x %x %x %x", 24 "% %%x", 25 '%3$x %4$x %1$x %2$x' 26); 27 28// Arrays of hexa values for the format defined in $format. 29// Each sub array contains hexa values which correspond to each format string in $format 30$args_array = array( 31 array(0x0), 32 array(-0x1, 0x1, +0x22), 33 array(0x7FFFFFFF, +0x7000000, -0x80000000), 34 array(123456, 12345678, -1234567, 1234567), 35 array(1, 0x2222, 0333333, -0x44444444), 36 array(0x123b, 0xfAb, "0xaxz", 012), 37 array(0x1234, 0x34), 38 array(0x3, 0x4, 0x1, 0x2) 39 40); 41 42// looping to test vprintf() with different char octal from the above $format array 43// and with octal values from the above $args_array array 44$counter = 1; 45foreach($formats as $format) { 46 echo "\n-- Iteration $counter --\n"; 47 $result = vprintf($format, $args_array[$counter-1]); 48 echo "\n"; 49 var_dump($result); 50 $counter++; 51} 52 53?> 54--EXPECT-- 55*** Testing vprintf() : hexa formats with hexa values *** 56 57-- Iteration 1 -- 580 59int(1) 60 61-- Iteration 2 -- 62ffffffffffffffff 1 22 63int(21) 64 65-- Iteration 3 -- 667fffffff 7000000 ffffffff80000000 67int(33) 68 69-- Iteration 4 -- 70 ffffffffffed2979 0000 71int(43) 72 73-- Iteration 5 -- 74#1 2222 1b6db ffffffffbbbbbbbc 75int(30) 76 77-- Iteration 6 -- 78123b fab 0 a 79int(12) 80 81-- Iteration 7 -- 82%34 83int(3) 84 85-- Iteration 8 -- 861 2 3 4 87int(7) 88