File: 007.phpt

package info (click to toggle)
php-zstd 0.14.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,536 kB
  • sloc: ansic: 30,009; asm: 382; xml: 179; makefile: 3
file content (42 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--TEST--
namespace: Zstd\compress()/uncompress()
--SKIPIF--
--FILE--
<?php
include(dirname(__FILE__) . '/data.inc');

// Initialise all required variables
$smallstring = "A small string to compress\n";


// Calling \Zstd\compress() with all possible arguments
$level = 1;

// Compressing a big string
echo "*** Compression ***", PHP_EOL;
$output = \Zstd\compress($data, $level);
var_dump(md5($output));
var_dump(\Zstd\uncompress($output) === $data);

// Compressing a smaller string
echo "*** Compression ***", PHP_EOL;
$output = \Zstd\compress($smallstring, $level);
var_dump(bin2hex($output));
var_dump(\Zstd\uncompress($output) === $smallstring);

// Calling \Zstd\compress() with mandatory arguments
echo "*** Testing with no specified compression ***", PHP_EOL;
var_dump(bin2hex(\Zstd\compress($smallstring) ));

?>
===Done===
--EXPECTF--
*** Compression ***
string(32) "%s"
bool(true)
*** Compression ***
string(72) "28b52ffd201bd900004120736d616c6c20737472696e6720746f20636f6d70726573730a"
bool(true)
*** Testing with no specified compression ***
string(72) "28b52ffd201bd900004120736d616c6c20737472696e6720746f20636f6d70726573730a"
===Done===