xref: /PHP-5.3/ext/zlib/tests/gzencode_basic1.phpt (revision af49e58f)
1--TEST--
2Test gzencode() function : basic functionality
3--SKIPIF--
4<?php
5if (!extension_loaded("zlib")) {
6	print "skip - ZLIB extension not loaded";
7}
8?>
9--FILE--
10<?php
11/* Prototype  : string gzencode  ( string $data  [, int $level  [, int $encoding_mode  ]] )
12 * Description: Gzip-compress a string
13 * Source code: ext/zlib/zlib.c
14 * Alias to functions:
15 */
16
17/*
18 * Test basic function of gzencode
19 */
20
21include(dirname(__FILE__) . '/data.inc');
22
23echo "*** Testing gzencode() : basic functionality ***\n";
24
25// Initialise all required variables
26
27$smallstring = "A small string to compress\n";
28
29
30// Calling gzencode() with various compression levels
31
32// Compressing a big string
33for($i = -1; $i < 10; $i++) {
34    echo "-- Compression level $i --\n";
35    $output = gzencode($data, $i);
36
37    // Clear OS byte before encode
38	$output[9] = "\x00";
39
40    var_dump(md5($output));
41}
42
43// Compressing a smaller string
44for($i = -1; $i < 10; $i++) {
45    echo "-- Compression level $i --\n";
46    $output = gzencode($smallstring, $i);
47
48    // Clear OS byte before encode
49	$output[9] = "\x00";
50
51    var_dump(md5($output));
52}
53
54?>
55===Done===
56--EXPECTF--
57*** Testing gzencode() : basic functionality ***
58-- Compression level -1 --
59string(32) "d9ede02415ce91d21e5a94274e2b9c42"
60-- Compression level 0 --
61string(32) "67aaf60426bb2cbd86d7fe530cb12306"
62-- Compression level 1 --
63string(32) "bce9c439cf767c1988ff4881b287d1ce"
64-- Compression level 2 --
65string(32) "7ddbfed63a76c42808722b66f1c133fc"
66-- Compression level 3 --
67string(32) "ca2b85d194dfa2a4e8a162b646c99265"
68-- Compression level 4 --
69string(32) "cfe28033eaf260bc33ddc04b53d3ba39"
70-- Compression level 5 --
71string(32) "ae357fada2b515422f8bea0aa3bcc48f"
72-- Compression level 6 --
73string(32) "d9ede02415ce91d21e5a94274e2b9c42"
74-- Compression level 7 --
75string(32) "d9ede02415ce91d21e5a94274e2b9c42"
76-- Compression level 8 --
77string(32) "d9ede02415ce91d21e5a94274e2b9c42"
78-- Compression level 9 --
79string(32) "d9ede02415ce91d21e5a94274e2b9c42"
80-- Compression level -1 --
81string(32) "f77bd31e1e4dd11d12828fb661a08010"
82-- Compression level 0 --
83string(32) "36220d650930849b67e8e0622f9bf270"
84-- Compression level 1 --
85string(32) "f77bd31e1e4dd11d12828fb661a08010"
86-- Compression level 2 --
87string(32) "f77bd31e1e4dd11d12828fb661a08010"
88-- Compression level 3 --
89string(32) "f77bd31e1e4dd11d12828fb661a08010"
90-- Compression level 4 --
91string(32) "f77bd31e1e4dd11d12828fb661a08010"
92-- Compression level 5 --
93string(32) "f77bd31e1e4dd11d12828fb661a08010"
94-- Compression level 6 --
95string(32) "f77bd31e1e4dd11d12828fb661a08010"
96-- Compression level 7 --
97string(32) "f77bd31e1e4dd11d12828fb661a08010"
98-- Compression level 8 --
99string(32) "f77bd31e1e4dd11d12828fb661a08010"
100-- Compression level 9 --
101string(32) "f77bd31e1e4dd11d12828fb661a08010"
102===Done===