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

1.1       misho       1: --TEST--
                      2: Test number_format() - basic function test number_format()
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  :  string number_format  ( float $number  [, int $decimals  ] )
                      6:  *               string number_format ( float $number , int $decimals , string $dec_point , string $thousands_sep )
                      7:  * Description: Format a number with grouped thousands
                      8:  * Source code: ext/standard/string.c
                      9:  */
                     10:  
                     11: echo "*** Testing number_format() : basic functionality ***\n";
                     12: 
                     13: $values = array(1234.5678,
                     14:                                -1234.5678,
                     15:                                1234.6578e4,
                     16:                                -1234.56789e4,
                     17:                                0x1234CDEF,
                     18:                                02777777777,
                     19:                                "123456789",
                     20:                                "123.456789",
                     21:                                "12.3456789e1",                         
                     22:                                null,
                     23:                                true,
                     24:                                false); 
                     25: 
                     26: echo "\n-- number_format tests.....default --\n";
                     27: for ($i = 0; $i < count($values); $i++) {
                     28:        $res = number_format($values[$i]);
                     29:        var_dump($res);
                     30: }
                     31: 
                     32: echo "\n-- number_format tests.....with two dp --\n";
                     33: for ($i = 0; $i < count($values); $i++) {
                     34:        $res = number_format($values[$i], 2);
                     35:        var_dump($res);
                     36: }
                     37: 
                     38: echo "\n-- number_format tests.....English format --\n";
                     39: for ($i = 0; $i < count($values); $i++) {
                     40:        $res = number_format($values[$i], 2, '.', ' ');
                     41:        var_dump($res);
                     42: }
                     43: 
                     44: echo "\n-- number_format tests.....French format --\n";
                     45: for ($i = 0; $i < count($values); $i++) {
                     46:        $res = number_format($values[$i], 2, ',' , ' ');
                     47:        var_dump($res);
                     48: }
                     49: ?>
                     50: ===DONE===
                     51: --EXPECTF--
                     52: *** Testing number_format() : basic functionality ***
                     53: 
                     54: -- number_format tests.....default --
                     55: string(5) "1,235"
                     56: string(6) "-1,235"
                     57: string(10) "12,346,578"
                     58: string(11) "-12,345,679"
                     59: string(11) "305,450,479"
                     60: string(11) "402,653,183"
                     61: string(11) "123,456,789"
                     62: string(3) "123"
                     63: string(3) "123"
                     64: string(1) "0"
                     65: string(1) "1"
                     66: string(1) "0"
                     67: 
                     68: -- number_format tests.....with two dp --
                     69: string(8) "1,234.57"
                     70: string(9) "-1,234.57"
                     71: string(13) "12,346,578.00"
                     72: string(14) "-12,345,678.90"
                     73: string(14) "305,450,479.00"
                     74: string(14) "402,653,183.00"
                     75: string(14) "123,456,789.00"
                     76: string(6) "123.46"
                     77: string(6) "123.46"
                     78: string(4) "0.00"
                     79: string(4) "1.00"
                     80: string(4) "0.00"
                     81: 
                     82: -- number_format tests.....English format --
                     83: string(8) "1 234.57"
                     84: string(9) "-1 234.57"
                     85: string(13) "12 346 578.00"
                     86: string(14) "-12 345 678.90"
                     87: string(14) "305 450 479.00"
                     88: string(14) "402 653 183.00"
                     89: string(14) "123 456 789.00"
                     90: string(6) "123.46"
                     91: string(6) "123.46"
                     92: string(4) "0.00"
                     93: string(4) "1.00"
                     94: string(4) "0.00"
                     95: 
                     96: -- number_format tests.....French format --
                     97: string(8) "1 234,57"
                     98: string(9) "-1 234,57"
                     99: string(13) "12 346 578,00"
                    100: string(14) "-12 345 678,90"
                    101: string(14) "305 450 479,00"
                    102: string(14) "402 653 183,00"
                    103: string(14) "123 456 789,00"
                    104: string(6) "123,46"
                    105: string(6) "123,46"
                    106: string(4) "0,00"
                    107: string(4) "1,00"
                    108: string(4) "0,00"
                    109: ===DONE===

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