Annotation of embedaddon/php/ext/standard/tests/strings/vprintf_variation17.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test vsprintf() function : usage variations - scientific formats with scientific values
3: --FILE--
4: <?php
5: /* Prototype : string vsprintf(string format, array args)
6: * Description: Output a formatted string
7: * Source code: ext/standard/formatted_print.c
8: */
9:
10: /*
11: * Test vprintf() when different scientific formats and scientific values
12: * are passed to the '$format' and '$args' arguments of the function
13: */
14:
15: echo "*** Testing vprintf() : scientific formats and scientific values ***\n";
16:
17: // defining array of scientific formats
18: $formats = array(
19: '%e %+e %-e',
20: '%le %Le %4e %-4e',
21: '%10.4e %-10.4e %.4e',
22: '%\'#20e %\'20e %\'$20e %\'_20e',
23: '%3$e %4$e %1$e %2$e'
24: );
25:
26: // Arrays of scientific values for the format defined in $format.
27: // Each sub array contains scientific values which correspond to each format string in $format
28: $args_array = array(
29: array(0, 1e0, "10e2" ),
30: array(2.2e2, 10e10, 1000e-2, 1000e7),
31: array(-22e12, 10e20, 1.2e2),
32: array(1e1, +1e2, -1e3, "1e2_"),
33: array(3e3, 4e3, 1e3, 2e3)
34: );
35:
36: // looping to test vprintf() with different scientific formats from the above $format array
37: // and with signed and other types of values from the above $args_array array
38: $counter = 1;
39: foreach($formats as $format) {
40: echo "\n-- Iteration $counter --\n";
41: $result = vprintf($format, $args_array[$counter-1]);
42: echo "\n";
43: var_dump($result);
44: $counter++;
45: }
46:
47: ?>
48: ===DONE===
49: --EXPECT--
50: *** Testing vprintf() : scientific formats and scientific values ***
51:
52: -- Iteration 1 --
53: 0.000000e+0 +1.000000e+0 1.000000e+3
54: int(36)
55:
56: -- Iteration 2 --
57: 2.200000e+2 e 1.000000e+1 1.000000e+10
58: int(38)
59:
60: -- Iteration 3 --
61: -2.2000e+13 1.0000e+21 1.2000e+2
62: int(32)
63:
64: -- Iteration 4 --
65: #########1.000000e+1 1.000000e+2 $$$$$$$$-1.000000e+3 _________1.000000e+2
66: int(74)
67:
68: -- Iteration 5 --
69: 1.000000e+3 2.000000e+3 3.000000e+3 4.000000e+3
70: int(47)
71: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>