1--TEST--
2Test vfprintf() function : usage variations - with whitespaces in format strings
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  : int vfprintf  ( resource $handle  , string $format , array $args  )
10 * Description: Write a formatted string to a stream
11 * Source code: ext/standard/formatted_print.c
12*/
13
14echo "*** Testing vfprintf() : with  white spaces in format strings ***\n";
15
16// initializing the format array
17$formats = array(
18  "% d  %  d  %   d",
19  "% f  %  f  %   f",
20  "% F  %  F  %   F",
21  "% b  %  b  %   b",
22  "% c  %  c  %   c",
23  "% e  %  e  %   e",
24  "% u  %  u  %   u",
25  "% o  %  o  %   o",
26  "% x  %  x  %   x",
27  "% X  %  X  %   X",
28  "% E  %  E  %   E"
29);
30
31// initializing the args array
32
33$args_array = array(
34  array(111, 222, 333),
35  array(1.1, .2, -0.6),
36  array(1.12, -1.13, +0.23),
37  array(1, 2, 3),
38  array(65, 66, 67),
39  array(2e1, 2e-1, -2e1),
40  array(-11, +22, 33),
41  array(012, -02394, +02389),
42  array(0x11, -0x22, +0x33),
43  array(0x11, -0x22, +0x33),
44  array(2e1, 2e-1, -2e1)
45);
46
47
48/* creating dumping file */
49$data_file = dirname(__FILE__) . '/vfprintf_variation19_64bit.txt';
50if (!($fp = fopen($data_file, 'wt')))
51   return;
52
53// looping to test vfprintf() with different scientific formats from the above $format array
54// and with non-scientific values from the above $args_array array
55$counter = 1;
56foreach($formats as $format) {
57  fprintf($fp, "\n-- Iteration %d --\n",$counter);
58  vfprintf($fp,$format, $args_array[$counter-1]);
59  $counter++;
60}
61
62fclose($fp);
63print_r(file_get_contents($data_file));
64echo "\n";
65
66unlink($data_file);
67?>
68===DONE===
69--EXPECT--
70*** Testing vfprintf() : with  white spaces in format strings ***
71
72-- Iteration 1 --
73111  222  333
74-- Iteration 2 --
751.100000  0.200000  -0.600000
76-- Iteration 3 --
771.120000  -1.130000  0.230000
78-- Iteration 4 --
791  10  11
80-- Iteration 5 --
81A  B  C
82-- Iteration 6 --
832.000000e+1  2.000000e-1  -2.000000e+1
84-- Iteration 7 --
8518446744073709551605  22  33
86-- Iteration 8 --
8712  1777777777777777777755  23
88-- Iteration 9 --
8911  ffffffffffffffde  33
90-- Iteration 10 --
9111  FFFFFFFFFFFFFFDE  33
92-- Iteration 11 --
932.000000E+1  2.000000E-1  -2.000000E+1
94===DONE===
95