gzcompress_basic1.phpt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. --TEST--
  2. Test gzcompress() function : basic functionality
  3. --EXTENSIONS--
  4. zlib
  5. --FILE--
  6. <?php
  7. /*
  8. * add a comment here to say what the test is supposed to do
  9. */
  10. include(__DIR__ . '/data.inc');
  11. echo "*** Testing gzcompress() : basic functionality ***\n";
  12. // Initialise all required variables
  13. $smallstring = "A small string to compress\n";
  14. // Calling gzcompress() with all possible arguments
  15. // Compressing a big string
  16. for($i = -1; $i < 10; $i++) {
  17. echo "-- Compression level $i --\n";
  18. $output = gzcompress($data, $i);
  19. var_dump(md5($output));
  20. var_dump(strcmp(gzuncompress($output), $data));
  21. }
  22. // Compressing a smaller string
  23. for($i = -1; $i < 10; $i++) {
  24. echo "-- Compression level $i --\n";
  25. $output = gzcompress($smallstring, $i);
  26. var_dump(bin2hex($output));
  27. var_dump(strcmp(gzuncompress($output), $smallstring));
  28. }
  29. // Calling gzcompress() with mandatory arguments
  30. echo "\n-- Testing with no specified compression level --\n";
  31. var_dump( bin2hex(gzcompress($smallstring) ));
  32. ?>
  33. --EXPECT--
  34. *** Testing gzcompress() : basic functionality ***
  35. -- Compression level -1 --
  36. string(32) "764809aef15bb34cb73ad49ecb600d99"
  37. int(0)
  38. -- Compression level 0 --
  39. string(32) "d0136b3fb5424142c0eb26dfec8f56fe"
  40. int(0)
  41. -- Compression level 1 --
  42. string(32) "c2e070f4320d1f674965eaab95b53d9c"
  43. int(0)
  44. -- Compression level 2 --
  45. string(32) "36922f486410d08209d0d0d21b26030e"
  46. int(0)
  47. -- Compression level 3 --
  48. string(32) "a441a2f5169bb303cd45b860a5a9dbf9"
  49. int(0)
  50. -- Compression level 4 --
  51. string(32) "d5b7451e9de2864beccc9de1fc55eb87"
  52. int(0)
  53. -- Compression level 5 --
  54. string(32) "32ba4a01120449ec25508cabfad41f56"
  55. int(0)
  56. -- Compression level 6 --
  57. string(32) "764809aef15bb34cb73ad49ecb600d99"
  58. int(0)
  59. -- Compression level 7 --
  60. string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
  61. int(0)
  62. -- Compression level 8 --
  63. string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
  64. int(0)
  65. -- Compression level 9 --
  66. string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
  67. int(0)
  68. -- Compression level -1 --
  69. string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  70. int(0)
  71. -- Compression level 0 --
  72. string(76) "7801011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a87a509cb"
  73. int(0)
  74. -- Compression level 1 --
  75. string(70) "7801735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  76. int(0)
  77. -- Compression level 2 --
  78. string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  79. int(0)
  80. -- Compression level 3 --
  81. string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  82. int(0)
  83. -- Compression level 4 --
  84. string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  85. int(0)
  86. -- Compression level 5 --
  87. string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  88. int(0)
  89. -- Compression level 6 --
  90. string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  91. int(0)
  92. -- Compression level 7 --
  93. string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  94. int(0)
  95. -- Compression level 8 --
  96. string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  97. int(0)
  98. -- Compression level 9 --
  99. string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
  100. int(0)
  101. -- Testing with no specified compression level --
  102. string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"