1 | # Commands covered: |
---|
2 | # Rappture::Gauge |
---|
3 | # Rappture::Gauge::value |
---|
4 | # |
---|
5 | # This file contains a collection of tests for one of the Rappture Tcl |
---|
6 | # commands. Sourcing this file into Tcl runs the tests and |
---|
7 | # generates output for errors. No output means no errors were found. |
---|
8 | # |
---|
9 | # ====================================================================== |
---|
10 | # AUTHOR: Derrick Kearney, Purdue University |
---|
11 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
12 | # |
---|
13 | # See the file "license.terms" for information on usage and redistribution |
---|
14 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
15 | |
---|
16 | |
---|
17 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
18 | package require tcltest |
---|
19 | package require RapptureGUI |
---|
20 | namespace import -force ::tcltest::* |
---|
21 | } |
---|
22 | |
---|
23 | |
---|
24 | #---------------------------------------------------------- |
---|
25 | #---------------------------------------------------------- |
---|
26 | # value command |
---|
27 | # |
---|
28 | # value |
---|
29 | # value <newval> |
---|
30 | # value -check <newval> |
---|
31 | #---------------------------------------------------------- |
---|
32 | test gauge.value.1 {value command, 0 args, default value is 0} \ |
---|
33 | -setup { |
---|
34 | set w [Rappture::Gauge .#auto] |
---|
35 | } -body { |
---|
36 | $w value |
---|
37 | } -cleanup { |
---|
38 | destroy $w |
---|
39 | catch {unset w} |
---|
40 | } -result {0} |
---|
41 | |
---|
42 | test gauge.value.2 {value command, 0 args, set value is returned} \ |
---|
43 | -setup { |
---|
44 | set w [Rappture::Gauge .#auto] |
---|
45 | $w value 4 |
---|
46 | } -body { |
---|
47 | $w value |
---|
48 | } -cleanup { |
---|
49 | destroy $w |
---|
50 | catch {unset w} |
---|
51 | } -result {4} |
---|
52 | |
---|
53 | test gauge.value.3 {value command, 1 args, set value, value is returned} \ |
---|
54 | -setup { |
---|
55 | set w [Rappture::Gauge .#auto] |
---|
56 | } -body { |
---|
57 | $w value 4 |
---|
58 | } -cleanup { |
---|
59 | destroy $w |
---|
60 | catch {unset w} |
---|
61 | } -result {4} |
---|
62 | |
---|
63 | test gauge.value.4 {value command, just -check flag, value is returned} \ |
---|
64 | -setup { |
---|
65 | set w [Rappture::Gauge .#auto] |
---|
66 | } -body { |
---|
67 | $w value -check |
---|
68 | } -cleanup { |
---|
69 | destroy $w |
---|
70 | catch {unset w} |
---|
71 | } -result {0} |
---|
72 | |
---|
73 | test gauge.value.5 {value command, invalid flag, return error} \ |
---|
74 | -setup { |
---|
75 | set w [Rappture::Gauge .#auto] |
---|
76 | } -body { |
---|
77 | list [catch {$w value -chcek} msg] $msg |
---|
78 | } -cleanup { |
---|
79 | destroy $w |
---|
80 | catch {unset w} |
---|
81 | } -result {1 {bad value "-chcek": should be a real number}} |
---|
82 | |
---|
83 | ::tcltest::cleanupTests |
---|
84 | return |
---|