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

1.1       misho       1: --TEST--
                      2: Test crc32() function : usage variations - heredoc strings
                      3: --SKIPIF--
                      4: <?php
                      5: if (PHP_INT_SIZE != 4)
                      6:   die("skip this test is for 32bit platform only");
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10: /* Prototype  : string crc32(string $str)
                     11:  * Description: Calculate the crc32 polynomial of a string 
                     12:  * Source code: ext/standard/crc32.c
                     13:  * Alias to functions: none
                     14: */
                     15: 
                     16: /*
                     17:  * Testing crc32() : with different heredoc strings passed to the str argument
                     18: */
                     19: 
                     20: echo "*** Testing crc32() : with different heredoc strings ***\n";
                     21: 
                     22: // defining different heredoc strings
                     23: $empty_heredoc = <<<EOT
                     24: EOT;
                     25: 
                     26: $heredoc_with_newline = <<<EOT
                     27: \n
                     28: 
                     29: EOT;
                     30: 
                     31: $heredoc_with_characters = <<<EOT
                     32: first line of heredoc string
                     33: second line of heredoc string
                     34: third line of heredocstring
                     35: EOT;
                     36: 
                     37: $heredoc_with_newline_and_tabs = <<<EOT
                     38: hello\tworld\nhello\nworld\n
                     39: EOT;
                     40: 
                     41: $heredoc_with_alphanumerics = <<<EOT
                     42: hello123world456
                     43: 1234hello\t1234
                     44: EOT;
                     45: 
                     46: $heredoc_with_embedded_nulls = <<<EOT
                     47: hello\0world\0hello
                     48: \0hello\0
                     49: EOT;
                     50: 
                     51: $heredoc_with_hexa_octal = <<<EOT
                     52: hello\0\100\xaaworld\0hello
                     53: \0hello\0
                     54: EOT;
                     55: 
                     56: $heredoc_with_long_string = <<<EOT
                     57: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb
                     58: cccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddd
                     59: eeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffff
                     60: gggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhh
                     61: 111111111111111111111122222222222222222222222222222222222222222222
                     62: 333333333333333333333333333333333334444444444444444444444444444444
                     63: 555555555555555555555555555555555555555555556666666666666666666666
                     64: 777777777777777777777777777777777777777777777777777777777777777777
                     65: /t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t
                     66: /n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n
                     67: EOT;
                     68: 
                     69: $heredoc_strings = array(
                     70:                    $empty_heredoc,
                     71:                    $heredoc_with_newline,
                     72:                    $heredoc_with_characters,
                     73:                    $heredoc_with_newline_and_tabs,
                     74:                    $heredoc_with_alphanumerics,
                     75:                    $heredoc_with_embedded_nulls,
                     76:                    $heredoc_with_hexa_octal,
                     77:                   $heredoc_with_long_string
                     78:                    );
                     79: 
                     80: // loop to test the function with each heredoc string in the array
                     81: 
                     82: $count = 1;
                     83: foreach($heredoc_strings as $str) {
                     84:   echo "\n-- Iteration $count --\n";
                     85:   var_dump( crc32($str) );
                     86:   $count++;
                     87: }
                     88: 
                     89: echo "Done";
                     90: ?>
                     91: --EXPECTF--
                     92: *** Testing crc32() : with different heredoc strings ***
                     93: 
                     94: -- Iteration 1 --
                     95: int(0)
                     96: 
                     97: -- Iteration 2 --
                     98: int(1541608299)
                     99: 
                    100: -- Iteration 3 --
                    101: int(1588851550)
                    102: 
                    103: -- Iteration 4 --
                    104: int(-1726108239)
                    105: 
                    106: -- Iteration 5 --
                    107: int(-1847303891)
                    108: 
                    109: -- Iteration 6 --
                    110: int(-1260053120)
                    111: 
                    112: -- Iteration 7 --
                    113: int(-1718044186)
                    114: 
                    115: -- Iteration 8 --
                    116: int(1646793751)
                    117: Done

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