import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-strings / vfprintf_variation16_64bit.php
blob81b54d69f0d79801b11527c47a1a380a9c42e00e
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 unsigned formats and signed values and other types of values
9 * are passed to the '$format' and '$args' arguments of the function
12 echo "*** Testing vfprintf() : unsigned formats and signed & other types of values ***\n";
14 // defining array of unsigned formats
15 $formats =
16 '%u %+u %-u
17 %lu %Lu %4u %-4u
18 %10.4u %-10.4u %.4u
19 %\'#2u %\'2u %\'$2u %\'_2u
20 %3$u %4$u %1$u %2$u';
22 // Arrays of signed and other type of values for the format defined in $format.
23 // Each sub array contains signed 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,
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 strings
34 array(" ", ' ', 'hello',
35 '123hello', "123hello", '-123hello', '+123hello',
36 "\12345678hello", "-\12345678hello", 'h123456ello',
37 "1234hello", "hello\0world", "NULL", "true",
38 "3", "4", '1', '2'),
40 // different arrays
41 array( array(0), array(1, 2), array(-1, -1),
42 array("123"), array('123'), array('-123'), array("-123"),
43 array(true), array(TRUE), array(FALSE),
44 array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
45 array("3"), array("4"), array("1"), array("2") ),
47 // array of boolean data
48 array( true, TRUE, false,
49 TRUE, 0, FALSE, 1,
50 true, TRUE, FALSE,
51 0, 1, 1, 0,
52 1, TRUE, 0, FALSE),
56 /* creating dumping file */
57 $data_file = dirname(__FILE__) . '/vfprintf_variation16_64bit.phpt.txt';
58 if (!($fp = fopen($data_file, 'wt')))
59 return;
61 // looping to test vfprintf() with different unsigned formats from the above $format array
62 // and with signed and other types of values from the above $args_array array
63 $counter = 1;
64 foreach($args_array as $args) {
65 fprintf($fp, "\n-- Iteration %d --\n",$counter);
66 vfprintf($fp, $formats, $args);
67 $counter++;
70 fclose($fp);
71 print_r(file_get_contents($data_file));
72 echo "\n";
74 unlink($data_file);
77 ===DONE===