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

1.1       misho       1: --TEST--
                      2: Test sprintf() function : usage variations - float formats with resource values
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
                      6:  * Description: Return a formatted string 
                      7:  * Source code: ext/standard/formatted_print.c
                      8: */
                      9: 
                     10: echo "*** Testing sprintf() : float formats with resource values ***\n";
                     11: 
                     12: // resource type variable
                     13: $fp = fopen (__FILE__, "r");
                     14: $dfp = opendir ( dirname(__FILE__) );
                     15: 
                     16: // array of resource types
                     17: $resource_values = array (
                     18:   $fp,
                     19:   $dfp
                     20: );
                     21: 
                     22: // various float formats
                     23: $float_formats = array(
                     24:   "%f", "%hf", "%lf", 
                     25:   "%Lf", " %f", "%f ", 
                     26:   "\t%f", "\n%f", "%4f",
                     27:   "%30f", "%[0-9]", "%*f"
                     28: );
                     29: 
                     30: $count = 1;
                     31: foreach($resource_values as $resource_value) {
                     32:   echo "\n-- Iteration $count --\n";
                     33:   
                     34:   foreach($float_formats as $format) {
                     35:     // with two arguments
                     36:     var_dump( sprintf($format, $resource_value) );
                     37:   }
                     38:   $count++;
                     39: };
                     40: 
                     41: // closing the resources
                     42: fclose($fp);
                     43: closedir($dfp);
                     44: 
                     45: echo "Done";
                     46: ?>
                     47: --EXPECTF--
                     48: *** Testing sprintf() : float formats with resource values ***
                     49: 
                     50: -- Iteration 1 --
                     51: string(%d) "%d.000000"
                     52: string(1) "f"
                     53: string(%d) "%d.000000"
                     54: string(1) "f"
                     55: string(%d) " %d.000000"
                     56: string(%d) "%d.000000 "
                     57: string(%d) "   %d.000000"
                     58: string(%d) "
                     59: %d.000000"
                     60: string(%d) "%d.000000"
                     61: string(30) "%s%d.000000"
                     62: string(4) "0-9]"
                     63: string(1) "f"
                     64: 
                     65: -- Iteration 2 --
                     66: string(%d) "%d.000000"
                     67: string(1) "f"
                     68: string(%d) "%d.000000"
                     69: string(1) "f"
                     70: string(%d) " %d.000000"
                     71: string(%d) "%d.000000 "
                     72: string(%d) "   %d.000000"
                     73: string(%d) "
                     74: %d.000000"
                     75: string(%d) "%d.000000"
                     76: string(30) "%s%d.000000"
                     77: string(4) "0-9]"
                     78: string(1) "f"
                     79: Done

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