Tk Library Source Code

Artifact [b031ab6b53]
Login

Artifact b031ab6b53c6dc6656dfa22b69314fe70e7c0dc0:

Attachment "crc32bugs.test" to ticket [709375ffff] added by patthoyts 2003-03-31 16:38:36.
# crc32bugs.test - Copyright (C) 2002 Pat Thoyts <[email protected]>
#
# Bug finding for crc32 module.
#
# -------------------------------------------------------------------------
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# -------------------------------------------------------------------------
# RCS: @(#) $Id$

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

package require crc32
package require crc16

test crcbugs-0.0 {get platform info - THIS IS SUPPOSED TO FAIL} {
    array get tcl_platform
} {}

foreach {n msg expected} {
    1  ""                 "0 0"
    2  "\x00"             "d202ef8d d202ef8d"
    3  "\x00\x00"         "41d912ff 41d912ff"
    4  "\x00\x00\x00"     "ff41d912 ff41d912"
    5  "\x00\x00\x00\x00" "2144df1c 2144df1c"
    6  "\xFF"             "ff000000 ff000000"
    7  "\xFF\xFF"         "ffff0000 ffff0000"
    8  "\xFF\xFF\xFF"     "ffffff00 ffffff00"
    9  "\xFF\xFF\xFF\xFF" "ffffffff ffffffff"
   10  "\x00\x00\x00\x01" "5643ef8a 5643ef8a"
   11  "\x80\x00\x00\x00" "cc1d6927 cc1d6927"    
} {
    test crc32bugs-2.$n {crc32 and crc-32 comparison} {
	list [catch {
            list \
                [::crc::crc32 -format %x $msg] \
                [::crc::crc-32 -format %x $msg]
        } msg] $msg
    } [list 0 $expected]
}

# -------------------------------------------------------------------------

::tcltest::cleanupTests

# Local Variables:
#  mode: tcl
#  indent-tabs-mode: nil
# End: