summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/struct/graph/tests/node/attr.test
diff options
context:
space:
mode:
Diffstat (limited to 'tcllib/modules/struct/graph/tests/node/attr.test')
-rw-r--r--tcllib/modules/struct/graph/tests/node/attr.test97
1 files changed, 97 insertions, 0 deletions
diff --git a/tcllib/modules/struct/graph/tests/node/attr.test b/tcllib/modules/struct/graph/tests/node/attr.test
new file mode 100644
index 0000000..fab276e
--- /dev/null
+++ b/tcllib/modules/struct/graph/tests/node/attr.test
@@ -0,0 +1,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
+} {}
+
+# ---------------------------------------------------