1 | # Commands covered: Rappture::library |
---|
2 | # |
---|
3 | # This file contains a collection of tests for one of the Rappture Tcl |
---|
4 | # commands. Sourcing this file into Tcl runs the tests and |
---|
5 | # generates output for errors. No output means no errors were found. |
---|
6 | # |
---|
7 | # ====================================================================== |
---|
8 | # AUTHOR: Derrick Kearney, Purdue University |
---|
9 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
10 | # |
---|
11 | # See the file "license.terms" for information on usage and redistribution |
---|
12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | |
---|
14 | |
---|
15 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
16 | package require tcltest |
---|
17 | package require Rappture |
---|
18 | namespace import -force ::tcltest::* |
---|
19 | } |
---|
20 | catch {unset lib} |
---|
21 | |
---|
22 | #---------------------------------------------------------- |
---|
23 | # put command |
---|
24 | # put "?-append yes? ?-id num? ?<path>? <string>" |
---|
25 | #---------------------------------------------------------- |
---|
26 | # MMc's original code does not make <string> a required argument |
---|
27 | # even though the command howto makes it seem required |
---|
28 | #test library-4.0.1 {put command valid path 0 arg} { |
---|
29 | # catch {unset libPut} |
---|
30 | # set libPut [Rappture::library rplib_test.xml] |
---|
31 | # $libPut put |
---|
32 | # $libPut xml |
---|
33 | #} {<run></run>} |
---|
34 | test library-4.0.1 {put command valid path 0 arg} { |
---|
35 | catch {unset libPut} |
---|
36 | set libPut [Rappture::library rplib_test.xml] |
---|
37 | list [catch {$libPut put} msg] $msg |
---|
38 | } {1 {wrong # args: should be "put ?-append bval? ?-id num? ?-type string|file? ?-compress bval? ?path? string"}} |
---|
39 | test library-4.1.1 {put command valid path 1 arg} { |
---|
40 | catch {unset libPut} |
---|
41 | set libPut [Rappture::library rplib_test.xml] |
---|
42 | list [catch {$libPut put "input.test1" } msg] $msg |
---|
43 | } {0 {}} |
---|
44 | test library-4.1.2 {put command valid path 1 arg with id} { |
---|
45 | catch {unset libPut} |
---|
46 | set libPut [Rappture::library rplib_test.xml] |
---|
47 | list [catch {$libPut put "input.test2(withId)"} msg] $msg |
---|
48 | } {0 {}} |
---|
49 | test library-4.1.3 {put command valid path 2 arg} { |
---|
50 | catch {unset libPut} |
---|
51 | set libPut [Rappture::library rplib_test.xml] |
---|
52 | $libPut put "input.test" "val1" |
---|
53 | $libPut get "input.test" |
---|
54 | } {val1} |
---|
55 | test library-4.1.4 {put command valid path 2 arg with id} { |
---|
56 | catch {unset libPut} |
---|
57 | set libPut [Rappture::library rplib_test.xml] |
---|
58 | $libPut put "input.test(withId)" "val1" |
---|
59 | $libPut put "input.test(withNewId)" "val2" |
---|
60 | $libPut get "input.test" |
---|
61 | } {val1} |
---|
62 | test library-4.1.5 {put command valid path 2 arg} { |
---|
63 | catch {unset libPut} |
---|
64 | set libPut [Rappture::library rplib_test.xml] |
---|
65 | $libPut put "input.test(withId)" "val1" |
---|
66 | $libPut put "input.test(withNewId)" "val2" |
---|
67 | $libPut get "input.test(withId)" |
---|
68 | } {val1} |
---|
69 | test library-4.1.6 {put command valid path 2 arg} { |
---|
70 | catch {unset libPut} |
---|
71 | set libPut [Rappture::library rplib_test.xml] |
---|
72 | $libPut put "input.test(withId)" "val1" |
---|
73 | $libPut put "input.test(withNewId)" "val2" |
---|
74 | $libPut get "input.test(withNewId)" |
---|
75 | } {val2} |
---|
76 | test library-4.2.1 {put command test append yes} { |
---|
77 | catch {unset libPut} |
---|
78 | set libPut [Rappture::library rplib_test.xml] |
---|
79 | $libPut put "input.test(withId)" "val1" |
---|
80 | $libPut put -append yes "input.test(withId)" "val2" |
---|
81 | $libPut get "input.test(withId)" |
---|
82 | } {val1val2} |
---|
83 | test library-4.2.2 {put command test append no} { |
---|
84 | catch {unset libPut} |
---|
85 | set libPut [Rappture::library rplib_test.xml] |
---|
86 | $libPut put "input.test(withId)" "val1" |
---|
87 | $libPut put -append no "input.test(withId)" "val2" |
---|
88 | $libPut get "input.test(withId)" |
---|
89 | } {val2} |
---|
90 | test library-4.2.3 {put command test append blank} { |
---|
91 | catch {unset libPut} |
---|
92 | set libPut [Rappture::library rplib_test.xml] |
---|
93 | $libPut put "input.test(withId)" "val1" |
---|
94 | list [catch {$libPut put -append "input.test(withId)" "val2"} msg] $msg |
---|
95 | # $libPut xml |
---|
96 | } {1 {expected boolean value but got "input.test(withId)"}} |
---|
97 | test library-4.2.5 {put command test append junk} { |
---|
98 | catch {unset libPut} |
---|
99 | set libPut [Rappture::library rplib_test.xml] |
---|
100 | $libPut put "input.test(withId)" "val1" |
---|
101 | list [catch {$libPut put -append junk "input.test(withId)" "val2"} msg] $msg |
---|
102 | # $libPut xml |
---|
103 | } {1 {expected boolean value but got "junk"}} |
---|
104 | test library-4.2.6 {put command test append = "1"} { |
---|
105 | catch {unset libPut} |
---|
106 | set libPut [Rappture::library rplib_test.xml] |
---|
107 | set path "input.test(withId)" |
---|
108 | $libPut put $path "val1" |
---|
109 | set rslt [list [catch {$libPut put -append 1 $path "val2"} msg] $msg] |
---|
110 | if {![lrange $rslt 0 0]} { |
---|
111 | lappend rslt [$libPut get $path] |
---|
112 | } |
---|
113 | set rslt |
---|
114 | } {0 {} val1val2} |
---|
115 | test library-4.2.7 {put command test append = "0"} { |
---|
116 | catch {unset libPut} |
---|
117 | set libPut [Rappture::library rplib_test.xml] |
---|
118 | set path "input.test(withId)" |
---|
119 | $libPut put $path "val1" |
---|
120 | set rslt [list [catch {$libPut put -append 0 $path "val2"} msg] $msg] |
---|
121 | if {![lrange $rslt 0 0]} { |
---|
122 | lappend rslt [$libPut get $path] |
---|
123 | } |
---|
124 | set rslt |
---|
125 | } {0 {} val2} |
---|
126 | test library-4.2.8 {put command test append = "true"} { |
---|
127 | catch {unset libPut} |
---|
128 | set libPut [Rappture::library rplib_test.xml] |
---|
129 | set path "input.test(withId)" |
---|
130 | $libPut put $path "val1" |
---|
131 | set rslt [list [catch {$libPut put -append true $path "val2"} msg] $msg] |
---|
132 | if {![lrange $rslt 0 0]} { |
---|
133 | lappend rslt [$libPut get $path] |
---|
134 | } |
---|
135 | set rslt |
---|
136 | } {0 {} val1val2} |
---|
137 | test library-4.2.9 {put command test append = "false"} { |
---|
138 | catch {unset libPut} |
---|
139 | set libPut [Rappture::library rplib_test.xml] |
---|
140 | set path "input.test(withId)" |
---|
141 | $libPut put $path "val1" |
---|
142 | set rslt [list [catch {$libPut put -append false $path "val2"} msg] $msg] |
---|
143 | if {![lrange $rslt 0 0]} { |
---|
144 | lappend rslt [$libPut get $path] |
---|
145 | } |
---|
146 | set rslt |
---|
147 | } {0 {} val2} |
---|
148 | test library-4.3.1 {put command valid path 3 arg} { |
---|
149 | catch {unset libPut} |
---|
150 | set libPut [Rappture::library rplib_test.xml] |
---|
151 | list [catch {$libPut put "input.test" "val1" "val2"} msg] $msg |
---|
152 | } {1 {wrong # args: should be "put ?-append bval? ?-id num? ?-type string|file? ?-compress bval? ?path? string"}} |
---|
153 | |
---|
154 | |
---|
155 | ::tcltest::cleanupTests |
---|
156 | return |
---|