summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/struct/graph/tests/attr/keys.test
diff options
context:
space:
mode:
Diffstat (limited to 'tcllib/modules/struct/graph/tests/attr/keys.test')
-rw-r--r--tcllib/modules/struct/graph/tests/attr/keys.test79
1 files changed, 79 insertions, 0 deletions
diff --git a/tcllib/modules/struct/graph/tests/attr/keys.test b/tcllib/modules/struct/graph/tests/attr/keys.test
new file mode 100644
index 0000000..e80c445
--- /dev/null
+++ b/tcllib/modules/struct/graph/tests/attr/keys.test
@@ -0,0 +1,79 @@
+# -*- tcl -*-
+# Graph tests - graph/arc/node keys (attribute keys)
+# Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>
+# All rights reserved.
+# RCS: @(#) $Id: keys.test,v 1.3 2008/03/07 06:51:39 andreas_kupries Exp $
+
+# Syntax: graph keys ?PATTERN?
+# Syntax: graph arc keys ARC ?PATTERN?
+# Syntax: graph node keys NODE ?PATTERN?
+
+# -------------------------------------------------------------------------
+
+foreach {e ex stem mp mk} {
+ arc Arc {mygraph arc} {arc } x
+ node Node {mygraph node} {node } x
+ graph Graph {mygraph} {} {}
+} {
+ AttrSetup
+
+ # -------------------------------------------------------------------------
+ # Wrong # args: Missing, Too many
+
+ test graph-${impl}-${setimpl}-${e}-keys-1.0 "$e keys, wrong # args, missing" !graph {
+ SETUP
+ catch {CMD keys} msg
+ mygraph destroy
+ set msg
+ } [tmWrongA "${mp}keys" "${mp}?pattern?" 0] ; # {}
+
+ test graph-${impl}-${setimpl}-${e}-keys-1.1 "$e keys, wrong # args, too many" {
+ SETUP
+ catch {CMD keys a b c} msg
+ mygraph destroy
+ set msg
+ } [tmTooManyA "${mp}keys" "${mp}?pattern?"] ; # {}
+
+ # -------------------------------------------------------------------------
+ # Logical arguments checks and failures
+
+ test graph-${impl}-${setimpl}-${e}-keys-2.0 "$e keys, missing $e" !graph {
+ SETUP
+ catch {Keys$ex} msg
+ mygraph destroy
+ set msg
+ } [Missing$ex $MY x] ; # {}
+
+ # -------------------------------------------------------------------------
+ # Ok arguments.
+
+ test graph-${impl}-${setimpl}-${e}-keys-3.0 "$e keys, no attributes, empty list result" {
+ SETUP
+ $ex
+ set results [Keys$ex]
+ mygraph destroy
+ set results
+ } {}
+
+ test graph-${impl}-${setimpl}-${e}-keys-3.1 "$e keys, list result" {
+ SETUP
+ $ex
+ SetW$ex data foobar
+ SetW$ex other thing
+ set results [Keys$ex]
+ mygraph destroy
+ lsort $results
+ } {data other}
+
+ test graph-${impl}-${setimpl}-${e}-keys-3.2 "$e keys, pattern match" {
+ SETUP
+ $ex
+ SetW$ex data foobar
+ SetW$ex other thing
+ set results [KeysP$ex d*]
+ mygraph destroy
+ set results
+ } data
+}
+
+# -------------------------------------------------------------------------