crc32_variation2.phpt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. --TEST--
  2. Test crc32() function : usage variations - single quoted 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 strings in single quotes passed to the function
  12. */
  13. echo "*** Testing crc32() : with different strings in single quotes ***\n";
  14. // defining an array of strings
  15. $string_array = array(
  16. '',
  17. ' ',
  18. 'hello world',
  19. 'HELLO WORLD',
  20. ' helloworld ',
  21. '(hello world)',
  22. 'hello(world)',
  23. 'helloworld()',
  24. 'hello()(world',
  25. '"hello" world',
  26. 'hello "world"',
  27. 'hello""world',
  28. 'hello\tworld',
  29. 'hellowor\\tld',
  30. '\thello world\t',
  31. 'hello\nworld',
  32. 'hellowor\\nld',
  33. '\nhello world\n',
  34. '\n\thelloworld',
  35. 'hel\tlo\n world',
  36. '!@#$%&',
  37. '#hello@world.com',
  38. '$hello$world',
  39. 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb
  40. cccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddd
  41. eeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffff
  42. gggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhh
  43. 111111111111111111111122222222222222222222222222222222222222222222
  44. 333333333333333333333333333333333334444444444444444444444444444444
  45. 555555555555555555555555555555555555555555556666666666666666666666
  46. 777777777777777777777777777777777777777777777777777777777777777777
  47. /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
  48. /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'
  49. );
  50. // looping to check the behaviour of the function for each string in the array
  51. $count = 1;
  52. foreach($string_array as $str) {
  53. echo "\n-- Iteration $count --\n";
  54. var_dump( crc32($str) );
  55. $count++;
  56. }
  57. echo "Done";
  58. ?>
  59. --EXPECT--
  60. *** Testing crc32() : with different strings in single quotes ***
  61. -- Iteration 1 --
  62. int(0)
  63. -- Iteration 2 --
  64. int(-378745019)
  65. -- Iteration 3 --
  66. int(222957957)
  67. -- Iteration 4 --
  68. int(-2015000997)
  69. -- Iteration 5 --
  70. int(1234261835)
  71. -- Iteration 6 --
  72. int(-1867296214)
  73. -- Iteration 7 --
  74. int(1048577080)
  75. -- Iteration 8 --
  76. int(2129739710)
  77. -- Iteration 9 --
  78. int(-1633247628)
  79. -- Iteration 10 --
  80. int(135755572)
  81. -- Iteration 11 --
  82. int(27384015)
  83. -- Iteration 12 --
  84. int(-497244052)
  85. -- Iteration 13 --
  86. int(-2065897232)
  87. -- Iteration 14 --
  88. int(243585859)
  89. -- Iteration 15 --
  90. int(-856440615)
  91. -- Iteration 16 --
  92. int(647088397)
  93. -- Iteration 17 --
  94. int(523630053)
  95. -- Iteration 18 --
  96. int(-2062229676)
  97. -- Iteration 19 --
  98. int(1169918910)
  99. -- Iteration 20 --
  100. int(-618551732)
  101. -- Iteration 21 --
  102. int(-1828940657)
  103. -- Iteration 22 --
  104. int(-1654468652)
  105. -- Iteration 23 --
  106. int(-1648442217)
  107. -- Iteration 24 --
  108. int(1431761713)
  109. Done