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
|
# -*- tcl -*-
# Graph tests - graph/arc/node get (attribute get)
# Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
# RCS: @(#) $Id: get.test,v 1.3 2008/03/07 06:51:36 andreas_kupries Exp $
# Syntax: graph get KEY
# Syntax: graph arc get ARC KEY
# Syntax: graph node get NODE KEY
# -------------------------------------------------------------------------
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}-get-1.0 "$e get, wrong#args, missing" {
SETUP
catch {CMD get} msg
mygraph destroy
set msg
} [tmWrongA "${mp}get" "${mp}key" 0] ; # {}
test graph-${impl}-${setimpl}-${e}-get-1.1 "$e get, wrong#args, missing" !graph {
SETUP
catch {CMD get x} msg
mygraph destroy
set msg
} [tmWrongA "${mp}get" "${mp}key" 1] ; # {}
test graph-${impl}-${setimpl}-${e}-get-1.2 "$e get, wrong#args, too many" {
SETUP
catch {CMD get x y z} msg
mygraph destroy
set msg
} [tmTooManyA "${mp}get" "${mp}key"] ; # {}
# -------------------------------------------------------------------------
# Logical arguments checks and failures
test graph-${impl}-${setimpl}-${e}-get-2.0 "$e get, missing $e" !graph {
SETUP
catch {Get$ex data} msg
mygraph destroy
set msg
} [Missing$ex $MY x] ; # {}
test graph-${impl}-${setimpl}-${e}-get-2.1 "$e get, no attributes" {
SETUP
$ex
catch {Get$ex bogus} msg
mygraph destroy
set msg
} [MissingKey $mk $e bogus] ; # {}
test graph-${impl}-${setimpl}-${e}-get-2.2 "$e get, missing key" {
SETUP
$ex
SetW$ex foo far
catch {Get$ex bogus} msg
mygraph destroy
set msg
} [MissingKey $mk $e bogus] ; # {}
# -------------------------------------------------------------------------
# Ok arguments.
test graph-${impl}-${setimpl}-${e}-get-2.4 "$e get" {
SETUP
$ex
SetW$ex boom foobar
set result [Get$ex boom]
mygraph destroy
set result
} foobar ; # {}
}
# -------------------------------------------------------------------------
|