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

1.1       misho       1: --TEST--
                      2: Test vprintf() function : usage variations - float formats with non-float values
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string vprintf(string format, array args)
                      6:  * Description: Output a formatted string 
                      7:  * Source code: ext/standard/formatted_print.c
                      8: */
                      9: 
                     10: /*
                     11:  * Test vprintf() when different float formats and non-float values are passed to
                     12:  * the '$format' and '$args' arguments of the function
                     13: */
                     14: 
                     15: echo "*** Testing vprintf() : float formats and non-float values ***\n";
                     16: 
                     17: // defining array of float formats
                     18: $formats = 
                     19:   '%f %+f %-f 
                     20:    %lf %Lf %4f %-4f
                     21:    %10.4f %-10.4f %04f %04.4f
                     22:    %\'#2f %\'2f %\'$2f %\'_2f
                     23:    %3$f %4$f %1$f %2$f';
                     24: 
                     25: // Arrays of non float values for the format defined in $format.
                     26: // Each sub array contains non float values which correspond to each format in $format
                     27: $args_array = array(
                     28: 
                     29:   // array of int values
                     30:   array(2, -2, +2,
                     31:         123456, 123456234, -12346789, +12346789,
                     32:         123200, +20000, -40000, 22212,
                     33:         12345780, 1211111, -12111111, -12345634,
                     34:         3, +4, 1,-2 ),
                     35: 
                     36:   // array of strings
                     37:   array(" ", ' ', 'hello',
                     38:         '123hello', "123hello", '-123hello', '+123hello',
                     39:         "\12345678hello", "-\12345678hello", '0123456hello', 'h123456ello',
                     40:         "1234hello", "hello\0world", "NULL", "true",
                     41:         "3", "4", '1', '2'),
                     42: 
                     43:   // different arrays
                     44:   array( array(0), array(1, 2), array(-1, -1),
                     45:          array("123"), array('123'), array('-123'), array("-123"),
                     46:          array(true), array(false), array(TRUE), array(FALSE),
                     47:          array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
                     48:          array("3"), array("4"), array("1"), array("2") ),
                     49: 
                     50:   // array of boolean data
                     51:   array( true, TRUE, false,
                     52:          TRUE, 0, FALSE, 1,
                     53:          true, false, TRUE, FALSE,
                     54:          0, 1, 1, 0,
                     55:          1, TRUE, 0, FALSE),
                     56:   
                     57: );
                     58:  
                     59: // looping to test vprintf() with different float formats from the above $format array
                     60: // and with non-float values from the above $args_array array
                     61: $counter = 1;
                     62: foreach($args_array as $args) {
                     63:   echo "\n-- Iteration $counter --\n";
                     64:   $result = vprintf($formats, $args);
                     65:   echo "\n";
                     66:   var_dump($result);
                     67:   $counter++;
                     68: }
                     69: 
                     70: ?>
                     71: ===DONE===
                     72: --EXPECT--
                     73: *** Testing vprintf() : float formats and non-float values ***
                     74: 
                     75: -- Iteration 1 --
                     76: 2.000000 -2.000000 2.000000 
                     77:    123456.000000 f -12346789.000000 12346789.000000
                     78:    123200.0000 20000.0000 -40000.000000 22212.0000
                     79:    12345780.000000 1211111.000000 -12111111.000000 -12345634.000000
                     80:    2.000000 123456.000000 2.000000 -2.000000
                     81: int(244)
                     82: 
                     83: -- Iteration 2 --
                     84: 0.000000 +0.000000 0.000000 
                     85:    123.000000 f -123.000000 123.000000
                     86:        0.0000 0.0000     123456.000000 0.0000
                     87:    1234.000000 0.000000 0.000000 0.000000
                     88:    0.000000 123.000000 0.000000 0.000000
                     89: int(196)
                     90: 
                     91: -- Iteration 3 --
                     92: 1.000000 +1.000000 1.000000 
                     93:    1.000000 f 1.000000 1.000000
                     94:        1.0000 1.0000     1.000000 1.0000
                     95:    1.000000 1.000000 1.000000 1.000000
                     96:    1.000000 1.000000 1.000000 1.000000
                     97: int(179)
                     98: 
                     99: -- Iteration 4 --
                    100: 1.000000 +1.000000 0.000000 
                    101:    1.000000 f 0.000000 1.000000
                    102:        1.0000 0.0000     1.000000 0.0000
                    103:    0.000000 1.000000 1.000000 0.000000
                    104:    0.000000 1.000000 1.000000 1.000000
                    105: int(179)
                    106: ===DONE===

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