Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation42.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - unsigned 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() : unsigned 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: // array of unsigned formats
23: $unsigned_formats = array(
24: "%u", "%hu", "%lu",
25: "%Lu", " %u", "%u ",
26: "\t%u", "\n%u", "%4u",
27: "%30u", "%[0-9]", "%*u"
28: );
29:
30:
31: $count = 1;
32: foreach($resource_values as $resource_value) {
33: echo "\n-- Iteration $count --\n";
34:
35: foreach($unsigned_formats as $format) {
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() : unsigned formats with resource values ***
49:
50: -- Iteration 1 --
51: string(%d) "%d"
52: string(1) "u"
53: string(%d) "%d"
54: string(1) "u"
55: string(%d) " %d"
56: string(%d) "%d "
57: string(%d) " %d"
58: string(%d) "
59: %d"
60: string(4) "%s%d"
61: string(30) "%s%d"
62: string(4) "0-9]"
63: string(1) "u"
64:
65: -- Iteration 2 --
66: string(%d) "%d"
67: string(1) "u"
68: string(%d) "%d"
69: string(1) "u"
70: string(%d) " %d"
71: string(%d) "%d "
72: string(%d) " %d"
73: string(%d) "
74: %d"
75: string(4) "%s%d"
76: string(30) "%s%d"
77: string(4) "0-9]"
78: string(1) "u"
79: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>