crc32_variation4.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. /*
  11. * Testing crc32() : with different heredoc strings passed to the str argument
  12. */
  13. echo "*** Testing crc32() : with different heredoc strings ***\n";
  14. // defining different heredoc strings
  15. $empty_heredoc = <<<EOT
  16. EOT;
  17. $heredoc_with_newline = <<<EOT
  18. \n
  19. EOT;
  20. $heredoc_with_characters = <<<EOT
  21. first line of heredoc string
  22. second line of heredoc string
  23. third line of heredocstring
  24. EOT;
  25. $heredoc_with_newline_and_tabs = <<<EOT
  26. hello\tworld\nhello\nworld\n
  27. EOT;
  28. $heredoc_with_alphanumerics = <<<EOT
  29. hello123world456
  30. 1234hello\t1234
  31. EOT;
  32. $heredoc_with_embedded_nulls = <<<EOT
  33. hello\0world\0hello
  34. \0hello\0
  35. EOT;
  36. $heredoc_with_hexa_octal = <<<EOT
  37. hello\0\100\xaaworld\0hello
  38. \0hello\0
  39. EOT;
  40. $heredoc_with_long_string = <<<EOT
  41. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb
  42. cccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddd
  43. eeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffff
  44. gggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhh
  45. 111111111111111111111122222222222222222222222222222222222222222222
  46. 333333333333333333333333333333333334444444444444444444444444444444
  47. 555555555555555555555555555555555555555555556666666666666666666666
  48. 777777777777777777777777777777777777777777777777777777777777777777
  49. /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
  50. /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
  51. EOT;
  52. $heredoc_strings = array(
  53. $empty_heredoc,
  54. $heredoc_with_newline,
  55. $heredoc_with_characters,
  56. $heredoc_with_newline_and_tabs,
  57. $heredoc_with_alphanumerics,
  58. $heredoc_with_embedded_nulls,
  59. $heredoc_with_hexa_octal,
  60. $heredoc_with_long_string
  61. );
  62. // loop to test the function with each heredoc string in the array
  63. $count = 1;
  64. foreach($heredoc_strings as $str) {
  65. echo "\n-- Iteration $count --\n";
  66. var_dump( crc32($str) );
  67. $count++;
  68. }
  69. echo "Done";
  70. ?>
  71. --EXPECT--
  72. *** Testing crc32() : with different heredoc strings ***
  73. -- Iteration 1 --
  74. int(0)
  75. -- Iteration 2 --
  76. int(1541608299)
  77. -- Iteration 3 --
  78. int(1588851550)
  79. -- Iteration 4 --
  80. int(-1726108239)
  81. -- Iteration 5 --
  82. int(-1847303891)
  83. -- Iteration 6 --
  84. int(-1260053120)
  85. -- Iteration 7 --
  86. int(-1718044186)
  87. -- Iteration 8 --
  88. int(1646793751)
  89. Done