# -*- tcl -*- # Commands covered: fifo # # This file contains a collection of tests for one or more of the commands # the Memchan extension. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 1999 Andreas Kupries (a.kupries@westend.com) # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # $Id: fifo_bb.test,v 1.1 1999/09/18 13:36:03 aku Exp $ test fifo-basic-1.0 {Create memory fifo channels} { set chan [fifo] close $chan regsub -all {[0-9]} $chan {} chan set chan } {fifo} # Neither tell nor seek possible for fifos test fifo-basic-1.1 {Check tell on memory fifo channels} { set chan [fifo] set res [tell $chan] close $chan set res } {-1} test fifo-basic-1.2 {Check seek on memory fifo channels} { set chan [fifo] set res [catch {[seek $chan 0]} msg] close $chan list $res [regexp -nocase -- invalid $msg] } {1 1} test fifo-basic-1.3 {Check fconfigure/get on memory fifo channels} { set chan [fifo] set conf [fconfigure $chan] set res [list] lappend res [lrange $conf [set pos [lsearch -exact $conf -length]] [incr pos]] lappend res [lrange $conf [set pos [lsearch -exact $conf -allocated]] [incr pos]] close $chan set res } {{-length 0} {-allocated 0}} test fifo-basic-1.4 {Check fconfigure/get -length} { set chan [fifo] set res [fconfigure $chan -length] close $chan set res } {0} test fifo-rw-1.0 {Write and length} { set chan [fifo] puts -nonewline $chan {hello world} set res [list [fconfigure $chan -length]] close $chan set res } {11} test fifo-rw-1.1 {Write and read} { set chan [fifo] puts -nonewline $chan {hello world!} set res [list [fconfigure $chan -length]] lappend res [read $chan] close $chan set res } {12 {hello world!}} ::tcltest::cleanupTests