File: fifo_bb.test

package info (click to toggle)
memchan 2.3-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,868 kB
  • sloc: ansic: 3,320; sh: 990; tcl: 687; makefile: 51
file content (79 lines) | stat: -rw-r--r-- 1,992 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- 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