File: fifo.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 (80 lines) | stat: -rw-r--r-- 1,955 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
80
# -*- tcl -*-
# Commands covered:	None, introductory text
#
# This file contains a collection of tests for one or more of the commands
# the piTcl extension. Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 1998 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.test,v 1.4 1999/09/18 13:36:06 aku Exp $

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


test fifo-basics-1.0 {Create memory fifo channels} {
    set m [fifo]
    close $m
    regsub -all {[0-9]} $m {} m
    set m
} {fifo}

if {0} {
    # Neither tell nor seek possible

    test fifo-basics-1.1 {Check tell on memory fifo channels} {
	set m [fifo]
	set res [tell $m]
	close $m
	set res
    } {0}

    test fifo-basics-1.2 {Check seek on memory fifo channels} {
	set m [fifo]
	set res [seek $m 0]
	close $m
	set res
    } {}
}

test fifo-basics-1.3 {Check fconfigure/get on memory fifo channels} {
    set m [fifo]
    set conf [fconfigure $m]
    set res [list]
    lappend res [lrange $conf [set x [lsearch -exact $conf -length]] [incr x]]
    lappend res [lrange $conf [set x [lsearch -exact $conf -allocated]] [incr x]]
    close $m
    set res
} {{-length 0} {-allocated 0}}

test fifo-basics-1.4 {Check fconfigure/get -length} {
    set m [fifo]
    set res [fconfigure $m -length]
    close $m
    set res
} {0}


test fifo-readwrite-1.0 {Write and length} {
    set m [fifo]
    puts -nonewline $m {hello world}
    set res [list [fconfigure $m -length]]
    close $m
    set res
} {11}

test fifo-readwrite-1.1 {Write and read} {
    set m [fifo]
    puts -nonewline $m {hello world!}
    set res [list [fconfigure $m -length]]
    lappend res [read $m]
    close $m
    set res
} {12 {hello world!}}


catch {unset m}
catch {unset res}