dictionary_usage.phpt 834 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Test dictionary usage on zlib methods
  3. --EXTENSIONS--
  4. zlib
  5. --FILE--
  6. <?php
  7. $dict = range("a", "z");
  8. $r = deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => $dict]);
  9. $a = deflate_add($r, "abdcde", ZLIB_FINISH);
  10. var_dump($a);
  11. $r = deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => implode("\0", $dict)."\0"]);
  12. $dictStr_a = deflate_add($r, "abdcde", ZLIB_FINISH);
  13. var_dump($dictStr_a === $a);
  14. $r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => $dict]);
  15. var_dump(inflate_add($r, $a, ZLIB_FINISH));
  16. $r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => ["8"] + range("a", "z")]);
  17. var_dump(inflate_add($r, $a, ZLIB_FINISH));
  18. ?>
  19. --EXPECTF--
  20. string(%d) "%s"
  21. bool(true)
  22. string(6) "abdcde"
  23. Warning: inflate_add(): Dictionary does not match expected dictionary (incorrect adler32 hash) in %s on line %d
  24. bool(false)