1--TEST--
2Test vfprintf() 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  : 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
14/*
15 * Test vfprintf() when different unsigned formats and unsigned values
16 * are passed to the '$format' and '$args' arguments of the function
17*/
18
19echo "*** Testing vfprintf() : 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", 10.1234567e10, 1.2e2),
36  array(1, 0, 00, "10_"),
37  array(3, 4, 1, 2)
38);
39
40/* creating dumping file */
41$data_file = __DIR__ . '/vfprintf_variation15_64bit.txt';
42if (!($fp = fopen($data_file, 'wt')))
43   return;
44
45// looping to test vfprintf() with different unsigned formats from the above $format array
46// and with signed and other types of  values from the above $args_array array
47$counter = 1;
48foreach($formats as $format) {
49  fprintf($fp, "\n-- Iteration %d --\n",$counter);
50  vfprintf($fp, $format, $args_array[$counter-1]);
51  $counter++;
52}
53
54fclose($fp);
55print_r(file_get_contents($data_file));
56echo "\n";
57
58unlink($data_file);
59
60?>
61===DONE===
62--EXPECT--
63*** Testing vfprintf() : unsigned formats and unsigned values ***
64
65-- Iteration 1 --
661234567 342391 0
67-- Iteration 2 --
6812345678900 u 1234 12345
69-- Iteration 3 --
70   1234000 101234567000 120
71-- Iteration 4 --
72#1 0 $0 10
73-- Iteration 5 --
741 2 3 4
75===DONE===
76