1--TEST--
2zstd_compress(): basic functionality
3--SKIPIF--
4--FILE--
5<?php
6include(dirname(__FILE__) . '/data.inc');
7
8// Initialise all required variables
9$smallstring = "A small string to compress\n";
10
11
12// Calling zstd_compress() with all possible arguments
13$level = 1;
14
15// Compressing a big string
16echo "*** Compression big ***", PHP_EOL;
17$output = zstd_compress($data, $level);
18var_dump(md5($output));
19var_dump(zstd_uncompress($output) === $data);
20
21// Compressing a smaller string
22echo "*** Compression small ***", PHP_EOL;
23$output = zstd_compress($smallstring, $level);
24var_dump(bin2hex($output));
25var_dump(zstd_uncompress($output) === $smallstring);
26
27// Calling zstd_compress() with mandatory arguments
28echo "*** Testing with no specified compression ***", PHP_EOL;
29var_dump(bin2hex(zstd_compress($smallstring) ));
30
31// Compressing a empty string
32echo "*** Compression empty ***", PHP_EOL;
33$output = zstd_compress('', $level);
34var_dump(bin2hex($output));
35var_dump(zstd_uncompress($output) === '');
36?>
37===Done===
38--EXPECTF--
39*** Compression big ***
40string(32) "%s"
41bool(true)
42*** Compression small ***
43string(72) "28b52ffd201bd900004120736d616c6c20737472696e6720746f20636f6d70726573730a"
44bool(true)
45*** Testing with no specified compression ***
46string(72) "28b52ffd201bd900004120736d616c6c20737472696e6720746f20636f6d70726573730a"
47*** Compression empty ***
48string(18) "28b52ffd2000010000"
49bool(true)
50===Done===
51