1--TEST--
2Test vprintf() function : usage variations - octal formats with octal 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 octal formats and octal values are passed to
11 * the '$format' and '$args' arguments of the function
12*/
13
14echo "*** Testing vprintf() : octal formats with octal values ***\n";
15
16// defining array of octal formats
17$formats = array(
18  "%o",
19  "%+o %-o",
20  "%lo %4o %-4o",
21  "%10.4o %-10.4o %04o %04.4o",
22  "%'#2o %'2o %'$2o %'_2o",
23  "%o %o %o %o",
24  "%% %%o",
25  '%3$o %4$o %1$o %2$o'
26);
27
28// Arrays of octal values for the format defined in $format.
29// Each sub array contains octal values which correspond to each format string in $format
30$args_array = array(
31  array(00),
32  array(-01, 01),
33  array(-020000000000, 017777777777, -017777777777),
34  array(0123456, 01234567, -01234567, 01234567),
35  array(0111, 02222, -0333333, -044444444),
36  array(0x123b, 0xfAb, 0123, 012),
37  array(01234, 0567),
38  array(03, 04, 01, 02)
39
40);
41
42// looping to test vprintf() with different octal formats from the above $formats 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() : octal formats with octal values ***
56
57-- Iteration 1 --
580
59int(1)
60
61-- Iteration 2 --
6237777777777 1
63int(13)
64
65-- Iteration 3 --
6620000000000 17777777777 20000000001
67int(35)
68
69-- Iteration 4 --
70                      37776543211 0000
71int(38)
72
73-- Iteration 5 --
74111 2222 37777444445 37733333334
75int(32)
76
77-- Iteration 6 --
7811073 7653 123 12
79int(17)
80
81-- Iteration 7 --
82% %o
83int(4)
84
85-- Iteration 8 --
861 2 3 4
87int(7)
88