Annotation of embedaddon/php/ext/standard/tests/strings/vprintf_variation13_64bit.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test vprintf() 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  : string vprintf(string format, array args)
                     10:  * Description: Output a formatted string 
                     11:  * Source code: ext/standard/formatted_print.c
                     12: */
                     13: 
                     14: /*
                     15:  * Test vprintf() when different hexa formats and hexa values are passed to
                     16:  * the '$format' and '$args' arguments of the function
                     17: */
                     18: 
                     19: echo "*** Testing vprintf() : 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: // looping to test vprintf() with different char octal from the above $format array
                     48: // and with octal values from the above $args_array array
                     49: $counter = 1;
                     50: foreach($formats as $format) {
                     51:   echo "\n-- Iteration $counter --\n";   
                     52:   $result = vprintf($format, $args_array[$counter-1]);
                     53:   echo "\n";
                     54:   var_dump($result);
                     55:   $counter++;
                     56: }
                     57: 
                     58: ?>
                     59: ===DONE===
                     60: --EXPECT--
                     61: *** Testing vprintf() : hexa formats with hexa values ***
                     62: 
                     63: -- Iteration 1 --
                     64: 0
                     65: int(1)
                     66: 
                     67: -- Iteration 2 --
                     68: ffffffffffffffff 1 22
                     69: int(21)
                     70: 
                     71: -- Iteration 3 --
                     72: 7fffffff x, 7000000 ffffffff80000000
                     73: int(36)
                     74: 
                     75: -- Iteration 4 --
                     76:                       ffffffffffed2979 0000
                     77: int(43)
                     78: 
                     79: -- Iteration 5 --
                     80: #1 2222 1b6db ffffffffbbbbbbbc
                     81: int(30)
                     82: 
                     83: -- Iteration 6 --
                     84: 123b fab 0 a
                     85: int(12)
                     86: 
                     87: -- Iteration 7 --
                     88: %34 x
                     89: int(5)
                     90: 
                     91: -- Iteration 8 --
                     92: 1 2 3 4
                     93: int(7)
                     94: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>