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