1--TEST-- 2Test vprintf() function : usage variations - unsigned formats with signed and other types of values 3--SKIPIF-- 4<?php 5if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); 6?> 7--FILE-- 8<?php 9/* 10 * Test vprintf() when different unsigned formats and signed values and other types of values 11 * are passed to the '$format' and '$args' arguments of the function 12*/ 13 14echo "*** Testing vprintf() : unsigned formats and signed & other types of values ***\n"; 15 16// defining array of unsigned formats 17$formats = 18 '%u %+u %-u 19 %lu %4u %-4u 20 %10.4u %-10.4u %.4u 21 %\'#2u %\'2u %\'$2u %\'_2u 22 %3$u %4$u %1$u %2$u'; 23 24// Arrays of signed and other type of values for the format defined in $format. 25// Each sub array contains signed 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, +123456.234, +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 strings 36 array(" ", ' ', 'hello', 37 '123hello', '-123hello', '+123hello', 38 "\12345678hello", "-\12345678hello", 'h123456ello', 39 "1234hello", "hello\0world", "NULL", "true", 40 "3", "4", '1', '2'), 41 42 // different arrays 43 array( array(0), array(1, 2), array(-1, -1), 44 array("123"), array('-123'), array("-123"), 45 array(true), array(TRUE), array(FALSE), 46 array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"), 47 array("3"), array("4"), array("1"), array("2") ), 48 49 // array of boolean data 50 array( true, TRUE, false, 51 TRUE, FALSE, 1, 52 true, TRUE, FALSE, 53 0, 1, 1, 0, 54 1, TRUE, 0, FALSE), 55 56); 57 58// looping to test vprintf() with different unsigned formats from the above $format array 59// and with signed and other types of values from the above $args_array array 60$counter = 1; 61foreach($args_array as $args) { 62 echo "\n-- Iteration $counter --\n"; 63 $result = vprintf($formats, $args); 64 echo "\n"; 65 var_dump($result); 66 $counter++; 67} 68?> 69--EXPECT-- 70*** Testing vprintf() : unsigned formats and signed & other types of values *** 71 72-- Iteration 1 -- 732 0 10 74 123456 123456 1234 75 2820130816 2840207360 1177509888 76 12345 12 4294967284 4294843840 77 10 123456 2 0 78int(115) 79 80-- Iteration 2 -- 810 0 0 82 123 4294967173 123 83 0 0 0 84 1234 0 $0 _0 85 0 123 0 0 86int(84) 87 88-- Iteration 3 -- 891 1 1 90 1 1 1 91 1 1 1 92 #1 1 $1 _1 93 1 1 1 1 94int(72) 95 96-- Iteration 4 -- 971 1 0 98 1 0 1 99 1 1 0 100 #0 1 $1 _0 101 0 1 1 1 102int(72) 103