import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-strings / vfprintf_variation12_64bit.php
bloba4018753732be2815911e5ae8bf3e58e110f0fe4
1 <?php
2 /* Prototype : int vfprintf ( resource $handle , string $format , array $args )
3 * Description: Write a formatted string to a stream
4 * Source code: ext/standard/formatted_print.c
5 */
7 /*
8 * Test vfprintf() when different octal formats and non-octal values are passed to
9 * the '$format' and '$args' arguments of the function
12 echo "*** Testing vfprintf() : octal formats and non-octal values ***\n";
14 // defining array of octal formats
15 $formats =
16 '%o %+o %-o
17 %lo %Lo %4o %-4o
18 %10.4o %-10.4o %.4o
19 %\'#2o %\'2o %\'$2o %\'_2o
20 %3$o %4$o %1$o %2$o';
22 // Arrays of non octal values for the format defined in $format.
23 // Each sub array contains non octal values which correspond to each format in $format
24 $args_array = array(
26 // array of float values
27 array(2.2, .2, 10.2,
28 123456.234, 123456.234, -1234.6789, +1234.6789,
29 2e10, +2e12, 22e+12,
30 12345.780, 12.000000011111, -12.00000111111, -123456.234,
31 3.33, +4.44, 1.11,-2.22 ),
33 // array of int values
34 array(2, -2, +2,
35 123456, 123456234, -12346789, +12346789,
36 123200, +20000, 22212,
37 12345780, 1211111, -12111111, -12345634,
38 3, +4, 1,-2 ),
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(false), 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, false, TRUE,
58 0, 1, 1, 0,
59 1, TRUE, 0, FALSE),
63 /* creating dumping file */
64 $data_file = dirname(__FILE__) . '/vfprintf_variation12_64bit.phpt.txt';
65 if (!($fp = fopen($data_file, 'wt')))
66 return;
68 // looping to test vfprintf() with different octal formats from the above $format array
69 // and with non-octal 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===