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

1.1       misho       1: --TEST--
                      2: Test sprintf() function : usage variations - typical format strings
                      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() : with  typical format strings ***\n";
                     11: 
                     12: // initialising required variables
                     13: $tempnum = 12345;
                     14: $tempstring = "abcdefghjklmnpqrstuvwxyz";
                     15: 
                     16: echo"\n-- Testing for '%%%.2f' as the format parameter --\n";
                     17: var_dump(sprintf("%%%.2f", 1.23456789e10));
                     18: 
                     19: echo"\n-- Testing for '%%' as the format parameter --\n";
                     20: var_dump(sprintf("%%", 1.23456789e10));
                     21: 
                     22: echo"\n-- Testing for precision value more than maximum --\n";
                     23: var_dump(sprintf("%.988f", 1.23456789e10));
                     24: 
                     25: echo"\n-- Testing for invalid width(-15) specifier --\n";
                     26: var_dump(sprintf("%030.-15s", $tempstring));
                     27: 
                     28: echo"\n-- Testing for '%X' as the format parameter --\n";
                     29: var_dump(sprintf("%X", 12));
                     30: 
                     31: echo"\n-- Testing for multiple format parameters --\n";
                     32: var_dump(sprintf("%d  %s  %d\n", $tempnum, $tempstring, $tempnum));
                     33: 
                     34: echo"\n-- Testing for excess of mixed type arguments  --\n";
                     35: var_dump(sprintf("%s", $tempstring, $tempstring, $tempstring));
                     36: 
                     37: echo "Done";
                     38: ?>
                     39: --EXPECTF--
                     40: *** Testing sprintf() : with  typical format strings ***
                     41: 
                     42: -- Testing for '%%%.2f' as the format parameter --
                     43: string(15) "%12345678900.00"
                     44: 
                     45: -- Testing for '%%' as the format parameter --
                     46: string(1) "%"
                     47: 
                     48: -- Testing for precision value more than maximum --
                     49: 
                     50: Notice: sprintf(): Requested precision of 988 digits was truncated to PHP maximum of %d digits in %s on line %d
                     51: string(65) "12345678900.00000000000000000000000000000000000000000000000000000"
                     52: 
                     53: -- Testing for invalid width(-15) specifier --
                     54: string(3) "15s"
                     55: 
                     56: -- Testing for '%X' as the format parameter --
                     57: string(1) "C"
                     58: 
                     59: -- Testing for multiple format parameters --
                     60: string(39) "12345  abcdefghjklmnpqrstuvwxyz  12345
                     61: "
                     62: 
                     63: -- Testing for excess of mixed type arguments  --
                     64: string(24) "abcdefghjklmnpqrstuvwxyz"
                     65: Done

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