Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / standard / tests / strings / vfprintf_variation16.phpt
blob21630521b8dc1ddd2bd64c8bf10c40136b9800b6
1 --TEST--
2 Test vfprintf() function : usage variations - unsigned formats with signed and other types of values
3 --SKIPIF--
4 <?php
5 if (PHP_INT_SIZE != 4) die("skip this test is for 32bit 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
15  * Test vfprintf() when different unsigned formats and signed values and other types of values
16  * are passed to the '$format' and '$args' arguments of the function
19 echo "*** Testing vfprintf() : unsigned formats and signed & other types of values ***\n";
21 // defining array of unsigned formats
22 $formats = 
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';
29 // Arrays of signed and other type of values for the format defined in $format.
30 // Each sub array contains signed values which correspond to each format in $format
31 $args_array = array(
33   // array of float values
34   array(+2.2, +.2, +10.2,
35         +123456.234, +123456.234, +1234.6789,
36         +2e10, +2e12, +22e+12,
37         +12345.780, +12.000000011111, -12.00000111111, -123456.234,
38         +3.33, +4.44, +1.11,-2.22 ),
40   // array of strings
41   array(" ", ' ', 'hello',
42         '123hello', "123hello", '-123hello', '+123hello',
43         "\12345678hello", "-\12345678hello", 'h123456ello',
44         "1234hello", "hello\0world", "NULL", "true",
45         "3", "4", '1', '2'),
47   // different arrays
48   array( array(0), array(1, 2), array(-1, -1),
49          array("123"), array('123'), array('-123'), array("-123"),
50          array(true), array(TRUE), array(FALSE),
51          array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
52          array("3"), array("4"), array("1"), array("2") ),
54   // array of boolean data
55   array( true, TRUE, false,
56          TRUE, 0, FALSE, 1,
57          true, TRUE, FALSE,
58          0, 1, 1, 0,
59          1, TRUE, 0, FALSE),
60   
63 /* creating dumping file */
64 $data_file = dirname(__FILE__) . '/dump.txt';
65 if (!($fp = fopen($data_file, 'wt')))
66    return;
68 // looping to test vfprintf() with different unsigned formats from the above $format array
69 // and with signed and other types of  values from the above $args_array array
70 $counter = 1;
71 foreach($args_array as $args) {
72   fprintf($fp, "\n-- Iteration %d --\n",$counter);
73   vfprintf($fp, $formats, $args);
74   $counter++;
77 fclose($fp);
78 print_r(file_get_contents($data_file));
79 echo "\n";
81 unlink($data_file);  
84 ===DONE===
85 --EXPECT--
86 *** Testing vfprintf() : unsigned formats and signed & other types of values ***
88 -- Iteration 1 --
89 2 0 10 
90    123456 u 1234 2820130816
91    2840207360 1177509888 12345 
92    12 4294967284 4294843840 _3
93    10 123456 2 0
94 -- Iteration 2 --
95 0 0 0 
96    123 u 4294967173 123 
97             0 0          0 
98    1234 0 $0 _0
99    0 123 0 0
100 -- Iteration 3 --
101 1 1 1 
102    1 u    1 1   
103             1 1          1 
104    #1 1 $1 _1
105    1 1 1 1
106 -- Iteration 4 --
107 1 1 0 
108    1 u    0 1   
109             1 1          0 
110    #0 1 $1 _0
111    0 1 1 1
112 ===DONE===