Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation45.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - unsigned formats with boolean 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 boolean values ***\n";
11:
12: // array of boolean values
13: $boolean_values = array(
14: true,
15: false,
16: TRUE,
17: FALSE,
18: );
19:
20: // array of unsigned formats
21: $unsigned_formats = array(
22: "%u", "%hu", "%lu",
23: "%Lu", " %u", "%u ",
24: "\t%u", "\n%u", "%4u",
25: "%30u", "%[0-9]", "%*u"
26: );
27:
28: $count = 1;
29: foreach($boolean_values as $boolean_value) {
30: echo "\n-- Iteration $count --\n";
31:
32: foreach($unsigned_formats as $format) {
33: var_dump( sprintf($format, $boolean_value) );
34: }
35: $count++;
36: };
37:
38: echo "Done";
39: ?>
40: --EXPECTF--
41: *** Testing sprintf() : unsigned formats with boolean values ***
42:
43: -- Iteration 1 --
44: string(1) "1"
45: string(1) "u"
46: string(1) "1"
47: string(1) "u"
48: string(2) " 1"
49: string(2) "1 "
50: string(2) " 1"
51: string(2) "
52: 1"
53: string(4) " 1"
54: string(30) " 1"
55: string(4) "0-9]"
56: string(1) "u"
57:
58: -- Iteration 2 --
59: string(1) "0"
60: string(1) "u"
61: string(1) "0"
62: string(1) "u"
63: string(2) " 0"
64: string(2) "0 "
65: string(2) " 0"
66: string(2) "
67: 0"
68: string(4) " 0"
69: string(30) " 0"
70: string(4) "0-9]"
71: string(1) "u"
72:
73: -- Iteration 3 --
74: string(1) "1"
75: string(1) "u"
76: string(1) "1"
77: string(1) "u"
78: string(2) " 1"
79: string(2) "1 "
80: string(2) " 1"
81: string(2) "
82: 1"
83: string(4) " 1"
84: string(30) " 1"
85: string(4) "0-9]"
86: string(1) "u"
87:
88: -- Iteration 4 --
89: string(1) "0"
90: string(1) "u"
91: string(1) "0"
92: string(1) "u"
93: string(2) " 0"
94: string(2) "0 "
95: string(2) " 0"
96: string(2) "
97: 0"
98: string(4) " 0"
99: string(30) " 0"
100: string(4) "0-9]"
101: string(1) "u"
102: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>