Artifact
f0337cca514d1c1d861787ad8e553b87b0c1136e:
Attachment "crc32.test" to
ticket [501339ffff]
added by
patthoyts
2002-01-09 22:25:39.
# crc32.test: tests for the crc32 commands
#
# By Pat Thoyts <[email protected]>, ...
#
# RCS: @(#) $Id$
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import ::tcltest::*
}
package require crc32
test crc32-1.0 {crc32 with no parameters } {
catch {::crc32::crc32} result
set result
} {no value given for parameter "instr" to "::crc32::crc32"}
foreach {n msg expected} {
1 ""
"0"
2 "a"
"3904355907"
3 "abc"
"891568578"
4 "message digest"
"538287487"
5 "abcdefghijklmnopqrstuvwxyz"
"1277644989"
6 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
"532866770"
7 "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
"2091469426"
8 "\uFFFE\u0000\u0001\u0002"
"2968055525"
} {
test crc32-2.$n {crc32 and unsigned integer} {
::crc32::crc32 $msg
} $expected ; # {}
}
foreach {n msg expected} {
1 ""
"0x0"
2 "a"
"0xE8B7BE43"
3 "abc"
"0x352441C2"
4 "message digest"
"0x20159D7F"
5 "abcdefghijklmnopqrstuvwxyz"
"0x4C2750BD"
6 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
"0x1FC2E6D2"
7 "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
"0x7CA94A72"
8 "\uFFFE\u0000\u0001\u0002"
"0xB0E8EEE5"
} {
test crc32-3.$n {crc32 as hexadecimal string} {
::crc32::crc32 $msg 0x%X
} $expected ; # {}
}
::tcltest::cleanupTests
# Local Variables:
# mode: tcl
# indent-tabs-mode: nil
# End: