Annotation of embedaddon/php/ext/standard/tests/strings/vfprintf_variation13_64bit.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test vfprintf() function : usage variations - hexa formats with hexa values
3: --SKIPIF--
4: <?php
5: if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6: ?>
7: --FILE--
8: <?php
9: /* Prototype : int vfprintf ( resource $handle , string $format , array $args )
10: * Description: Write a formatted string to a stream
11: * Source code: ext/standard/formatted_print.c
12: */
13:
14: /*
15: * Test vfprintf() when different hexa formats and hexa values are passed to
16: * the '$format' and '$args' arguments of the function
17: */
18:
19: echo "*** Testing vfprintf() : hexa formats with hexa values ***\n";
20:
21: // defining array of different hexa formats
22: $formats = array(
23: "%x",
24: "%+x %-x %X",
25: "%lx %Lx, %4x %-4x",
26: "%10.4x %-10.4x %04x %04.4x",
27: "%'#2x %'2x %'$2x %'_2x",
28: "%x %x %x %x",
29: "% %%x x%",
30: '%3$x %4$x %1$x %2$x'
31: );
32:
33: // Arrays of hexa values for the format defined in $format.
34: // Each sub array contains hexa values which correspond to each format string in $format
35: $args_array = array(
36: array(0x0),
37: array(-0x1, 0x1, +0x22),
38: array(0x7FFFFFFF, -0x7fffffff, +0x7000000, -0x80000000),
39: array(123456, 12345678, -1234567, 1234567),
40: array(1, 0x2222, 0333333, -0x44444444),
41: array(0x123b, 0xfAb, "0xaxz", 01293),
42: array(0x1234, 0x34, 0x2ff),
43: array(0x3, 0x4, 0x1, 0x2)
44:
45: );
46:
47: /* creating dumping file */
1.1.1.2 ! misho 48: $data_file = dirname(__FILE__) . '/vfprintf_variation13_64bit.txt';
1.1 misho 49: if (!($fp = fopen($data_file, 'wt')))
50: return;
51:
52: // looping to test vfprintf() with different char octal from the above $format array
53: // and with octal values from the above $args_array array
54: $counter = 1;
55: foreach($formats as $format) {
56: fprintf($fp, "\n-- Iteration %d --\n",$counter);
57: vfprintf($fp, $format, $args_array[$counter-1]);
58: $counter++;
59: }
60:
61: fclose($fp);
62: print_r(file_get_contents($data_file));
63: echo "\n";
64:
65: unlink($data_file);
66:
67: ?>
68: ===DONE===
69: --EXPECT--
70: *** Testing vfprintf() : hexa formats with hexa values ***
71:
72: -- Iteration 1 --
73: 0
74: -- Iteration 2 --
75: ffffffffffffffff 1 22
76: -- Iteration 3 --
77: 7fffffff x, 7000000 ffffffff80000000
78: -- Iteration 4 --
79: ffffffffffed2979 0000
80: -- Iteration 5 --
81: #1 2222 1b6db ffffffffbbbbbbbc
82: -- Iteration 6 --
83: 123b fab 0 a
84: -- Iteration 7 --
85: %34 x
86: -- Iteration 8 --
87: 1 2 3 4
88: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>