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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
# The file tests the jim-zlib.c file; based on tests/zlib.test from Tcl 8.6.
#
# This file contains a collection of tests for one or more of the Tcl built-in
# commands. Sourcing this file into Tcl runs the tests and generates output
# for errors. No output means no errors were found.
#
# Copyright (c) 1996-1998 by Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
source [file dirname [info script]]/testing.tcl
source [file dirname [info script]]/testing.tcl
needs cmd zlib
test zlib-1.1 {zlib deflate usage 1} -returnCodes error -body {
zlib deflate
} -result {wrong # args: should be "zlib deflate string ?level?"}
test zlib-1.2 {zlib deflate usage 2} -returnCodes error -body {
zlib deflate a b
} -result {expected integer but got "b"}
test zlib-1.3 {zlib deflate usage 3} -returnCodes error -body {
zlib deflate a b c
} -result {wrong # args: should be "zlib deflate string ?level?"}
test zlib-1.4 {zlib inflate usage 1} -returnCodes error -body {
zlib inflate
} -result {wrong # args: should be "zlib inflate data ?bufferSize?"}
test zlib-1.5 {zlib inflate usage 2} -returnCodes error -body {
zlib inflate afdfdfdsfdsfsd
} -result {invalid stored block lengths}
test zlib-1.6 {zlib inflate usage 3} -returnCodes error -body {
zlib inflate afdfdfdsfdsfsd f
} -result {expected integer but got "f"}
test zlib-1.7 {zlib inflate usage 4} -returnCodes error -body {
zlib inflate afdfdfdsfdsfsd 0
} -result {buffer size must be 0 to 2147483647}
test zlib-2.1 {zlib deflate/inflate} {
zlib inflate [zlib deflate abcdefghijklm]
} abcdefghijklm
test zlib-2.2 {zlib deflate/inflate level and size known} {
zlib inflate [zlib deflate abcdefghijklm 9] 13
} abcdefghijklm
test zlib-2.3 {zlib deflate/inflate bad size} -returnCodes error -body {
zlib inflate [zlib deflate abcdefghijklm 9] 0
} -result {buffer size must be 0 to 2147483647}
test zlib-2.4 {zlib deflate/inflate wrong size} {
zlib inflate [zlib deflate abcdefghijklm] 6
} abcdefghijklm
test zlib-3.1 {zlib gunzip usage 1} -returnCodes error -body {
zlib gunzip
} -result {wrong # args: should be "zlib gunzip data ?-buffersize size?"}
test zlib-3.2 {zlib gunzip usage 2} -returnCodes error -body {
zlib gunzip aaa
} -result {incorrect header check}
test zlib-3.3 {zlib gunzip usage 3} -returnCodes error -body {
zlib gunzip aaa 4
} -result {wrong # args: should be "zlib gunzip data ?-buffersize size?"}
test zlib-3.4 {zlib gunzip usage 4} -returnCodes error -body {
zlib gunzip aaa -buffersize
} -result {wrong # args: should be "zlib gunzip data ?-buffersize size?"}
test zlib-3.5 {zlib gunzip usage 5} -returnCodes error -body {
zlib gunzip aaa -buffersize a
} -result {wrong # args: should be "zlib gunzip data ?-buffersize size?"}
test zlib-3.6 {zlib gunzip usage 5} -returnCodes error -body {
zlib gunzip aaa -buffersize a
} -result {wrong # args: should be "zlib gunzip data ?-buffersize size?"}
test zlib-3.7 {zlib gunzip usage 6} -returnCodes error -body {
zlib gunzip aaa -buffersize 0
} -result {buffer size must be 0 to 2147483647}
test zlib-3.8 {zlib gzip usage 1} -returnCodes error -body {
zlib gzip
} -result {wrong # args: should be "zlib gzip data ?-level level?"}
test zlib-3.9 {zlib gzip usage 2} -returnCodes error -body {
zlib gzip aa 9
} -result {wrong # args: should be "zlib gzip data ?-level level?"}
test zlib-3.10 {zlib gzip usage 3} -returnCodes error -body {
zlib gzip -level a
} -result {wrong # args: should be "zlib gzip data ?-level level?"}
test zlib-3.11 {zlib gzip usage 4} -returnCodes error -body {
zlib gzip -level 9 a
} -result {wrong # args: should be "zlib gzip data ?-level level?"}
test zlib-3.7 {zlib gunzip bad option} -returnCodes error -body {
zlib gunzip aaa -badoption
} -result {wrong # args: should be "zlib gunzip data ?-buffersize size?"}
test zlib-4.1 {zlib gzip/gunzip} {
zlib gunzip [zlib gzip abcdefghijklm]
} abcdefghijklm
test zlib-4.2 {zlib gzip/gunzip level and chunk size} {
zlib gunzip [zlib gzip abcdefghijklm -level 9] -buffersize 128
} abcdefghijklm
test zlib-4.3 {zlib gzip/gunzip bad level } -body {
zlib gzip abcdefghijklm -level -5
} -returnCodes error -result {level must be 0 to 9}
test zlib-4.4 {zlib gzip/gunzip bad level } -body {
zlib gzip abcdefghijklm -level 10
} -returnCodes error -result {level must be 0 to 9}
test zlib-4.5 {zlib gzip/gunzip non-int level } -body {
zlib gzip abcdefghijklm -level "abc"
} -returnCodes error -result {wrong # args: should be "zlib gzip data ?-level level?"}
test zlib-5.1 {zlib crc32} {
format %x [expr {[zlib crc32 abcdeabcdeabcdeabcdeabcdeabcde] & 0xffffffff}]
} 6f73e901
test zlib-5.2 {zlib crc32} {
format %x [expr {[zlib crc32 abcdeabcdeabcdeabcdeabcdeabcde 42] & 0xffffffff}]
} ce1c4914
test zlib-5.3 {zlib crc32 non-int arg} -body {
zlib crc32 abcdeabcdeabcdeabcdeabcdeabcde "abc"
} -returnCodes error -result {expected integer but got "abc"}
testreport
|