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

1.1       misho       1: --TEST--
                      2: Test vsprintf() 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  : string vsprintf(string $format , array $args)
                     10:  * Description: Return a formatted string 
                     11:  * Source code: ext/standard/formatted_print.c
                     12: */
                     13: 
                     14: echo "*** Testing vsprintf() : 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: $counter = 1;
                     48: foreach($formats as $format) {
                     49:   echo"\n-- Iteration $counter --\n";
                     50:   var_dump( vsprintf($format, $args_array[$counter-1]) );
                     51:   $counter++;
                     52: }
                     53: 
                     54: echo "Done";
                     55: ?>
                     56: --EXPECTF--
                     57: *** Testing vsprintf() : with  white spaces in format strings ***
                     58: 
                     59: -- Iteration 1 --
                     60: string(13) "111  222  333"
                     61: 
                     62: -- Iteration 2 --
                     63: string(29) "1.100000  0.200000  -0.600000"
                     64: 
                     65: -- Iteration 3 --
                     66: string(29) "1.120000  -1.130000  0.230000"
                     67: 
                     68: -- Iteration 4 --
                     69: string(9) "1  10  11"
                     70: 
                     71: -- Iteration 5 --
                     72: string(7) "A  B  C"
                     73: 
                     74: -- Iteration 6 --
                     75: string(38) "2.000000e+1  2.000000e-1  -2.000000e+1"
                     76: 
                     77: -- Iteration 7 --
                     78: string(18) "4294967285  22  33"
                     79: 
                     80: -- Iteration 8 --
                     81: string(19) "12  37777777755  23"
                     82: 
                     83: -- Iteration 9 --
                     84: string(16) "11  ffffffde  33"
                     85: 
                     86: -- Iteration 10 --
                     87: string(16) "11  FFFFFFDE  33"
                     88: 
                     89: -- Iteration 11 --
                     90: string(38) "2.000000E+1  2.000000E-1  -2.000000E+1"
                     91: Done

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