# -*- tcl -*-
# Commands covered:	none, common behaviour of message digests (dig_opt.c, digest.c)
#
# This file contains a collection of tests for one or more of the commands
# the TRF extension. Sourcing this file into Tcl runs the tests and generates
# output for errors.  No output means no errors were found.
#
# Copyright (c) 1996 Andreas Kupries (andreas_kupries@users.sourceforge.net)
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# $Id: common_md.test,v 1.2 2000/11/18 22:42:32 aku Exp $


# message digests: adler, crc, crc_zlib, haval, md5, md2, sha, rmd160, rmd128
# tests done with builtin digest 'crc'.

foreach {i opt ovalue} {
    0 mode              absorb
    1 matchflag         XX
    2 write-destination XX
    3 read-destination  XX
} {
    test common.md-1.$i "common md, argument errors" {
	catch {crc -$opt $ovalue -in stdin -out stdout} msg
	set msg
    } {immediate: no options allowed}
}

test common.md-2.0 "common md, argument errors" {
    catch {crc -attach stdout} msg
    set msg
} {attach: -mode not defined}

test common.md-2.0 "common md, argument errors" {
    catch {crc -attach stdout -mode XXX} msg
    set msg
} {unknown mode 'XXX', should be 'absorb', 'write' or 'transparent'}

test common.md-2.1 "common md, argument errors" {
    catch {crc -attach stdin -mode absorb} msg
    set msg
} {attach: -matchflag not defined}

test common.md-2.2 "common md, argument errors" {
    catch {crc -attach stdout -mode write -matchflag XX} msg
    set msg
} {attach: -matchflag not allowed}

test common.md-2.3 "common md, argument errors" {
    catch {crc -attach stdout -mode write} msg
    set msg
} {attach, external: -write-destination missing}

test common.md-2.4 "common md, argument errors" {
    catch {crc -attach stdin -mode write} msg
    set msg
} {attach, external: -read-destination missing}

test common.md-2.5 "common md, argument errors" {
    catch {crc -attach stdout -mode write -write-type XX} msg
    set msg
} {unknown target-type 'XX'}

test common.md-2.6 "common md, argument errors" {
    catch {crc -attach stdout -mode write -write-type channel -write-destination stdin} msg
    set msg
} {write destination channel 'stdin' not opened for writing}

test common.md-2.7 "common md, argument errors" {
    catch {crc -attach stdin -mode write -read-type channel -read-destination stdin} msg
    set msg
} {read destination channel 'stdin' not opened for writing}

test common.md-2.8 "common md, argument errors" {
    catch {crc -attach stdout -mode write -write-type channel -write-destination XXX} msg
    set msg
} {can not find channel named "XXX"}

test common.md-2.9 "common md, argument errors" {
    catch {crc -attach stdin -mode write -read-type channel -read-destination XXX} msg
    set msg
} {can not find channel named "XXX"}



::tcltest::cleanupTests
