/tclzlib/tests/zlib.test

http://flightaware-tcltools.googlecode.com/ · Unknown · 56 lines · 47 code · 9 blank · 0 comment · 0 complexity · 204c23eecfb16a75092ea02464db1484 MD5 · raw file

  1. # Commands covered: sha1
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands. Sourcing this file into Tcl runs the tests and
  5. # generates output for errors. No output means no errors were found.
  6. #
  7. # Copyright (c) 2000 by Scriptics Corporation.
  8. #
  9. # See the file "license.terms" for information on usage and redistribution
  10. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. #
  12. # RCS: @(#) $Id: zlib.test,v 1.1.1.1 2007-11-19 23:31:49 karl Exp $
  13. if {[lsearch [namespace children] ::tcltest] == -1} {
  14. package require tcltest
  15. namespace import ::tcltest::*
  16. }
  17. package require zlib
  18. test zlib-1.1 {incorrect command usage} {
  19. list [catch {zlib} errMsg] $errMsg
  20. } {1 {wrong # args: should be "zlib option data ?...?"}}
  21. test zlib-1.2 {adler32 checksum} {
  22. zlib adler32 foobar
  23. } {145425018}
  24. test zlib-1.3 {CRC32 checksum} {
  25. zlib crc32 foobar
  26. } {-1628037227}
  27. test zlib-1.4 {compress / decompress test} {
  28. set in "blablablablab"
  29. set compressed [zlib compress $in]
  30. set out [zlib decompress $compressed]
  31. if { ![string equal $in $out] } {
  32. return mismatch
  33. }
  34. return match
  35. } {match}
  36. test zlib-1.4 {deflate / inflate test} {
  37. set in "blablablablab"
  38. set compressed [zlib deflate $in]
  39. set out [zlib inflate $compressed]
  40. if { ![string equal $in $out] } {
  41. return mismatch
  42. }
  43. return match
  44. } {match}
  45. # cleanup
  46. ::tcltest::cleanupTests
  47. return