source: branches/nanovis2/lang/tcl/tests/units.test @ 3305

Last change on this file since 3305 was 3305, checked in by ldelgass, 12 years ago

sync with trunk

File size: 46.5 KB
Line 
1# Commands covered:
2#   Rappture::Units::convert
3#   Rappture::Units::description
4#   Rappture::Units::System::for
5#   Rappture::Units::System::all
6#   Rappture::Units::Search::for
7#
8# This file contains a collection of tests for one of the Rappture Tcl
9# commands.  Sourcing this file into Tcl runs the tests and
10# generates output for errors.  No output means no errors were found.
11#
12# ======================================================================
13# AUTHOR:  Derrick Kearney, Purdue University
14# Copyright (c) 2004-2012  HUBzero Foundation, LLC
15#
16# See the file "license.terms" for information on usage and redistribution
17# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
18
19
20if {[lsearch [namespace children] ::tcltest] == -1} {
21    package require tcltest
22    package require Rappture
23    namespace import -force ::tcltest::*
24}
25catch {unset lib}
26
27proc check {var size} {
28    set l [llength $var]
29    if {$l != $size} {
30        return "length mismatch: should have been $size, was $l"
31    }
32    for {set i 0} {$i < $size} {set i [expr $i+1]} {
33        set j [lindex $var $i]
34        if {$j != "item $i"} {
35            return "element $i should have been \"item $i\", was \"$j\""
36        }
37    }
38    return ok
39}
40
41#----------------------------------------------------------
42#----------------------------------------------------------
43# convert command
44# Rappture::Units::convert <value> ?-context? ?-to units? ?-units on/off?
45#----------------------------------------------------------
46test convert-1.0.1 {Rappture::Units::convert, 0 arguments} {
47    list [catch {Rappture::Units::convert} msg] $msg
48} {1 {wrong # args: should be "Rappture::Units::convert <value> ?-context units? ?-to units? ?-units on/off?"}}
49
50test convert-1.1.1 {Rappture::Units::convert, 1 invalid argument} {
51    list [catch {Rappture::Units::convert re} msg] $msg
52} {1 {bad value "re": should be a real number with units}}
53
54test convert-1.1.2 {Rappture::Units::convert, invalid value, valid context} {
55    list [catch {Rappture::Units::convert re -context mm} msg] $msg
56} {1 {bad value "re": should be a real number with units of (A,bohr,in,m)}}
57
58test convert-1.1.3 {Rappture::Units::convert, 1 valid argument} {
59    list [catch {Rappture::Units::convert 5} msg] $msg
60} {1 {value: "5" has unrecognized units}}
61
62test convert-1.2.0 {Rappture::Units::convert, 1 valid argument w/ units} {
63    list [catch {Rappture::Units::convert 5m} msg] $msg
64} {0 5m}
65
66test convert-1.3.0 {Rappture::Units::convert, -context blank} {
67    list [catch {Rappture::Units::convert 5m -context} msg] $msg
68} {0 5m}
69
70test convert-1.3.1 {Rappture::Units::convert, -context valid} {
71    list [catch {Rappture::Units::convert 5m -context m} msg] $msg
72} {0 5m}
73
74#test convert-1.3.2.1 {Rappture::Units::convert, -context invalid} {
75## this test passes for old tcl version, fails for new tcl bindings
76#    list [catch {Rappture::Units::convert 5m -context ff} msg] $msg
77#} {0 5m}
78
79test convert-1.3.2.2 {Rappture::Units::convert, -context invalid} {
80# this test passes for new tcl bindings, fails for old tcl version
81    list [catch {Rappture::Units::convert 5m -context xx} msg] $msg
82} {1 {bad value "xx": should be a recognized unit for Rappture}}
83
84test convert-1.4.0 {Rappture::Units::convert, -to blank} {
85    list [catch {Rappture::Units::convert 5m -to} msg] $msg
86} {0 5m}
87
88#test convert-1.4.1.1 {Rappture::Units::convert, -to valid} {
89## this test passes for old tcl version, fails for new tcl bindings
90#    list [catch {Rappture::Units::convert 5m -to A} msg] $msg
91#} {0 50000000000A}
92
93test convert-1.4.1.2 {Rappture::Units::convert, -to valid} {
94# this test passes for new tcl bindings, fails for old tcl version
95    list [catch {Rappture::Units::convert 5m -to A} msg] $msg
96} {0 5e+10A}
97
98#test convert-1.4.2.1 {Rappture::Units::convert, -to invalid} {
99## this test passes for old tcl version, fails for new tcl bindings
100#    list [catch {Rappture::Units::convert 5m -to ff} msg] $msg
101#} {1 {invalid command name ""}}
102
103test convert-1.4.2.2 {Rappture::Units::convert, -to invalid} {
104# this test passes for new tcl bindings, fails for old tcl version
105    list [catch {Rappture::Units::convert 5m -to xx} msg] $msg
106} {1 {bad value "xx": should be a recognized unit for Rappture}}
107
108#test convert-1.5.0 {Rappture::Units::convert, -units blank} {
109## this test passes for old tcl version, fails for new tcl bindings
110#    list [catch {Rappture::Units::convert 5m -units} msg] $msg
111#} {1 {expected boolean value but got ""}}
112
113test convert-1.5.0 {Rappture::Units::convert, -units blank} {
114# this test passes for new tcl bindings, fails for old tcl version
115    list [catch {Rappture::Units::convert 5m -units} msg] $msg
116} {1 {expected boolean value but got ""}}
117
118test convert-1.5.1 {Rappture::Units::convert, -units on} {
119    list [catch {Rappture::Units::convert 5m -units on} msg] $msg
120} {0 5m}
121
122#test convert-1.5.2.1 {Rappture::Units::convert, -units off} {
123## this test passes for old tcl version, fails for new tcl bindings
124## comments for the Rappture::Units::convert function specify that
125## If the -to system is not specified, then the value is converted to
126## fundamental units for the current system. but the code just returns
127## the value, as specified by lines 115-118 or units.tcl 20060414
128#    list [catch {Rappture::Units::convert 5m -units off} msg] $msg
129#} {0 5m}
130
131test convert-1.5.2.2 {Rappture::Units::convert, -units off} {
132# this test passes for new tcl bindings, fails for old tcl version
133    list [catch {Rappture::Units::convert 5m -units off} msg] $msg
134} {0 5}
135
136test convert-1.5.3 {Rappture::Units::convert, -units invalid} {
137# this test passes for new tcl bindings, fails for old tcl version
138# because tcl version makes -units depend of -to flag being populated.
139    list [catch {Rappture::Units::convert 5m -units sdfsd} msg] $msg
140} {1 {expected boolean value but got "sdfsd"}}
141
142#test convert-1.6.0.1 {Rappture::Units::convert, all flags, all valid} {
143## this test passes for old tcl version, fails for new tcl bindings
144## new bindings return scientific notation.
145#    list [catch {Rappture::Units::convert 5m -context m -to A -units off} msg] $msg
146#} {0 50000000000}
147
148test convert-1.6.0.2 {Rappture::Units::convert, all flags, all valid} {
149# this test passes for new tcl bindings, fails for old tcl version
150    list [catch {Rappture::Units::convert 5m -context m -to A -units off} msg] $msg
151} {0 5e+10}
152
153test convert-1.7.0 {Rappture::Units::convert, val w/o units} {
154# this test passes for new tcl bindings, fails for old tcl version
155    list [catch {Rappture::Units::convert 5 -context m} msg] $msg
156} {0 5m}
157
158#test convert-1.7.1.1 {Rappture::Units::convert, invalid val w/ -context} {
159## this test passes for old tcl version, fails for new tcl bindings
160#    list [catch {Rappture::Units::convert de -context m } msg] $msg
161#} {1 {bad value "de": should be a real number with units of (m,A)}}
162
163test convert-1.7.1.2 {Rappture::Units::convert, invalid val w/ -context} {
164# this test passes for new tcl bindings, fails for old tcl version
165    list [catch {Rappture::Units::convert de -context m } msg] $msg
166} {1 {bad value "de": should be a real number with units of (A,bohr,in,m)}}
167
168test convert-1.8.0 {Rappture::Units::convert, convert undefined unit} {
169    list [catch {Rappture::Units::convert 33Q -to nm } msg] $msg
170} {1 {Unrecognized units: "Q".
171Should be units of type length (A,bohr,in,m)}}
172
173#----------------------------------------------------------
174#----------------------------------------------------------
175# description command
176# Rappture::Units::description <units>
177#----------------------------------------------------------
178
179test desc-2.0.0 {Rappture::Units::descption, blank units} {
180    list [catch {Rappture::Units::description} msg] $msg
181} {1 {wrong # args: should be "Rappture::Units::description units"}}
182
183test desc-2.1.0 {Rappture::Units::descption, invalid units} {
184# special note in the tcl bindings code reflects that i think
185# this behavior is incorrect, but tcl bindings comply with the
186# tcl version for now.
187    list [catch {Rappture::Units::description qqq} msg] $msg
188} {0 {}}
189
190test desc-2.2.0 {Rappture::Units::descption, valid units} {
191# this test passes for new tcl bindings, fails for old tcl version
192    list [catch {Rappture::Units::description eV} msg] $msg
193} {0 {energy (J,eV)}}
194
195test desc-2.2.1 {Rappture::Units::descption, *cm2*K/Vs} {
196    list [catch {Rappture::Units::description *cm2*K/Vs} msg] $msg
197} {0 {length*temperature/electric_potential*time (/V,/s,A2,C,F,K,R,bohr2,in2,m2)}}
198
199test desc-2.2.2 {Rappture::Units::descption, cm2 areas} {
200    list [catch {Rappture::Units::description cm2} msg] $msg
201} {0 {area (A2,bohr2,in2,m2)}}
202
203test desc-2.2.3 {Rappture::Units::descption, cm3 volumes} {
204    list [catch {Rappture::Units::description cm3} msg] $msg
205} {0 {volume (A3,bohr3,in3,m3)}}
206
207test desc-2.2.4 {Rappture::Units::descption, K temperature} {
208    list [catch {Rappture::Units::description K} msg] $msg
209} {0 {temperature (C,F,K,R)}}
210
211test desc-2.2.5 {Rappture::Units::descption, s time} {
212    list [catch {Rappture::Units::description s} msg] $msg
213} {0 {time (s)}}
214
215test desc-2.3.0 {Rappture::Units::descption, too many args} {
216    list [catch {Rappture::Units::description eV ee} msg] $msg
217} {1 {wrong # args: should be "Rappture::Units::description units"}}
218
219test desc-2.3.1 {Rappture::Units::descption, incorrect input type} {
220    list [catch {Rappture::Units::description 3cm} msg] $msg
221} {0 {}}
222
223test desc-2.4.0 {Rappture::Units::descption, "mm" correct units retrieval} {
224    list [catch {Rappture::Units::description mm} msg] $msg
225} {0 {length (A,bohr,in,m)}}
226
227test desc-2.4.1 {Rappture::Units::descption, "MM" correct units retrieval} {
228    list [catch {Rappture::Units::description MM} msg] $msg
229} {0 {length (A,bohr,in,m)}}
230
231test desc-2.4.2 {Rappture::Units::descption, "mM" correct units retrieval} {
232    list [catch {Rappture::Units::description mM} msg] $msg
233} {0 {length (A,bohr,in,m)}}
234
235test desc-2.4.3 {Rappture::Units::descption, "Mm" correct units retrieval} {
236    list [catch {Rappture::Units::description Mm} msg] $msg
237} {0 {length (A,bohr,in,m)}}
238
239test desc-2.4.4 {Rappture::Units::descption, "mv" correct units retrieval} {
240    list [catch {Rappture::Units::description mv} msg] $msg
241} {0 {electric_potential (V)}}
242
243test desc-2.4.5 {Rappture::Units::descption, "mV" correct units retrieval} {
244    list [catch {Rappture::Units::description mV} msg] $msg
245} {0 {electric_potential (V)}}
246
247test desc-2.4.6 {Rappture::Units::descption, "MV" correct units retrieval} {
248    list [catch {Rappture::Units::description MV} msg] $msg
249} {0 {electric_potential (V)}}
250
251test desc-2.4.7 {Rappture::Units::descption, "Mv" correct units retrieval} {
252    list [catch {Rappture::Units::description Mv} msg] $msg
253} {0 {electric_potential (V)}}
254
255test desc-2.4.8 {Rappture::Units::descption, "ms" correct units retrieval} {
256    list [catch {Rappture::Units::description ms} msg] $msg
257} {0 {time (s)}}
258
259test desc-2.4.9 {Rappture::Units::descption, "mS" correct units retrieval} {
260    list [catch {Rappture::Units::description mS} msg] $msg
261} {0 {time (s)}}
262
263test desc-2.4.10 {Rappture::Units::descption, "MS" correct units retrieval} {
264    list [catch {Rappture::Units::description MS} msg] $msg
265} {0 {time (s)}}
266
267test desc-2.4.11 {Rappture::Units::descption, "Ms" correct units retrieval} {
268    list [catch {Rappture::Units::description Ms} msg] $msg
269} {0 {time (s)}}
270
271#----------------------------------------------------------
272#----------------------------------------------------------
273# for command
274# Rappture::Units::System::for <units>
275#----------------------------------------------------------
276
277#test for-3.0.0.1 {Rappture::Units::System::for, blank units} {
278## this test passes for old tcl version, fails for new tcl bindings
279## because of additional "::" prefixed on object name
280#    list [catch {Rappture::Units::System::for} msg] $msg
281#} {1 {wrong # args: should be "::Rappture::Units::System::for units"}}
282
283test for-3.0.0.2 {Rappture::Units::System::for, blank units} {
284    list [catch {Rappture::Units::System::for} msg] $msg
285} {1 {wrong # args: should be "Rappture::Units::System::for units"}}
286
287test for-3.1.0 {Rappture::Units::System::for, invalid units} {
288# special note in the tcl bindings code reflects that i think
289# this behavior is incorrect, but tcl bindings comply with the
290# tcl version for now.
291    list [catch {Rappture::Units::System::for qqq} msg] $msg
292} {0 {}}
293
294#test for-3.2.0.1 {Rappture::Units::System::for, valid units} {
295## this test passes for old tcl version, fails for new tcl bindings
296## because different order of units
297#    list [catch {Rappture::Units::System::for eV} msg] $msg
298#} {0 ::Rappture::Units::system6}
299
300test for-3.2.0.2 {Rappture::Units::System::for, valid units} {
301# this test passes for new tcl bindings, fails for old tcl version
302    list [catch {Rappture::Units::System::for eV} msg] $msg
303} {0 energy}
304
305#test for-3.3.0.1 {Rappture::Units::System::for, too many args} {
306## this test passes for old tcl version, fails for new tcl bindings
307## because of additional "::" prefixed on object name
308#    list [catch {Rappture::Units::System::for eV ee} msg] $msg
309#} {1 {wrong # args: should be "::Rappture::Units::System::for units"}}
310
311test for-3.3.0.2 {Rappture::Units::System::for, too many args} {
312# this test passes for new tcl bindings, fails for old tcl version
313    list [catch {Rappture::Units::System::for eV ee} msg] $msg
314} {1 {wrong # args: should be "Rappture::Units::System::for units"}}
315
316
317#----------------------------------------------------------
318#----------------------------------------------------------
319# all command
320# Rappture::Units::Sys::all <units>
321#----------------------------------------------------------
322
323#test all-4.0.0.1 {Rappture::Units::System::all, blank} {
324## this test passes for old tcl version, fails for new tcl bindings
325## because of additional "::" prefixed on object name
326#    list [catch {Rappture::Units::System::all} msg] $msg
327#} {1 {wrong # args: should be "::Rappture::Units::System::all units"}}
328
329test all-4.0.0.2 {Rappture::Units::System::all, blank units} {
330    list [catch {Rappture::Units::System::all} msg] $msg
331} {1 {wrong # args: should be "Rappture::Units::System::all units"}}
332
333test all-4.1.0 {Rappture::Units::System::all, invalid units} {
334# special note in the tcl bindings code reflects that i think
335# this behavior is incorrect, but tcl bindings comply with the
336# tcl version for now.
337    list [catch {Rappture::Units::System::all qqq} msg] $msg
338} {0 {}}
339
340#test all-4.2.0.1 {Rappture::Units::System::all, valid units} {
341## this test passes for old tcl version, fails for new tcl bindings
342## because different order of units
343#    list [catch {Rappture::Units::System::all eV} msg] $msg
344#} {0 {eV J}}
345
346test all-4.2.0.2 {Rappture::Units::System::all, valid units} {
347# this test passes for new tcl bindings, fails for old tcl version
348    list [catch {Rappture::Units::System::all eV} msg] $msg
349} {0 {J eV}}
350
351#test all-4.3.0.1 {Rappture::Units::System::all, too many args} {
352## this test passes for old tcl version, fails for new tcl bindings
353## because of additional "::" prefixed on object name
354#    list [catch {Rappture::Units::System::all eV ee} msg] $msg
355#} {1 {wrong # args: should be "::Rappture::Units::System::all units"}}
356
357test all-4.3.0.2 {Rappture::Units::System::all, too many args} {
358# this test passes for new tcl bindings, fails for old tcl version
359    list [catch {Rappture::Units::System::all eV ee} msg] $msg
360} {1 {wrong # args: should be "Rappture::Units::System::all units"}}
361
362#----------------------------------------------------------
363#----------------------------------------------------------
364# convert command - testing units conversions
365#----------------------------------------------------------
366
367test convert_units-5.4.1.0 {Rappture::Units::convert, m->A} {
368    list [catch {Rappture::Units::convert 5m -to A} msg] $msg
369} {0 5e+10A}
370
371test convert_units-5.4.1.1 {Rappture::Units::convert, m<-A} {
372    list [catch {Rappture::Units::convert 5A -to m} msg] $msg
373} {0 5e-10m}
374
375#--------------------------------------------------------------------
376# Metric Extension Conversions
377#--------------------------------------------------------------------
378
379test convert_units-5.4.2.0 {Rappture::Units::convert, m->dm} {
380    list [catch {Rappture::Units::convert 5m -to dm} msg] $msg
381} {0 50dm}
382
383test convert_units-5.4.2.1 {Rappture::Units::convert, m->cm} {
384    list [catch {Rappture::Units::convert 5m -to cm} msg] $msg
385} {0 500cm}
386
387test convert_units-5.4.2.3 {Rappture::Units::convert, m->mm} {
388    list [catch {Rappture::Units::convert 5m -to mm} msg] $msg
389} {0 5000mm}
390
391test convert_units-5.4.2.4 {Rappture::Units::convert, m->um} {
392    list [catch {Rappture::Units::convert 5m -to um} msg] $msg
393} {0 5e+06um}
394
395test convert_units-5.4.2.5 {Rappture::Units::convert, m->nm} {
396    list [catch {Rappture::Units::convert 5m -to nm} msg] $msg
397} {0 5e+09nm}
398
399test convert_units-5.4.2.6 {Rappture::Units::convert, m->pm} {
400    list [catch {Rappture::Units::convert 5m -to pm} msg] $msg
401} {0 5e+12pm}
402
403test convert_units-5.4.2.7 {Rappture::Units::convert, m->fm} {
404    list [catch {Rappture::Units::convert 5m -to fm} msg] $msg
405} {0 5e+15fm}
406
407test convert_units-5.4.2.8 {Rappture::Units::convert, m->am} {
408    list [catch {Rappture::Units::convert 5m -to am} msg] $msg
409} {0 5e+18am}
410
411test convert_units-5.4.2.9 {Rappture::Units::convert, m->dam} {
412    list [catch {Rappture::Units::convert 5m -to dam} msg] $msg
413} {0 0.5dam}
414
415test convert_units-5.4.2.10 {Rappture::Units::convert, m->hm} {
416    list [catch {Rappture::Units::convert 5m -to hm} msg] $msg
417} {0 0.05hm}
418
419test convert_units-5.4.2.11 {Rappture::Units::convert, m->km} {
420    list [catch {Rappture::Units::convert 5m -to km} msg] $msg
421} {0 0.005km}
422
423test convert_units-5.4.2.12 {Rappture::Units::convert, m->Mm} {
424    list [catch {Rappture::Units::convert 5m -to Mm} msg] $msg
425} {0 5e-06Mm}
426
427test convert_units-5.4.2.13 {Rappture::Units::convert, m->Gm} {
428    list [catch {Rappture::Units::convert 5m -to Gm} msg] $msg
429} {0 5e-09Gm}
430
431test convert_units-5.4.2.14 {Rappture::Units::convert, m->Tm} {
432    list [catch {Rappture::Units::convert 5m -to Tm} msg] $msg
433} {0 5e-12Tm}
434
435test convert_units-5.4.2.15 {Rappture::Units::convert, m->Pm} {
436    list [catch {Rappture::Units::convert 5m -to Pm} msg] $msg
437} {0 5e-15Pm}
438
439test convert_units-5.4.2.16 {Rappture::Units::convert, m->Em} {
440    list [catch {Rappture::Units::convert 5m -to Em} msg] $msg
441} {0 5e-18Em}
442
443test convert_units-5.4.2.17 {Rappture::Units::convert, dm->m} {
444    list [catch {Rappture::Units::convert 5dm -to m} msg] $msg
445} {0 0.5m}
446
447test convert_units-5.4.2.18 {Rappture::Units::convert, cm->m} {
448    list [catch {Rappture::Units::convert 5cm -to m} msg] $msg
449} {0 0.05m}
450
451test convert_units-5.4.2.19 {Rappture::Units::convert, mm->m} {
452    list [catch {Rappture::Units::convert 5mm -to m} msg] $msg
453} {0 0.005m}
454
455test convert_units-5.4.2.20 {Rappture::Units::convert, um->m} {
456    list [catch {Rappture::Units::convert 5um -to m} msg] $msg
457} {0 5e-06m}
458
459test convert_units-5.4.2.21 {Rappture::Units::convert, nm->m} {
460    list [catch {Rappture::Units::convert 5nm -to m} msg] $msg
461} {0 5e-09m}
462
463test convert_units-5.4.2.22 {Rappture::Units::convert, pm->m} {
464    list [catch {Rappture::Units::convert 5pm -to m} msg] $msg
465} {0 5e-12m}
466
467test convert_units-5.4.2.23 {Rappture::Units::convert, fm->m} {
468    list [catch {Rappture::Units::convert 5fm -to m} msg] $msg
469} {0 5e-15m}
470
471test convert_units-5.4.2.24 {Rappture::Units::convert, am->m} {
472    list [catch {Rappture::Units::convert 5am -to m} msg] $msg
473} {0 5e-18m}
474
475test convert_units-5.4.2.25 {Rappture::Units::convert, dam->m} {
476    list [catch {Rappture::Units::convert 5dam -to m} msg] $msg
477} {0 50m}
478
479test convert_units-5.4.2.26 {Rappture::Units::convert, hm->m} {
480    list [catch {Rappture::Units::convert 5hm -to m} msg] $msg
481} {0 500m}
482
483test convert_units-5.4.2.27 {Rappture::Units::convert, km->m} {
484    list [catch {Rappture::Units::convert 5km -to m} msg] $msg
485} {0 5000m}
486
487test convert_units-5.4.2.28 {Rappture::Units::convert, Mm->m} {
488    list [catch {Rappture::Units::convert 5Mm -to m} msg] $msg
489} {0 5e+06m}
490
491test convert_units-5.4.2.29 {Rappture::Units::convert, Gm->G} {
492    list [catch {Rappture::Units::convert 5Gm -to m} msg] $msg
493} {0 5e+09m}
494
495test convert_units-5.4.2.30 {Rappture::Units::convert, Tm->m} {
496    list [catch {Rappture::Units::convert 5Tm -to m} msg] $msg
497} {0 5e+12m}
498
499test convert_units-5.4.2.31 {Rappture::Units::convert, Pm->m} {
500    list [catch {Rappture::Units::convert 5Pm -to m} msg] $msg
501} {0 5e+15m}
502
503test convert_units-5.4.2.32 {Rappture::Units::convert, Em->m} {
504    list [catch {Rappture::Units::convert 5Em -to m} msg] $msg
505} {0 5e+18m}
506
507#--------------------------------------------------------------------
508# Concentration Conversions
509#--------------------------------------------------------------------
510
511test convert_units-5.4.3.0 {Rappture::Units::convert, pH->pOH} {
512    list [catch {Rappture::Units::convert 5pH -to pOH} msg] $msg
513} {0 9pOH}
514
515test convert_units-5.4.3.1 {Rappture::Units::convert, pOH->pH} {
516    list [catch {Rappture::Units::convert 9pOH -to pH} msg] $msg
517} {0 5pH}
518
519#--------------------------------------------------------------------
520# Multiple Unit Conversions
521#--------------------------------------------------------------------
522
523test convert_units-5.4.4.0 {Rappture::Units::convert, cm2/Vs->m2/kVus} {
524    list [catch {Rappture::Units::convert 2cm2/Vs -to m2/kVus} msg] $msg
525} {0 2e-07m2/kVus}
526
527test convert_units-5.4.4.1 {Rappture::Units::convert, cm2/Vs->m2/kQus} {
528    list [catch {Rappture::Units::convert 2cm2/Vs -to m2/kQus} msg] $msg
529} {1 {bad value "m2/kQus": should be a recognized unit for Rappture}}
530
531test convert_units-5.4.4.2 {Rappture::Units::convert, cm2nZ/Vs->m2/us} {
532    list [catch {Rappture::Units::convert 2cm2nZ/Vs -to m2/us} msg] $msg
533} {1 {Unrecognized units: "cm2nZ/Vs".
534Should be units of type length/time (/s,A2,bohr2,in2,m2)}}
535
536test convert_units-5.4.4.3 {Rappture::Units::convert, cm2/s->m2/kVus} {
537    list [catch {Rappture::Units::convert 2cm2/s -to m2/kVus} msg] $msg
538} {1 {unmatched units in conversion: (kV-1)
539Please enter units of type length/electric_potential*time (/V,/s,A2,bohr2,in2,m2)}}
540
541test convert_units-5.4.4.4 {Rappture::Units::convert, cm2/s->m2/uskV} {
542    list [catch {Rappture::Units::convert 2cm2/s -to m2/uskV} msg] $msg
543} {1 {unmatched units in conversion: (kV-1)
544Please enter units of type length/time*electric_potential (/V,/s,A2,bohr2,in2,m2)}}
545
546test convert_units-5.4.4.5 {Rappture::Units::convert, cm2V/s->m2/us} {
547    list [catch {Rappture::Units::convert 2cm2V/s -to m2/us} msg] $msg
548} {1 {unmatched units in conversion: (V)
549Please enter units of type length/time (/s,A2,bohr2,in2,m2)}}
550
551test convert_units-5.4.4.6 {Rappture::Units::convert, cm2V/s->m2/us} {
552    list [catch {Rappture::Units::convert 2cm2V/s -to m2/us} msg] $msg
553} {1 {unmatched units in conversion: (V)
554Please enter units of type length/time (/s,A2,bohr2,in2,m2)}}
555
556test convert_units-5.4.4.7 {Rappture::Units::convert, cm2V->m2} {
557    list [catch {Rappture::Units::convert 2cm2V -to m2} msg] $msg
558} {1 {unmatched units in conversion: (V)
559Please enter units of type length (A2,bohr2,in2,m2)}}
560
561test convert_units-5.4.4.8 {Rappture::Units::convert, Vcm2->m2} {
562    list [catch {Rappture::Units::convert 2Vcm2 -to m2} msg] $msg
563} {1 {unmatched units in conversion: (V)
564Please enter units of type length (A2,bohr2,in2,m2)}}
565
566test convert_units-5.4.4.9 {Rappture::Units::convert, cm2->Vm2} {
567    list [catch {Rappture::Units::convert 2cm2 -to Vm2} msg] $msg
568} {1 {unmatched units in conversion: (V)
569Please enter units of type electric_potential*length (A2,V,bohr2,in2,m2)}}
570
571test convert_units-5.4.4.10 {Rappture::Units::convert, cm2->m2V} {
572    list [catch {Rappture::Units::convert 2cm2 -to m2V} msg] $msg
573} {1 {unmatched units in conversion: (V)
574Please enter units of type length*electric_potential (A2,V,bohr2,in2,m2)}}
575
576test convert_units-5.4.4.11 {Rappture::Units::convert, cm2A->Vm2} {
577    list [catch {Rappture::Units::convert 2cm2A -to Vm2} msg] $msg
578} {1 {unmatched units in conversion: (A) -> (V)
579Please enter units of type electric_potential*length (A2,V,bohr2,in2,m2)}}
580
581test convert_units-5.4.4.12 {Rappture::Units::convert, cm2A->m2V} {
582    list [catch {Rappture::Units::convert 2cm2A -to m2V} msg] $msg
583} {1 {Conversion unavailable: (A) -> (V)
584Please enter units of type length*electric_potential (A2,V,bohr2,in2,m2)}}
585
586test convert_units-5.4.4.13 {Rappture::Units::convert, Acm2->Vm2} {
587    list [catch {Rappture::Units::convert 2Acm2 -to Vm2} msg] $msg
588} {1 {unmatched units in conversion: (A) -> (V)
589Please enter units of type electric_potential*length (A2,V,bohr2,in2,m2)}}
590
591test convert_units-5.4.4.14 {Rappture::Units::convert, Acm2->m2V} {
592    list [catch {Rappture::Units::convert 2Acm2 -to m2V} msg] $msg
593} {1 {Conversion unavailable: (A) -> (V)
594Please enter units of type length*electric_potential (A2,V,bohr2,in2,m2)}}
595
596#--------------------------------------------------------------------
597# Inverse Unit Conversions
598#--------------------------------------------------------------------
599
600test convert_units-5.4.5.0 {Rappture::Units::convert, /cm2->/m2} {
601    list [catch {Rappture::Units::convert 2/cm2 -to /m2} msg] $msg
602} {0 20000/m2}
603
604test convert_units-5.4.5.1 {Rappture::Units::convert, cm2->/m2} {
605    list [catch {Rappture::Units::convert 1cm -to /m2} msg] $msg
606} {1 {Conversion unavailable: (cm) -> (m-2)
607Please enter units of type /area (/A2,/bohr2,/in2,/m2)}}
608
609#--------------------------------------------------------------------
610# Temperature Conversions
611#--------------------------------------------------------------------
612
613test convert_units-5.4.6.0 {Rappture::Units::convert, F->C} {
614    list [catch {Rappture::Units::convert 78.8F -to C} msg] $msg
615} {0 26C}
616
617test convert_units-5.4.6.1 {Rappture::Units::convert, C->F} {
618    list [catch {Rappture::Units::convert 26C -to F} msg] $msg
619} {0 78.8F}
620
621test convert_units-5.4.6.2 {Rappture::Units::convert, C->K} {
622    list [catch {Rappture::Units::convert 26C -to K} msg] $msg
623} {0 299.15K}
624
625test convert_units-5.4.6.3 {Rappture::Units::convert, K->C} {
626    list [catch {Rappture::Units::convert 299.15K -to C} msg] $msg
627} {0 26C}
628
629test convert_units-5.4.6.4 {Rappture::Units::convert, K->F} {
630    list [catch {Rappture::Units::convert 299.15K -to F} msg] $msg
631} {0 78.8F}
632
633test convert_units-5.4.6.5 {Rappture::Units::convert, F->K} {
634    list [catch {Rappture::Units::convert 78.8F -to K} msg] $msg
635} {0 299.15K}
636
637test convert_units-5.4.6.6 {Rappture::Units::convert, F->R} {
638    list [catch {Rappture::Units::convert 78.8F -to R} msg] $msg
639} {0 538.47R}
640
641test convert_units-5.4.6.7 {Rappture::Units::convert, R->F} {
642    list [catch {Rappture::Units::convert 538.47R -to F} msg] $msg
643} {0 78.8F}
644
645test convert_units-5.4.6.8 {Rappture::Units::convert, R->C} {
646    list [catch {Rappture::Units::convert 538.47R -to C} msg] $msg
647} {0 26C}
648
649test convert_units-5.4.6.9 {Rappture::Units::convert, C->R} {
650    list [catch {Rappture::Units::convert 26C -to R} msg] $msg
651} {0 538.47R}
652
653test convert_units-5.4.6.10 {Rappture::Units::convert, R->K} {
654    list [catch {Rappture::Units::convert 538.47R -to K} msg] $msg
655} {0 299.15K}
656
657test convert_units-5.4.6.11 {Rappture::Units::convert, K->R} {
658    list [catch {Rappture::Units::convert 299.15K -to R} msg] $msg
659} {0 538.47R}
660
661test convert_units-5.4.6.12 {Rappture::Units::convert, K->mK} {
662    list [catch {Rappture::Units::convert 299.15K -to mK} msg] $msg
663} {0 299150mK}
664
665test convert_units-5.4.6.13 {Rappture::Units::convert, K->mk} {
666    list [catch {Rappture::Units::convert 299.15K -to mk} msg] $msg
667} {0 299150mK}
668
669test convert_units-5.4.6.14 {Rappture::Units::convert, C->mC} {
670    list [catch {Rappture::Units::convert 100C -to mC} msg] $msg
671} {0 100000mC}
672
673test convert_units-5.4.6.15 {Rappture::Units::convert, C->mc} {
674    list [catch {Rappture::Units::convert 100C -to mc} msg] $msg
675} {0 100000mC}
676
677
678#--------------------------------------------------------------------
679# Energy Conversions
680#--------------------------------------------------------------------
681
682test convert_units-5.4.7.0 {Rappture::Units::convert, eV->J} {
683    list [catch {Rappture::Units::convert 5eV -to J} msg] $msg
684} {0 8.01089e-19J}
685
686test convert_units-5.4.7.1 {Rappture::Units::convert, J->eV} {
687    list [catch {Rappture::Units::convert 8.01088231e-19J -to eV} msg] $msg
688} {0 5eV}
689
690#--------------------------------------------------------------------
691# Time Conversions
692#--------------------------------------------------------------------
693
694test convert_units-5.4.8.0 {Rappture::Units::convert, s->s} {
695    list [catch {Rappture::Units::convert 5s -to s} msg] $msg
696} {0 5s}
697
698test convert_units-5.4.8.1 {Rappture::Units::convert, min->s} {
699    list [catch {Rappture::Units::convert 5min -to s} msg] $msg
700} {0 300s}
701
702test convert_units-5.4.8.2 {Rappture::Units::convert, h->s} {
703    list [catch {Rappture::Units::convert 5h -to s} msg] $msg
704} {0 18000s}
705
706test convert_units-5.4.8.3 {Rappture::Units::convert, d->s} {
707    list [catch {Rappture::Units::convert 5d -to s} msg] $msg
708} {0 432000s}
709
710test convert_units-5.4.8.4 {Rappture::Units::convert, s->min} {
711    list [catch {Rappture::Units::convert 5s -to min} msg] $msg
712} {0 0.0833333min}
713
714test convert_units-5.4.8.5 {Rappture::Units::convert, min->min} {
715    list [catch {Rappture::Units::convert 5min -to min} msg] $msg
716} {0 5min}
717
718test convert_units-5.4.8.6 {Rappture::Units::convert, h->min} {
719    list [catch {Rappture::Units::convert 5h -to min} msg] $msg
720} {0 300min}
721
722test convert_units-5.4.8.7 {Rappture::Units::convert, d->min} {
723    list [catch {Rappture::Units::convert 5d -to min} msg] $msg
724} {0 7200min}
725
726test convert_units-5.4.8.8 {Rappture::Units::convert, s->h} {
727    list [catch {Rappture::Units::convert 5s -to h} msg] $msg
728} {0 0.00138889h}
729
730test convert_units-5.4.8.9 {Rappture::Units::convert, min->h} {
731    list [catch {Rappture::Units::convert 5min -to h} msg] $msg
732} {0 0.0833333h}
733
734test convert_units-5.4.8.10 {Rappture::Units::convert, h->h} {
735    list [catch {Rappture::Units::convert 5h -to h} msg] $msg
736} {0 5h}
737
738test convert_units-5.4.8.11 {Rappture::Units::convert, d->h} {
739    list [catch {Rappture::Units::convert 5d -to h} msg] $msg
740} {0 120h}
741
742test convert_units-5.4.8.12 {Rappture::Units::convert, s->d} {
743    list [catch {Rappture::Units::convert 5s -to d} msg] $msg
744} {0 5.78704e-05d}
745
746test convert_units-5.4.8.13 {Rappture::Units::convert, min->d} {
747    list [catch {Rappture::Units::convert 5min -to d} msg] $msg
748} {0 0.00347222d}
749
750test convert_units-5.4.8.14 {Rappture::Units::convert, h->d} {
751    list [catch {Rappture::Units::convert 5h -to d} msg] $msg
752} {0 0.208333d}
753
754test convert_units-5.4.8.15 {Rappture::Units::convert, d->d} {
755    list [catch {Rappture::Units::convert 5d -to d} msg] $msg
756} {0 5d}
757
758#--------------------------------------------------------------------
759# Pressure Conversions
760#--------------------------------------------------------------------
761
762test convert_units-5.4.9.0 {Rappture::Units::convert, bar->Pa} {
763    list [catch {Rappture::Units::convert 5bar -to Pa} msg] $msg
764} {0 500000Pa}
765
766test convert_units-5.4.9.1 {Rappture::Units::convert, bar->atm} {
767    list [catch {Rappture::Units::convert 5bar -to atm} msg] $msg
768} {0 4.9346atm}
769
770test convert_units-5.4.9.2 {Rappture::Units::convert, bar->torr} {
771    list [catch {Rappture::Units::convert 5bar -to torr} msg] $msg
772} {0 3750.3torr}
773
774test convert_units-5.4.9.3 {Rappture::Units::convert, bar->psi} {
775    list [catch {Rappture::Units::convert 5bar -to psi} msg] $msg
776} {0 72.52psi}
777
778test convert_units-5.4.9.4 {Rappture::Units::convert, bar->bar} {
779    list [catch {Rappture::Units::convert 5bar -to bar} msg] $msg
780} {0 5bar}
781
782test convert_units-5.4.9.5 {Rappture::Units::convert, atm->Pa} {
783    list [catch {Rappture::Units::convert 5atm -to Pa} msg] $msg
784} {0 506625Pa}
785
786test convert_units-5.4.9.6 {Rappture::Units::convert, atm->atm} {
787    list [catch {Rappture::Units::convert 5atm -to atm} msg] $msg
788} {0 5atm}
789
790test convert_units-5.4.9.7 {Rappture::Units::convert, atm->torr} {
791    list [catch {Rappture::Units::convert 5atm -to torr} msg] $msg
792} {0 3800torr}
793
794test convert_units-5.4.9.8 {Rappture::Units::convert, atm->psi} {
795    list [catch {Rappture::Units::convert 5bar -to psi} msg] $msg
796} {0 72.52psi}
797
798test convert_units-5.4.9.9 {Rappture::Units::convert, atm->bar} {
799    list [catch {Rappture::Units::convert 5atm -to bar} msg] $msg
800} {0 5.06627bar}
801
802test convert_units-5.4.9.10 {Rappture::Units::convert, Pa->Pa} {
803    list [catch {Rappture::Units::convert 5Pa -to Pa} msg] $msg
804} {0 5Pa}
805
806test convert_units-5.4.9.11 {Rappture::Units::convert, Pa->atm} {
807    list [catch {Rappture::Units::convert 5Pa -to atm} msg] $msg
808} {0 4.9346e-05atm}
809
810test convert_units-5.4.9.12 {Rappture::Units::convert, Pa->torr} {
811    list [catch {Rappture::Units::convert 5Pa -to torr} msg] $msg
812} {0 0.037503torr}
813
814test convert_units-5.4.9.13 {Rappture::Units::convert, Pa->psi} {
815    list [catch {Rappture::Units::convert 5Pa -to psi} msg] $msg
816} {0 0.0007252psi}
817
818test convert_units-5.4.9.14 {Rappture::Units::convert, Pa->bar} {
819    list [catch {Rappture::Units::convert 5Pa -to bar} msg] $msg
820} {0 5e-05bar}
821
822test convert_units-5.4.9.15 {Rappture::Units::convert, torr->Pa} {
823    list [catch {Rappture::Units::convert 5torr -to Pa} msg] $msg
824} {0 666.613Pa}
825
826test convert_units-5.4.9.16 {Rappture::Units::convert, torr->atm} {
827    list [catch {Rappture::Units::convert 5torr -to atm} msg] $msg
828} {0 0.006579atm}
829
830test convert_units-5.4.9.17 {Rappture::Units::convert, torr->torr} {
831    list [catch {Rappture::Units::convert 5torr -to torr} msg] $msg
832} {0 5torr}
833
834test convert_units-5.4.9.18 {Rappture::Units::convert, torr->psi} {
835    list [catch {Rappture::Units::convert 5torr -to psi} msg] $msg
836} {0 0.096685psi}
837
838test convert_units-5.4.9.19 {Rappture::Units::convert, torr->bar} {
839    list [catch {Rappture::Units::convert 5torr -to bar} msg] $msg
840} {0 0.00666613bar}
841
842test convert_units-5.4.9.20 {Rappture::Units::convert, psi->Pa} {
843    list [catch {Rappture::Units::convert 5psi -to Pa} msg] $msg
844} {0 34473.8Pa}
845
846test convert_units-5.4.9.21 {Rappture::Units::convert, psi->atm} {
847    list [catch {Rappture::Units::convert 5psi -to atm} msg] $msg
848} {0 0.34023atm}
849
850test convert_units-5.4.9.22 {Rappture::Units::convert, psi->torr} {
851    list [catch {Rappture::Units::convert 5psi -to torr} msg] $msg
852} {0 258.575torr}
853
854test convert_units-5.4.9.23 {Rappture::Units::convert, psi->psi} {
855    list [catch {Rappture::Units::convert 5psi -to psi} msg] $msg
856} {0 5psi}
857
858test convert_units-5.4.9.24 {Rappture::Units::convert, psi->bar} {
859    list [catch {Rappture::Units::convert 5psi -to bar} msg] $msg
860} {0 0.344738bar}
861
862test convert_units-5.4.9.25 {Rappture::Units::convert, psi->kPa} {
863    list [catch {Rappture::Units::convert 5psi -to kPa} msg] $msg
864} {0 34.4738kPa}
865
866test convert_units-5.4.9.26 {Rappture::Units::convert, kPa->psi} {
867    list [catch {Rappture::Units::convert 5kPa -to psi} msg] $msg
868} {0 0.7252psi}
869
870test convert_units-5.4.9.27 {Rappture::Units::convert, mmHg->torr} {
871    list [catch {Rappture::Units::convert 5mmHg -to torr} msg] $msg
872} {0 5torr}
873
874test convert_units-5.4.9.28 {Rappture::Units::convert, torr->mmHg} {
875    list [catch {Rappture::Units::convert 5torr -to mmHg} msg] $msg
876} {0 5mmHg}
877
878#--------------------------------------------------------------------
879# Case Insensitive/Sensitive Unit Conversions
880#--------------------------------------------------------------------
881
882test convert_units-5.4.10.1 {Rappture::Units::convert, torr->mmhg} {
883    list [catch {Rappture::Units::convert 5torr -to mmhg} msg] $msg
884} {0 5mmHg}
885
886test convert_units-5.4.10.2 {Rappture::Units::convert, ToRr->mmhg} {
887    list [catch {Rappture::Units::convert 5ToRr -to mmhg} msg] $msg
888} {0 5mmHg}
889
890test convert_units-5.4.10.3 {Rappture::Units::convert, kpa->PSI} {
891    list [catch {Rappture::Units::convert 5kpa -to PSI} msg] $msg
892} {0 0.7252psi}
893
894test convert_units-5.4.10.4 {Rappture::Units::convert, KPA->PsI} {
895    list [catch {Rappture::Units::convert 5KPA -to PsI} msg] $msg
896} {0 0.7252psi}
897
898test convert_units-5.4.10.5 {Rappture::Units::convert, Cm2/vS->M2/KVUS} {
899    list [catch {Rappture::Units::convert 2Cm2/vS -to M2/KVUS} msg] $msg
900} {0 2e-07m2/kVus}
901
902#--------------------------------------------------------------------
903# Magnetic Field Conversions
904#--------------------------------------------------------------------
905
906test convert_units-5.4.11.0 {Rappture::Units::convert, T->G} {
907    list [catch {Rappture::Units::convert 5T -to G} msg] $msg
908} {0 50000G}
909
910test convert_units-5.4.11.1 {Rappture::Units::convert, G->T} {
911    list [catch {Rappture::Units::convert 5G -to T} msg] $msg
912} {0 0.0005T}
913
914test convert_units-5.4.11.2 {Rappture::Units::convert, G->mT} {
915    list [catch {Rappture::Units::convert 50G -to mT} msg] $msg
916} {0 5mT}
917
918test convert_units-5.4.11.3 {Rappture::Units::convert, Mx->Wb} {
919    list [catch {Rappture::Units::convert 5Mx -to Wb} msg] $msg
920} {0 5e-08Wb}
921
922test convert_units-5.4.11.4 {Rappture::Units::convert, Wb->Mx} {
923    list [catch {Rappture::Units::convert 5e-8Wb -to Mx} msg] $msg
924} {0 5Mx}
925
926test convert_units-5.4.11.5 {Rappture::Units::convert, wB->mX} {
927    list [catch {Rappture::Units::convert 5e-8wB -to mX} msg] $msg
928} {0 5Mx}
929
930#--------------------------------------------------------------------
931# Rappture::Units::Search::for <units>
932#--------------------------------------------------------------------
933
934test search-for-6.0.0.1 {Rappture::Units::Search::for, 300K} {
935    list [catch {Rappture::Units::Search::for 300K} msg] $msg
936} {0 K}
937
938test search-for-6.0.0.2 {Rappture::Units::Search::for, 300cm2/Vs} {
939    list [catch {Rappture::Units::Search::for 300cm2/Vs} msg] $msg
940} {0 cm2/Vs}
941
942test search-for-6.0.0.3 {Rappture::Units::Search::for, cm2/Vs} {
943    list [catch {Rappture::Units::Search::for cm2/Vs} msg] $msg
944} {0 cm2/Vs}
945
946test search-for-6.0.1.1 {Rappture::Units::Search::for, 4notaunit} {
947    list [catch {Rappture::Units::Search::for 4notaunit} msg] $msg
948} {0 {}}
949
950test search-for-6.0.1.2 {Rappture::Units::Search::for, notaunit} {
951    list [catch {Rappture::Units::Search::for notaunit} msg] $msg
952} {0 {}}
953
954test search-for-6.0.1.3 {Rappture::Units::Search::for, notaunit} {
955    list [catch {Rappture::Units::Search::for ^&} msg] $msg
956} {0 {}}
957
958test search-for-6.0.1.4 {Rappture::Units::Search::for, notaunit} {
959    list [catch {Rappture::Units::Search::for x44} msg] $msg
960} {0 {}}
961
962test search-for-6.0.1.5 {Rappture::Units::Search::for, notaunit} {
963    list [catch {Rappture::Units::Search::for 3*44eV} msg] $msg
964} {0 {}}
965
966test search-for-6.0.2.0 {Rappture::Units::Search::for, case searches - m} {
967    set unit "m"
968    set status1 [catch {Rappture::Units::Search::for $unit} runit]
969    set status2 [catch {Rappture::Units::System::for $unit} type]
970    list $status1 $runit $status2 $type
971} {0 m 0 length}
972
973test search-for-6.0.2.1 {Rappture::Units::Search::for, case searches - M} {
974    set unit "M"
975    set status1 [catch {Rappture::Units::Search::for $unit} runit]
976    set status2 [catch {Rappture::Units::System::for $unit} type]
977    list $status1 $runit $status2 $type
978} {0 m 0 length}
979
980test search-for-6.0.2.2 {Rappture::Units::Search::for, case searches - mm} {
981    set unit "mm"
982    set status1 [catch {Rappture::Units::Search::for $unit} runit]
983    set status2 [catch {Rappture::Units::System::for $unit} type]
984    list $status1 $runit $status2 $type
985} {0 mm 0 length}
986
987test search-for-6.0.2.3 {Rappture::Units::Search::for, case searches - Mm} {
988    set unit "Mm"
989    set status1 [catch {Rappture::Units::Search::for $unit} runit]
990    set status2 [catch {Rappture::Units::System::for $unit} type]
991    list $status1 $runit $status2 $type
992} {0 Mm 0 length}
993
994test search-for-6.0.2.4 {Rappture::Units::Search::for, case searches - MM} {
995    set unit "MM"
996    set status1 [catch {Rappture::Units::Search::for $unit} runit]
997    set status2 [catch {Rappture::Units::System::for $unit} type]
998    list $status1 $runit $status2 $type
999} {0 Mm 0 length}
1000
1001test search-for-6.0.2.5 {Rappture::Units::Search::for, case searches - mM} {
1002    set unit "mM"
1003    set status1 [catch {Rappture::Units::Search::for $unit} runit]
1004    set status2 [catch {Rappture::Units::System::for $unit} type]
1005    list $status1 $runit $status2 $type
1006} {0 mm 0 length}
1007
1008test search-for-6.0.2.6 {Rappture::Units::Search::for, case searches - ks} {
1009    set unit "ks"
1010    set status1 [catch {Rappture::Units::Search::for $unit} runit]
1011    set status2 [catch {Rappture::Units::System::for $unit} type]
1012    list $status1 $runit $status2 $type
1013} {0 ks 0 time}
1014
1015test search-for-6.0.2.7 {Rappture::Units::Search::for, case searches - Ks} {
1016    set unit "Ks"
1017    set status1 [catch {Rappture::Units::Search::for $unit} runit]
1018    set status2 [catch {Rappture::Units::System::for $unit} type]
1019    list $status1 $runit $status2 $type
1020} {0 ks 0 time}
1021
1022test search-for-6.0.2.8 {Rappture::Units::Search::for, case searches - kS} {
1023    set unit "kS"
1024    set status1 [catch {Rappture::Units::Search::for $unit} runit]
1025    set status2 [catch {Rappture::Units::System::for $unit} type]
1026    list $status1 $runit $status2 $type
1027} {0 ks 0 time}
1028
1029test search-for-6.0.2.9 {Rappture::Units::Search::for, case searches - KS} {
1030    set unit "KS"
1031    set status1 [catch {Rappture::Units::Search::for $unit} runit]
1032    set status2 [catch {Rappture::Units::System::for $unit} type]
1033    list $status1 $runit $status2 $type
1034} {0 ks 0 time}
1035
1036test search-for-6.0.2.10 {Rappture::Units::Search::for, case searches - sk} {
1037    set unit "sk"
1038    set status1 [catch {Rappture::Units::Search::for $unit} runit]
1039    set status2 [catch {Rappture::Units::System::for $unit} type]
1040    list $status1 $runit $status2 $type
1041} {0 sK 0 time*temperature}
1042
1043test search-for-6.0.2.11 {Rappture::Units::Search::for, case searches - sK} {
1044    set unit "sK"
1045    set status1 [catch {Rappture::Units::Search::for $unit} runit]
1046    set status2 [catch {Rappture::Units::System::for $unit} type]
1047    list $status1 $runit $status2 $type
1048} {0 sK 0 time*temperature}
1049
1050#--------------------------------------------------------------------
1051# Allow isspace whitespace in Rappture::Units
1052#--------------------------------------------------------------------
1053
1054test space-7.0.0.1 {check for spaces before value unit string} {
1055    list [catch {Rappture::Units::Search::for " 300K"} msg] $msg
1056} {0 K}
1057
1058test space-7.0.0.2 {check for spaces after value unit string} {
1059    list [catch {Rappture::Units::Search::for "300K "} msg] $msg
1060} {0 K}
1061
1062test space-7.0.0.3 {check for spaces before and after value unit string} {
1063    list [catch {Rappture::Units::Search::for " 300K "} msg] $msg
1064} {0 K}
1065
1066test space-7.0.0.4 {check for spaces between value and unit string} {
1067    list [catch {Rappture::Units::Search::for " 300 K "} msg] $msg
1068} {0 K}
1069
1070test space-7.0.0.5 {check for spaces between value and single unit string} {
1071    list [catch {Rappture::Units::Search::for "300 K"} msg] $msg
1072} {0 K}
1073
1074test space-7.0.0.6 {check for spaces between value and multiple unit string} {
1075    list [catch {Rappture::Units::Search::for "300 Kft"} msg] $msg
1076} {0 Kft}
1077
1078test space-7.0.0.7 {check for spaces around and between value and multiple unit string} {
1079    list [catch {Rappture::Units::Search::for " 300 Kft "} msg] $msg
1080} {0 Kft}
1081
1082test space-7.0.0.8 {check for spaces between multiple unit string} {
1083    list [catch {Rappture::Units::Search::for "300 K ft"} msg] $msg
1084} {0 Kft}
1085
1086test space-7.0.0.9 {check for spaces around and between multiple unit string} {
1087    list [catch {Rappture::Units::Search::for " 300 K ft "} msg] $msg
1088} {0 Kft}
1089
1090test space-7.0.0.10 {check for spaces between multiple unit string with division} {
1091    list [catch {Rappture::Units::Search::for "300 K / ft"} msg] $msg
1092} {0 K/ft}
1093
1094test space-7.0.0.11 {check for spaces between multiple unit string with multiplication} {
1095    list [catch {Rappture::Units::Search::for "300 K * ft"} msg] $msg
1096} {0 Kft}
1097
1098test space-7.0.1.1 {check for tabs before value unit string} {
1099    list [catch {Rappture::Units::Search::for "\t300K"} msg] $msg
1100} {0 K}
1101
1102test space-7.0.1.2 {check for tabs after value unit string} {
1103    list [catch {Rappture::Units::Search::for "300K\t"} msg] $msg
1104} {0 K}
1105
1106test space-7.0.1.3 {check for tabs before and after value unit string} {
1107    list [catch {Rappture::Units::Search::for "\t300K\t"} msg] $msg
1108} {0 K}
1109
1110test space-7.0.1.4 {check for tabs between value and unit string} {
1111    list [catch {Rappture::Units::Search::for "\t300\tK\t"} msg] $msg
1112} {0 K}
1113
1114test space-7.0.1.5 {check for tabs between value and single unit string} {
1115    list [catch {Rappture::Units::Search::for "300\tK"} msg] $msg
1116} {0 K}
1117
1118test space-7.0.1.6 {check for tabs between value and multiple unit string} {
1119    list [catch {Rappture::Units::Search::for "300\tKft"} msg] $msg
1120} {0 Kft}
1121
1122test space-7.0.1.7 {check for tabs around and between value and multiple unit string} {
1123    list [catch {Rappture::Units::Search::for "\t300\tKft\t"} msg] $msg
1124} {0 Kft}
1125
1126test space-7.0.1.8 {check for tabs between multiple unit string} {
1127    list [catch {Rappture::Units::Search::for "300\tK\tft"} msg] $msg
1128} {0 Kft}
1129
1130test space-7.0.1.9 {check for tabs around and between multiple unit string} {
1131    list [catch {Rappture::Units::Search::for "\t300\tK\tft\t"} msg] $msg
1132} {0 Kft}
1133
1134test space-7.0.1.10 {check for tabs between multiple unit string with division} {
1135    list [catch {Rappture::Units::Search::for "300\tK\t/\tft"} msg] $msg
1136} {0 K/ft}
1137
1138test space-7.0.1.11 {check for tabs between multiple unit string with multiplication} {
1139    list [catch {Rappture::Units::Search::for "300\tK\t*\tft"} msg] $msg
1140} {0 Kft}
1141
1142test space-7.0.2.1 {check for newlines before value unit string} {
1143    list [catch {Rappture::Units::Search::for "\n300K"} msg] $msg
1144} {0 K}
1145
1146test space-7.0.2.2 {check for newlines after value unit string} {
1147    list [catch {Rappture::Units::Search::for "300K\n"} msg] $msg
1148} {0 K}
1149
1150test space-7.0.2.3 {check for newlines before and after value unit string} {
1151    list [catch {Rappture::Units::Search::for "\n300K\n"} msg] $msg
1152} {0 K}
1153
1154test space-7.0.2.4 {check for newlines between value and unit string} {
1155    list [catch {Rappture::Units::Search::for "\n300\nK\n"} msg] $msg
1156} {0 K}
1157
1158test space-7.0.2.5 {check for newlines between value and single unit string} {
1159    list [catch {Rappture::Units::Search::for "300\nK"} msg] $msg
1160} {0 K}
1161
1162test space-7.0.2.6 {check for newlines between value and multiple unit string} {
1163    list [catch {Rappture::Units::Search::for "300\nKft"} msg] $msg
1164} {0 Kft}
1165
1166test space-7.0.2.7 {check for newlines around and between value and multiple unit string} {
1167    list [catch {Rappture::Units::Search::for "\n300\nKft\n"} msg] $msg
1168} {0 Kft}
1169
1170test space-7.0.2.8 {check for newlines between multiple unit string} {
1171    list [catch {Rappture::Units::Search::for "300\nK\nft"} msg] $msg
1172} {0 Kft}
1173
1174test space-7.0.2.9 {check for newlines around and between multiple unit string} {
1175    list [catch {Rappture::Units::Search::for "\n300\nK\nft\n"} msg] $msg
1176} {0 Kft}
1177
1178test space-7.0.2.10 {check for newlines between multiple unit string with division} {
1179    list [catch {Rappture::Units::Search::for "300\nK\n/\nft"} msg] $msg
1180} {0 K/ft}
1181
1182test space-7.0.2.11 {check for newlines between multiple unit string with multiplication} {
1183    list [catch {Rappture::Units::Search::for "300\nK\n*\nft"} msg] $msg
1184} {0 Kft}
1185
1186# TODO:
1187# add tests for space and tab, space and newline, tab and newline
1188# add tests for bad characters &^%$#@!)(~`{}[]:;"'?><,.-_=+\ or |
1189
1190::tcltest::cleanupTests
1191return
1192
Note: See TracBrowser for help on using the repository browser.