Return to sprintf_error.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test sprintf() function : error conditions 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() : error conditions ***\n"; 11: 12: // Zero arguments 13: echo "\n-- Testing sprintf() function with Zero arguments --\n"; 14: var_dump( sprintf() ); 15: 16: echo "\n-- Testing sprintf() function with less than expected no. of arguments --\n"; 17: $format1 = '%s'; 18: $format2 = '%s%s'; 19: $format3 = '%s%s%s'; 20: $arg1 = 'one'; 21: $arg2 = 'two'; 22: 23: // with one argument less than expected 24: var_dump( sprintf($format1) ); 25: var_dump( sprintf($format2,$arg1) ); 26: var_dump( sprintf($format3,$arg1,$arg2) ); 27: 28: // with two argument less than expected 29: var_dump( sprintf($format2) ); 30: var_dump( sprintf($format3,$arg1) ); 31: 32: // with three argument less than expected 33: var_dump( sprintf($format3) ); 34: 35: echo "Done"; 36: ?> 37: --EXPECTF-- 38: *** Testing sprintf() : error conditions *** 39: 40: -- Testing sprintf() function with Zero arguments -- 41: 42: Warning: sprintf() expects at least %d parameter, %d given in %s on line %d 43: bool(false) 44: 45: -- Testing sprintf() function with less than expected no. of arguments -- 46: 47: Warning: sprintf(): Too few arguments in %s on line %d 48: bool(false) 49: 50: Warning: sprintf(): Too few arguments in %s on line %d 51: bool(false) 52: 53: Warning: sprintf(): Too few arguments in %s on line %d 54: bool(false) 55: 56: Warning: sprintf(): Too few arguments in %s on line %d 57: bool(false) 58: 59: Warning: sprintf(): Too few arguments in %s on line %d 60: bool(false) 61: 62: Warning: sprintf(): Too few arguments in %s on line %d 63: bool(false) 64: Done