Annotation of embedaddon/php/ext/standard/tests/strings/vfprintf_variation19.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test vfprintf() function : usage variations - with whitespaces in format strings
                      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
                     12: */
                     13: 
                     14: echo "*** 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__) . '/dump.txt';
                     50: if (!($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;
                     56: foreach($formats as $format) {
                     57:   fprintf($fp, "\n-- Iteration %d --\n",$counter);
                     58:   vfprintf($fp,$format, $args_array[$counter-1]);
                     59:   $counter++;
                     60: }
                     61: 
                     62: fclose($fp);
                     63: print_r(file_get_contents($data_file));
                     64: echo "\n";
                     65: 
                     66: unlink($data_file); 
                     67: ?>
                     68: ===DONE===
                     69: --EXPECT--
                     70: *** Testing vfprintf() : with  white spaces in format strings ***
                     71: 
                     72: -- Iteration 1 --
                     73: 111  222  333
                     74: -- Iteration 2 --
                     75: 1.100000  0.200000  -0.600000
                     76: -- Iteration 3 --
                     77: 1.120000  -1.130000  0.230000
                     78: -- Iteration 4 --
                     79: 1  10  11
                     80: -- Iteration 5 --
                     81: A  B  C
                     82: -- Iteration 6 --
                     83: 2.000000e+1  2.000000e-1  -2.000000e+1
                     84: -- Iteration 7 --
                     85: 4294967285  22  33
                     86: -- Iteration 8 --
                     87: 12  37777777755  23
                     88: -- Iteration 9 --
                     89: 11  ffffffde  33
                     90: -- Iteration 10 --
                     91: 11  FFFFFFDE  33
                     92: -- Iteration 11 --
                     93: 2.000000E+1  2.000000E-1  -2.000000E+1
                     94: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>