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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
# -*- tcl -*-
# Graph tests - node attr
# Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
# RCS: @(#) $Id: attr.test,v 1.2 2007/04/12 03:01:56 andreas_kupries Exp $
# Syntax: graph node attr KEY ?-nodes NODESLIST|-glob PATTERN|-regexp PATTERN?
# -------------------------------------------------------------------------
# Wrong # args: Missing, Too many
test graph-${impl}-${setimpl}-node-attr-1.0 {node attr, wrong#args, missing} {
SETUPx
catch {mygraph node attr} msg
mygraph destroy
set msg
} [tmWrong {node attr} {key ?-nodes list|-glob pattern|-regexp pattern?} 0 {key args}]
test graph-${impl}-${setimpl}-node-attr-1.1 {node attr, wrong#args, missing} {
SETUPx
catch {mygraph node attr a b} msg
mygraph destroy
set msg
} "wrong # args: should be \"$MY node attr key ?-nodes list|-glob pattern|-regexp pattern?\""
test graph-${impl}-${setimpl}-node-attr-1.2 {node attr, wrong#args, too many} {
SETUPx
catch {mygraph node attr a b c d} msg
mygraph destroy
set msg
} "wrong # args: should be \"$MY node attr key ?-nodes list|-glob pattern|-regexp pattern?\""
# -------------------------------------------------------------------------
# Logical arguments checks and failures
test graph-${impl}-${setimpl}-node-attr-2.0 {node attr, bogus switch} {
SETUPx
catch {mygraph node attr a -foo barf} msg
mygraph destroy
set msg
} {bad type "-foo": must be -glob, -nodes, or -regexp}
# -------------------------------------------------------------------------
# Ok arguments.
test graph-${impl}-${setimpl}-node-attr-3.4 {node attr, unfiltered, nothing} {
SETUPx
set result [mygraph node attr vol]
mygraph destroy
set result
} {}
test graph-${impl}-${setimpl}-node-attr-3.5 {node attr, unfiltered something} {
SETUPx
set result [dictsort [mygraph node attr volume]]
mygraph destroy
set result
} {%0 30 %5 50}
test graph-${impl}-${setimpl}-node-attr-3.6 {node attr, filtered -nodes} {
SETUPx
set result [mygraph node attr volume -nodes {%0 %3}]
mygraph destroy
set result
} {%0 30}
test graph-${impl}-${setimpl}-node-attr-3.7 {node attr, filtered -glob} {
SETUPx
set result [mygraph node attr volume -glob {%[0-3]}]
mygraph destroy
set result
} {%0 30}
test graph-${impl}-${setimpl}-node-attr-3.8 {node attr, filtered regexp} {
SETUPx
set result [mygraph node attr volume -regexp {[0-3]}]
mygraph destroy
set result
} {%0 30}
test graph-${impl}-${setimpl}-node-attr-3.9 {node attr, filtered -nodes nothing} {
SETUPx
set result [mygraph node attr volume -nodes {}]
mygraph destroy
set result
} {}
test graph-${impl}-${setimpl}-node-attr-3.10 {node attr, nothing} {
SETUPx
mygraph node unset %0 volume
mygraph node unset %5 volume
set result [mygraph node attr volume]
mygraph destroy
set result
} {}
# ---------------------------------------------------
|