gzdeflate_basic1.phpt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. --TEST--
  2. Test gzdeflate() function : basic functionality
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("zlib")) {
  6. print "skip - ZLIB extension not loaded";
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : string gzdeflate(string data [, int level, [int encoding]])
  12. * Description: Gzip-compress a string
  13. * Source code: ext/zlib/zlib.c
  14. * Alias to functions:
  15. */
  16. /*
  17. * add a comment here to say what the test is supposed to do
  18. */
  19. include(dirname(__FILE__) . '/data.inc');
  20. echo "*** Testing gzdeflate() : basic functionality ***\n";
  21. // Initialise all required variables
  22. $smallstring = "A small string to compress\n";
  23. // Calling gzdeflate() with all possible arguments
  24. // Compressing a big string
  25. for($i = -1; $i < 10; $i++) {
  26. echo "-- Compression level $i --\n";
  27. $output = gzdeflate($data, $i);
  28. var_dump(md5($output));
  29. var_dump(strcmp(gzinflate($output), $data));
  30. }
  31. // Compressing a smaller string
  32. for($i = -1; $i < 10; $i++) {
  33. echo "-- Compression level $i --\n";
  34. $output = gzdeflate($smallstring, $i);
  35. var_dump(bin2hex($output));
  36. var_dump(strcmp(gzinflate($output), $smallstring));
  37. }
  38. // Calling gzdeflate() with just mandatory arguments
  39. echo "\n-- Testing with no specified compression level --\n";
  40. var_dump( bin2hex(gzdeflate($smallstring) ));
  41. ?>
  42. ===Done===
  43. --EXPECT--
  44. *** Testing gzdeflate() : basic functionality ***
  45. -- Compression level -1 --
  46. string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
  47. int(0)
  48. -- Compression level 0 --
  49. string(32) "a71e54d2499aff9e48643cb1c260b60c"
  50. int(0)
  51. -- Compression level 1 --
  52. string(32) "05e80f4dc0d422e1f333cbed555d381f"
  53. int(0)
  54. -- Compression level 2 --
  55. string(32) "0fb33656e4ed0750f977df83246fce7a"
  56. int(0)
  57. -- Compression level 3 --
  58. string(32) "bc6e9c1dccc3e951e006315ee669ee08"
  59. int(0)
  60. -- Compression level 4 --
  61. string(32) "a61727d7a28c634470eb6e97a4a81b24"
  62. int(0)
  63. -- Compression level 5 --
  64. string(32) "a2a1a14b7542c82e8943200d093d5f27"
  65. int(0)
  66. -- Compression level 6 --
  67. string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
  68. int(0)
  69. -- Compression level 7 --
  70. string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
  71. int(0)
  72. -- Compression level 8 --
  73. string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
  74. int(0)
  75. -- Compression level 9 --
  76. string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
  77. int(0)
  78. -- Compression level -1 --
  79. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  80. int(0)
  81. -- Compression level 0 --
  82. string(64) "011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a"
  83. int(0)
  84. -- Compression level 1 --
  85. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  86. int(0)
  87. -- Compression level 2 --
  88. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  89. int(0)
  90. -- Compression level 3 --
  91. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  92. int(0)
  93. -- Compression level 4 --
  94. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  95. int(0)
  96. -- Compression level 5 --
  97. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  98. int(0)
  99. -- Compression level 6 --
  100. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  101. int(0)
  102. -- Compression level 7 --
  103. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  104. int(0)
  105. -- Compression level 8 --
  106. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  107. int(0)
  108. -- Compression level 9 --
  109. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  110. int(0)
  111. -- Testing with no specified compression level --
  112. string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
  113. ===Done===