Annotation of embedaddon/php/ext/standard/tests/strings/vsprintf_variation15.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test vsprintf() function : usage variations - unsigned formats with unsigned values
3: --SKIPIF--
4: <?php
5: if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
6: ?>
7: --FILE--
8: <?php
9: /* Prototype : string vsprintf(string format, array args)
10: * Description: Return a formatted string
11: * Source code: ext/standard/formatted_print.c
12: */
13:
14: /*
15: * Test vsprintf() when different unsigned formats and unsigned values
16: * are passed to the '$format' and '$args' arguments of the function
17: */
18:
19: echo "*** Testing vsprintf() : unsigned formats and unsigned values ***\n";
20:
21: // defining array of unsigned formats
22: $formats = array(
23: '%u %+u %-u',
24: '%lu %Lu %4u %-4u',
25: '%10.4u %-10.4u %.4u',
26: '%\'#2u %\'2u %\'$2u %\'_2u',
27: '%3$u %4$u %1$u %2$u'
28: );
29:
30: // Arrays of unsigned values for the format defined in $format.
31: // Each sub array contains unsigned values which correspond to each format string in $format
32: $args_array = array(
33: array(1234567, 01234567, 0 ),
34: array(12345678900, 12345678900, 1234, 12345),
35: array("1234000", 10.1234567e5, 1.2e2),
36: array(1, 0, 00, "10_"),
37: array(3, 4, 1, 2)
38: );
39:
40: // looping to test vsprintf() with different unsigned formats from the above $format array
41: // and with signed and other types of values from the above $args_array array
42: $counter = 1;
43: foreach($formats as $format) {
44: echo "\n-- Iteration $counter --\n";
45: var_dump( vsprintf($format, $args_array[$counter-1]) );
46: $counter++;
47: }
48:
49: ?>
50: ===Done===
51: --EXPECT--
52: *** Testing vsprintf() : unsigned formats and unsigned values ***
53:
54: -- Iteration 1 --
55: string(16) "1234567 342391 0"
56:
57: -- Iteration 2 --
58: string(23) "3755744308 u 1234 12345"
59:
60: -- Iteration 3 --
61: string(25) " 1234000 1012345 120"
62:
63: -- Iteration 4 --
64: string(10) "#1 0 $0 10"
65:
66: -- Iteration 5 --
67: string(7) "1 2 3 4"
68: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>