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 keyexists (attribute keyexists)
# Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
# RCS: @(#) $Id: keyexists.test,v 1.3 2008/03/07 06:51:39 andreas_kupries Exp $
# Syntax: graph keyexists KEY
# Syntax: graph arc keyexists ARC KEY
# Syntax: graph node keyexists 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}-keyexists-1.0 "$e keyexists, wrong # args, missing" {
SETUP
catch {CMD keyexists} msg
mygraph destroy
set msg
} [tmWrongA "${mp}keyexists" "${mp}key" 0] ; # {}
test graph-${impl}-${setimpl}-${e}-keyexists-1.1 "$e keyexists, wrong # args, missing" !graph {
SETUP
catch {CMD keyexists a} msg
mygraph destroy
set msg
} [tmWrongA "${mp}keyexists" "${mp}key" 1] ; # {}
test graph-${impl}-${setimpl}-${e}-keyexists-1.2 "$e keyexists, wrong # args, too many" {
SETUP
catch {CMD keyexists a b c} msg
mygraph destroy
set msg
} [tmTooManyA "${mp}keyexists" "${mp}key"] ; # {}
# -------------------------------------------------------------------------
# Logical arguments checks and failures
test graph-${impl}-${setimpl}-${e}-keyexists-2.0 "$e keyexists, missing $e" !graph {
SETUP
catch {Keyexists$ex foo} msg
mygraph destroy
set msg
} [Missing$ex $MY x] ; # {}
# -------------------------------------------------------------------------
# Ok arguments.
test graph-${impl}-${setimpl}-${e}-keyexists-3.0 "$e keyexists, no attributes" {
SETUP
$ex
set result [Keyexists$ex bogus]
mygraph destroy
set result
} 0 ; # {}
test graph-${impl}-${setimpl}-${e}-keyexists-3.1 "$e keyexists, missing key" {
SETUP
$ex
SetW$ex ok ""
set result [Keyexists$ex bogus]
mygraph destroy
set result
} 0 ; # {}
test graph-${impl}-${setimpl}-${e}-keyexists-3.2 "$e keyexists, existing key" {
SETUP
$ex
SetW$ex ok ""
set result [Keyexists$ex ok]
mygraph destroy
set result
} 1 ; # {}
}
# -------------------------------------------------------------------------
|