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

1.1       misho       1: --TEST--
                      2: Test vprintf() function : usage variations - char formats with char 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() for char formats with an array of chars passed to the function
                     12: */
                     13: 
                     14: echo "*** Testing vprintf() : char formats with char values ***\n";
                     15: 
                     16: 
                     17: // defining array of char formats
                     18: $formats = array(
                     19:   "%c",
                     20:   "%+c %-c %C",
                     21:   "%lc %Lc, %4c %-4c",
                     22:   "%10.4c %-10.4c %04c %04.4c",
                     23:   "%'#2c %'2c %'$2c %'_2c",
                     24:   "%c %c %c %c",
                     25:   "% %%c c%",
                     26:   '%3$c %4$c %1$c %2$c'
                     27: );
                     28: 
                     29: // Arrays of char values for the format defined in $format.
                     30: // Each sub array contains char values which correspond to each format string in $format
                     31: $args_array = array(
                     32:   array(0),
                     33:   array('c', 67, 68),
                     34:   array(' ', " ", -67, +67),
                     35:   array(97, -97, 98, +98),
                     36:   array(97, -97, 98, +98),
                     37:   array(0x123b, 0xfAb, 0123, 01293),
                     38:   array(38, -1234, 2345),
                     39:   array(67, 68, 65, 66)
                     40: 
                     41: );
                     42: 
                     43: // looping to test vprintf() with different char formats from the above $format array
                     44: // and with char values from the above $args_array array
                     45: $counter = 1;
                     46: foreach($formats as $format) {
                     47:   echo "\n-- Iteration $counter --\n";   
                     48:   $result = vprintf($format, $args_array[$counter-1]);
                     49:   echo "\n";
                     50:   var_dump($result); 
                     51:   $counter++;
                     52: }
                     53: 
                     54: ?>
                     55: ===DONE===
                     56: --EXPECTF--
                     57: *** Testing vprintf() : char formats with char values ***
                     58: 
                     59: -- Iteration 1 --
                     60: 
                     61: int(1)
                     62: 
                     63: -- Iteration 2 --
                     64:  C 
                     65: int(4)
                     66: 
                     67: -- Iteration 3 --
                     68:  c, ½ C
                     69: int(8)
                     70: 
                     71: -- Iteration 4 --
                     72: a Ÿ b b
                     73: int(7)
                     74: 
                     75: -- Iteration 5 --
                     76: a Ÿ b b
                     77: int(7)
                     78: 
                     79: -- Iteration 6 --
                     80: ; « S 
                     81: 
                     82: int(7)
                     83: 
                     84: -- Iteration 7 --
                     85: %. c
                     86: int(4)
                     87: 
                     88: -- Iteration 8 --
                     89: A B C D
                     90: int(7)
                     91: ===DONE===

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