# yencode.test - Copyright (C) 2002 Pat Thoyts <patthoyts@users.sourceforge.net>
#
# Tests for the Tcllib yencode package
#
# -------------------------------------------------------------------------
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# -------------------------------------------------------------------------
# RCS: @(#) $Id: yencode.test 381286 2003-05-01 22:40:19Z jigen $

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

package forget yencode
catch {namespace delete yencode}
if {[catch {source [file join [file dirname [info script]] yencode.tcl]} msg]} {
    puts "skipped [file tail [info script]]: $msg"
    return
}

puts "- yencode [package provide yencode] (pure Tcl)"

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

proc ::yencode::loaddata {filename {translation auto}} {
    set f [open $filename r]
    fconfigure $f -translation $translation
    set data [read $f]
    close $f
    return $data
}

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

set datafile [file join $::tcltest::testsDirectory yencode.test.data]

test yencode-1.0 {yencode yEnc test file} {
    set enc [::yencode::yencode -file $datafile]
    set dec [::yencode::ydecode $enc]
    set chk [::yencode::loaddata $datafile]
    string match $dec $chk
} {0}
    

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

catch {
    unset datafile
    rename ::yencode::loaddata {}
}
::tcltest::cleanupTests

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