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

1.1       misho       1: --TEST--
                      2: Test fprintf() function (variation - 3)
                      3: --SKIPIF--
                      4: <?php
                      5: $data_file = dirname(__FILE__) . '/dump.txt';
                      6: if (!($fp = fopen($data_file, 'w'))) {
                      7:   die('skip File dump.txt could not be created');
                      8: }
                      9: if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
                     10: ?>
                     11: --FILE--
                     12: <?php
                     13: 
                     14: $int_numbers = array( 0, 1, -1, 2.7, -2.7, 23333333, -23333333, "1234" );
                     15: 
                     16: /* creating dumping file */
                     17: $data_file = dirname(__FILE__) . '/dump.txt';
                     18: if (!($fp = fopen($data_file, 'wt')))
                     19:    return;
                     20: 
                     21: /* binary type variations */
                     22: fprintf($fp, "\n*** Testing fprintf() with binary ***\n");
                     23: foreach( $int_numbers as $bin_num ) {
                     24:   fprintf( $fp, "\n");
                     25:   fprintf( $fp, "%b", $bin_num );
                     26: }
                     27: 
                     28: fclose($fp);
                     29: 
                     30: print_r(file_get_contents($data_file));
                     31: echo "\nDone";
                     32: 
                     33: unlink($data_file);
                     34: 
                     35: ?>
                     36: --EXPECTF--
                     37: *** Testing fprintf() with binary ***
                     38: 
                     39: 0
                     40: 1
                     41: 11111111111111111111111111111111
                     42: 10
                     43: 11111111111111111111111111111110
                     44: 1011001000000100111010101
                     45: 11111110100110111111011000101011
                     46: 10011010010
                     47: Done

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