1--TEST--
2Test vprintf() function : usage variations - unsigned formats with unsigned 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 unsigned values
11 * are passed to the '$format' and '$args' arguments of the function
12*/
13
14echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n";
15
16// defining array of unsigned formats
17$formats = array(
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
25// Arrays of unsigned values for the format defined in $format.
26// Each sub array contains unsigned values which correspond to each format string in $format
27$args_array = array(
28  array(1234567, 01234567, 0 ),
29  array(12345678900, 1234, 12345),
30  array("1234000", 10.1234567e10, 1.2e2),
31  array(1, 0, 00, "10_"),
32  array(3, 4, 1, 2)
33);
34
35// looping to test vprintf() with different unsigned formats from the above $format array
36// and with signed and other types of  values from the above $args_array array
37$counter = 1;
38foreach($formats as $format) {
39  echo "\n-- Iteration $counter --\n";
40  $result = vprintf($format, $args_array[$counter-1]);
41  echo "\n";
42  var_dump($result);
43  $counter++;
44}
45
46?>
47--EXPECT--
48*** Testing vprintf() : unsigned formats and unsigned values ***
49
50-- Iteration 1 --
511234567 342391 0
52int(16)
53
54-- Iteration 2 --
553755744308 1234 12345
56int(21)
57
58-- Iteration 3 --
59   1234000 2450319192 120
60int(25)
61
62-- Iteration 4 --
63#1 0 $0 10
64int(10)
65
66-- Iteration 5 --
671 2 3 4
68int(7)
69