1--TEST--
2Test vsprintf() 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 vsprintf(string format, array args)
10 * Description: Return a formatted string
11 * Source code: ext/standard/formatted_print.c
12*/
13
14/*
15 * Test vsprintf() when different unsigned formats and unsigned values
16 * are passed to the '$format' and '$args' arguments of the function
17*/
18
19echo "*** Testing vsprintf() : 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 vsprintf() 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  var_dump( vsprintf($format, $args_array[$counter-1]) );
46  $counter++;
47}
48
49echo "Done";
50?>
51--EXPECTF--
52*** Testing vsprintf() : unsigned formats and unsigned values ***
53
54-- Iteration 1 --
55string(16) "1234567 342391 0"
56
57-- Iteration 2 --
58string(24) "12345678900 u 1234 12345"
59
60-- Iteration 3 --
61string(34) "   1234000 3875820019684212736 120"
62
63-- Iteration 4 --
64string(10) "#1 0 $0 10"
65
66-- Iteration 5 --
67string(7) "1 2 3 4"
68Done
69