1--TEST--
2Test vprintf() function : usage variations - unsigned formats with unsigned 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/* Prototype  : string vprintf(string format, array args)
10 * Description: Output a formatted string
11 * Source code: ext/standard/formatted_print.c
12*/
13
14/*
15 * Test vprintf() when different unsigned formats and unsigned values
16 * are passed to the '$format' and '$args' arguments of the function
17*/
18
19echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n";
20
21// defining array of unsigned formats
22$formats = array(
23  '%u %+u %-u',
24  '%lu %Lu %4u %-4u',
25  '%10.4u %-10.4u %.4u',
26  '%\'#2u %\'2u %\'$2u %\'_2u',
27  '%3$u %4$u %1$u %2$u'
28);
29
30// Arrays of unsigned values for the format defined in $format.
31// Each sub array contains unsigned values which correspond to each format string in $format
32$args_array = array(
33  array(1234567, 01234567, 0 ),
34  array(12345678900, 12345678900, 1234, 12345),
35  array("1234000", 10e20, 1.2e2),
36  array(1, 0, 00, "10_"),
37  array(3, 4, 1, 2)
38);
39
40// looping to test vprintf() with different unsigned formats from the above $format array
41// and with signed and other types of  values from the above $args_array array
42$counter = 1;
43foreach($formats as $format) {
44  echo "\n-- Iteration $counter --\n";
45  $result =  vprintf($format, $args_array[$counter-1]);
46  echo "\n";
47  var_dump($result);
48  $counter++;
49}
50
51?>
52===DONE===
53--EXPECTF--
54*** Testing vprintf() : unsigned formats and unsigned values ***
55
56-- Iteration 1 --
571234567 342391 0
58int(16)
59
60-- Iteration 2 --
6112345678900 u 1234 12345
62int(24)
63
64-- Iteration 3 --
65   1234000 3875820019684212736 120
66int(34)
67
68-- Iteration 4 --
69#1 0 $0 10
70int(10)
71
72-- Iteration 5 --
731 2 3 4
74int(7)
75===DONE===
76