Annotation of embedaddon/php/ext/zlib/tests/gzcompress_basic1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test gzcompress() 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 gzcompress(string data [, int level])
        !            12:  * Description: Gzip-compress a string 
        !            13:  * Source code: ext/zlib/zlib.c
        !            14:  * Alias to functions: 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  * add a comment here to say what the test is supposed to do
        !            19:  */
        !            20: 
        !            21: include(dirname(__FILE__) . '/data.inc');
        !            22: 
        !            23: echo "*** Testing gzcompress() : basic functionality ***\n";
        !            24: 
        !            25: // Initialise all required variables
        !            26: 
        !            27: $smallstring = "A small string to compress\n";
        !            28: 
        !            29: 
        !            30: // Calling gzcompress() with all possible arguments
        !            31: 
        !            32: // Compressing a big string
        !            33: for($i = -1; $i < 10; $i++) {
        !            34:     echo "-- Compression level $i --\n";
        !            35:     $output = gzcompress($data, $i);
        !            36:     var_dump(md5($output));
        !            37:        var_dump(strcmp(gzuncompress($output), $data));
        !            38: }
        !            39: 
        !            40: // Compressing a smaller string
        !            41: for($i = -1; $i < 10; $i++) {
        !            42:     echo "-- Compression level $i --\n";
        !            43:     $output = gzcompress($smallstring, $i);
        !            44:     var_dump(bin2hex($output));
        !            45:        var_dump(strcmp(gzuncompress($output), $smallstring));
        !            46: }
        !            47: 
        !            48: // Calling gzcompress() with mandatory arguments
        !            49: echo "\n-- Testing with no specified compression level --\n";
        !            50: var_dump( bin2hex(gzcompress($smallstring) ));
        !            51: 
        !            52: ?>
        !            53: ===Done===
        !            54: --EXPECT--
        !            55: *** Testing gzcompress() : basic functionality ***
        !            56: -- Compression level -1 --
        !            57: string(32) "764809aef15bb34cb73ad49ecb600d99"
        !            58: int(0)
        !            59: -- Compression level 0 --
        !            60: string(32) "d0136b3fb5424142c0eb26dfec8f56fe"
        !            61: int(0)
        !            62: -- Compression level 1 --
        !            63: string(32) "c2e070f4320d1f674965eaab95b53d9c"
        !            64: int(0)
        !            65: -- Compression level 2 --
        !            66: string(32) "400a53d19ca337727f8cd362f5cd3ee0"
        !            67: int(0)
        !            68: -- Compression level 3 --
        !            69: string(32) "a441a2f5169bb303cd45b860a5a9dbf9"
        !            70: int(0)
        !            71: -- Compression level 4 --
        !            72: string(32) "d5b7451e9de2864beccc9de1fc55eb87"
        !            73: int(0)
        !            74: -- Compression level 5 --
        !            75: string(32) "32ba4a01120449ec25508cabfad41f56"
        !            76: int(0)
        !            77: -- Compression level 6 --
        !            78: string(32) "764809aef15bb34cb73ad49ecb600d99"
        !            79: int(0)
        !            80: -- Compression level 7 --
        !            81: string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
        !            82: int(0)
        !            83: -- Compression level 8 --
        !            84: string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
        !            85: int(0)
        !            86: -- Compression level 9 --
        !            87: string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
        !            88: int(0)
        !            89: -- Compression level -1 --
        !            90: string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !            91: int(0)
        !            92: -- Compression level 0 --
        !            93: string(76) "7801011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a87a509cb"
        !            94: int(0)
        !            95: -- Compression level 1 --
        !            96: string(70) "7801735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !            97: int(0)
        !            98: -- Compression level 2 --
        !            99: string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           100: int(0)
        !           101: -- Compression level 3 --
        !           102: string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           103: int(0)
        !           104: -- Compression level 4 --
        !           105: string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           106: int(0)
        !           107: -- Compression level 5 --
        !           108: string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           109: int(0)
        !           110: -- Compression level 6 --
        !           111: string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           112: int(0)
        !           113: -- Compression level 7 --
        !           114: string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           115: int(0)
        !           116: -- Compression level 8 --
        !           117: string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           118: int(0)
        !           119: -- Compression level 9 --
        !           120: string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           121: int(0)
        !           122: 
        !           123: -- Testing with no specified compression level --
        !           124: string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
        !           125: ===Done===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>