# -*- tcl -*-
# Commands covered:  oct
#
# 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: oct.test,v 1.2 1997/07/22 20:32:51 aku Exp $

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



test oct-2.0 {oct, conversion errors} {
    catch {oct -mode decode 101010090010101010200} msg
    set msg
} {illegal character '9' found in input}


foreach {index string fullencode encode} {
    1 hello 150145154154157 150145154154157
    2 hellh 150145154154150 15014515415415
} {
    test oct-3.$index {oct, encode string} {
	oct -mode encode $string
    } $fullencode	;#{}

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

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

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