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

1.1       misho       1: --TEST--
                      2: Test vfprintf() function : basic functionality 
                      3: --CREDITS--
                      4: Felix De Vliegher <felix.devliegher@gmail.com>
                      5: --INI--
                      6: precision=14
                      7: --FILE--
                      8: <?php
                      9: /* Prototype  : int vfprintf(resource stream, string format, array args)
                     10:  * Description: Output a formatted string into a stream 
                     11:  * Source code: ext/standard/formatted_print.c
                     12:  * Alias to functions: 
                     13:  */
                     14: 
                     15: function writeAndDump($fp, $format, $args)
                     16: {
                     17:        ftruncate( $fp, 0 );
                     18:        $length = vfprintf( $fp, $format, $args );
                     19:        rewind( $fp );
                     20:        $content = stream_get_contents( $fp );
                     21:        var_dump( $content );
                     22:        var_dump( $length );
                     23: }
                     24: 
                     25: echo "*** Testing vfprintf() : basic functionality ***\n";
                     26: 
                     27: // Open handle
                     28: $file = 'vfprintf_test.txt';
                     29: $fp = fopen( $file, "a+" );
                     30: 
                     31: // Test vfprintf()
                     32: writeAndDump( $fp, "Foo is %d and %s", array( 30, 'bar' ) );
                     33: writeAndDump( $fp, "%s %s %s", array( 'bar', 'bar', 'bar' ) );
                     34: writeAndDump( $fp, "%d digit", array( '54' ) );
                     35: writeAndDump( $fp, "%b %b", array( true, false ) );
                     36: writeAndDump( $fp, "%c %c %c", array( 65, 66, 67 ) );
                     37: writeAndDump( $fp, "%e %E %e", array( 1000, 2e4, +2e2 ) );
                     38: writeAndDump( $fp, "%02d", array( 50 ) );
                     39: writeAndDump( $fp, "Testing %b %d %f %s %x %X", array( 9, 6, 2.5502, "foobar", 15, 65 ) );
                     40: 
                     41: // Close handle
                     42: fclose( $fp );
                     43: 
                     44: ?>
                     45: ===DONE===
                     46: --CLEAN--
                     47: <?php
                     48: 
                     49: $file = 'vfprintf_test.txt';
                     50: unlink( $file );
                     51: 
                     52: ?>
                     53: --EXPECTF--
                     54: *** Testing vfprintf() : basic functionality ***
                     55: string(17) "Foo is 30 and bar"
                     56: int(17)
                     57: string(11) "bar bar bar"
                     58: int(11)
                     59: string(8) "54 digit"
                     60: int(8)
                     61: string(3) "1 0"
                     62: int(3)
                     63: string(5) "A B C"
                     64: int(5)
                     65: string(35) "1.000000e+3 2.000000E+4 2.000000e+2"
                     66: int(35)
                     67: string(2) "50"
                     68: int(2)
                     69: string(35) "Testing 1001 6 2.550200 foobar f 41"
                     70: int(35)
                     71: ===DONE===

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