# -*- tcl -*-
# Commands covered:  bin
#
# This file contains a collection of tests for one or more of the trf
# commands of 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) 1995 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: bin.test,v 1.2 1997/07/22 20:32:49 aku Exp $

if {[string compare test [info procs test]] == 1} then {source defs}


test bin-2.0 {bin, conversion errors} {
    catch {bin -mode decode 101010020010101010200} msg
    set msg
} {illegal character '2' found in input}


foreach {index string fullencode encode} {
    1    hello 0110100001100101011011000110110001101111 0110100001100101011011000110110001101111
    2    hell` 0110100001100101011011000110110001100000 01101000011001010110110001101100011
} {
    test bin-3.$index {bin, encode string} {
	bin -mode encode $string
    } $fullencode	;#{}

    test bin-4.$index {bin, decode string} {
	bin -mode decode $encode
    } $string	;#{}

    # redundant tests following
    test bin-5.$index {bin, encode/decode identity} {
	bin -mode decode [bin -mode encode $string]
    } $string	;#{}

    test bin-6.$index {bin, decode/encode identity} {
	bin -mode encode [bin -mode decode $fullencode]
    } $fullencode	;#{}
}
