Changeset 532


Ignore:
Timestamp:
Oct 9, 2006 12:19:51 PM (18 years ago)
Author:
dkearney
Message:

new test cases in units.test to make sure conversions are done correctly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tcl/tests/units.test

    r403 r532  
    5353test convert-1.1.2 {Rappture::Units::convert, invalid value, valid context} {
    5454    list [catch {Rappture::Units::convert re -context mm} msg] $msg
    55 } {1 {bad value "re": should be a real number with units of (A,ft,in,m,mm,yd)}}
     55} {1 {bad value "re": should be a real number with units of (A,in,m,mm)}}
    5656
    5757test convert-1.1.3 {Rappture::Units::convert, 1 valid argument} {
     
    163163# this test passes for new tcl bindings, fails for old tcl version
    164164    list [catch {Rappture::Units::convert de -context m } msg] $msg
    165 } {1 {bad value "de": should be a real number with units of (A,ft,in,m,yd)}}
     165} {1 {bad value "de": should be a real number with units of (A,in,m)}}
    166166
    167167
     
    268268} {0 {}}
    269269
    270 #test all-3.2.0.1 {Rappture::Units::System::all, valid units} {
     270#test all-4.2.0.1 {Rappture::Units::System::all, valid units} {
    271271## this test passes for old tcl version, fails for new tcl bindings
    272272## because different order of units
     
    274274#} {0 {eV J}}
    275275
    276 test all-3.2.0.2 {Rappture::Units::System::all, valid units} {
     276test all-4.2.0.2 {Rappture::Units::System::all, valid units} {
    277277# this test passes for new tcl bindings, fails for old tcl version
    278278    list [catch {Rappture::Units::System::all eV} msg] $msg
    279279} {0 {J eV}}
    280280
    281 #test all-3.3.0.1 {Rappture::Units::System::all, too many args} {
     281#test all-4.3.0.1 {Rappture::Units::System::all, too many args} {
    282282## this test passes for old tcl version, fails for new tcl bindings
    283283## because of additional "::" prefixed on object name
     
    285285#} {1 {wrong # args: should be "::Rappture::Units::System::all units"}}
    286286
    287 test all-3.3.0.2 {Rappture::Units::System::all, too many args} {
     287test all-4.3.0.2 {Rappture::Units::System::all, too many args} {
    288288# this test passes for new tcl bindings, fails for old tcl version
    289289    list [catch {Rappture::Units::System::all eV ee} msg] $msg
    290290} {1 {wrong # args: should be "Rappture::Units::System::all units"}}
    291291
     292#----------------------------------------------------------
     293#----------------------------------------------------------
     294# convert command - testing units conversions
     295#----------------------------------------------------------
     296
     297test convert_units-5.4.1.0 {Rappture::Units::convert, m->A} {
     298    list [catch {Rappture::Units::convert 5m -to A} msg] $msg
     299} {0 5e+10A}
     300
     301test convert_units-5.4.1.1 {Rappture::Units::convert, m<-A} {
     302    list [catch {Rappture::Units::convert 5A -to m} msg] $msg
     303} {0 5e-10m}
     304
     305#--------------------------------------------------------------------
     306# Metric Extension Conversions
     307#--------------------------------------------------------------------
     308
     309test convert_units-5.4.2.0 {Rappture::Units::convert, m->dm} {
     310    list [catch {Rappture::Units::convert 5m -to dm} msg] $msg
     311} {0 50dm}
     312
     313test convert_units-5.4.2.1 {Rappture::Units::convert, m->cm} {
     314    list [catch {Rappture::Units::convert 5m -to cm} msg] $msg
     315} {0 500cm}
     316
     317test convert_units-5.4.2.3 {Rappture::Units::convert, m->mm} {
     318    list [catch {Rappture::Units::convert 5m -to mm} msg] $msg
     319} {0 5000mm}
     320
     321test convert_units-5.4.2.4 {Rappture::Units::convert, m->um} {
     322    list [catch {Rappture::Units::convert 5m -to um} msg] $msg
     323} {0 5e+06um}
     324
     325test convert_units-5.4.2.5 {Rappture::Units::convert, m->nm} {
     326    list [catch {Rappture::Units::convert 5m -to nm} msg] $msg
     327} {0 5e+09nm}
     328
     329test convert_units-5.4.2.6 {Rappture::Units::convert, m->pm} {
     330    list [catch {Rappture::Units::convert 5m -to pm} msg] $msg
     331} {0 5e+12pm}
     332
     333test convert_units-5.4.2.7 {Rappture::Units::convert, m->fm} {
     334    list [catch {Rappture::Units::convert 5m -to fm} msg] $msg
     335} {0 5e+15fm}
     336
     337test convert_units-5.4.2.8 {Rappture::Units::convert, m->am} {
     338    list [catch {Rappture::Units::convert 5m -to am} msg] $msg
     339} {0 5e+18am}
     340
     341test convert_units-5.4.2.9 {Rappture::Units::convert, m->dam} {
     342    list [catch {Rappture::Units::convert 5m -to dam} msg] $msg
     343} {0 0.5dam}
     344
     345test convert_units-5.4.2.10 {Rappture::Units::convert, m->hm} {
     346    list [catch {Rappture::Units::convert 5m -to hm} msg] $msg
     347} {0 0.05hm}
     348
     349test convert_units-5.4.2.11 {Rappture::Units::convert, m->km} {
     350    list [catch {Rappture::Units::convert 5m -to km} msg] $msg
     351} {0 0.005km}
     352
     353test convert_units-5.4.2.12 {Rappture::Units::convert, m->Mm} {
     354    list [catch {Rappture::Units::convert 5m -to Mm} msg] $msg
     355} {0 5e-06Mm}
     356
     357test convert_units-5.4.2.13 {Rappture::Units::convert, m->Gm} {
     358    list [catch {Rappture::Units::convert 5m -to Gm} msg] $msg
     359} {0 5e-09Gm}
     360
     361test convert_units-5.4.2.14 {Rappture::Units::convert, m->Tm} {
     362    list [catch {Rappture::Units::convert 5m -to Tm} msg] $msg
     363} {0 5e-12Tm}
     364
     365test convert_units-5.4.2.15 {Rappture::Units::convert, m->Pm} {
     366    list [catch {Rappture::Units::convert 5m -to Pm} msg] $msg
     367} {0 5e-15Pm}
     368
     369test convert_units-5.4.2.16 {Rappture::Units::convert, m->Em} {
     370    list [catch {Rappture::Units::convert 5m -to Em} msg] $msg
     371} {0 5e-18Em}
     372
     373test convert_units-5.4.2.17 {Rappture::Units::convert, dm->m} {
     374    list [catch {Rappture::Units::convert 5dm -to m} msg] $msg
     375} {0 0.5m}
     376
     377test convert_units-5.4.2.18 {Rappture::Units::convert, cm->m} {
     378    list [catch {Rappture::Units::convert 5cm -to m} msg] $msg
     379} {0 0.05m}
     380
     381test convert_units-5.4.2.19 {Rappture::Units::convert, mm->m} {
     382    list [catch {Rappture::Units::convert 5mm -to m} msg] $msg
     383} {0 0.005m}
     384
     385test convert_units-5.4.2.20 {Rappture::Units::convert, um->m} {
     386    list [catch {Rappture::Units::convert 5um -to m} msg] $msg
     387} {0 5e-06m}
     388
     389test convert_units-5.4.2.21 {Rappture::Units::convert, nm->m} {
     390    list [catch {Rappture::Units::convert 5nm -to m} msg] $msg
     391} {0 5e-09m}
     392
     393test convert_units-5.4.2.22 {Rappture::Units::convert, pm->m} {
     394    list [catch {Rappture::Units::convert 5pm -to m} msg] $msg
     395} {0 5e-12m}
     396
     397test convert_units-5.4.2.23 {Rappture::Units::convert, fm->m} {
     398    list [catch {Rappture::Units::convert 5fm -to m} msg] $msg
     399} {0 5e-15m}
     400
     401test convert_units-5.4.2.24 {Rappture::Units::convert, am->m} {
     402    list [catch {Rappture::Units::convert 5am -to m} msg] $msg
     403} {0 5e-18m}
     404
     405test convert_units-5.4.2.25 {Rappture::Units::convert, dam->m} {
     406    list [catch {Rappture::Units::convert 5dam -to m} msg] $msg
     407} {0 50m}
     408
     409test convert_units-5.4.2.26 {Rappture::Units::convert, hm->m} {
     410    list [catch {Rappture::Units::convert 5hm -to m} msg] $msg
     411} {0 500m}
     412
     413test convert_units-5.4.2.27 {Rappture::Units::convert, km->m} {
     414    list [catch {Rappture::Units::convert 5km -to m} msg] $msg
     415} {0 5000m}
     416
     417test convert_units-5.4.2.28 {Rappture::Units::convert, Mm->m} {
     418    list [catch {Rappture::Units::convert 5Mm -to m} msg] $msg
     419} {0 5e+06m}
     420
     421test convert_units-5.4.2.29 {Rappture::Units::convert, Gm->G} {
     422    list [catch {Rappture::Units::convert 5Gm -to m} msg] $msg
     423} {0 5e+09m}
     424
     425test convert_units-5.4.2.30 {Rappture::Units::convert, Tm->m} {
     426    list [catch {Rappture::Units::convert 5Tm -to m} msg] $msg
     427} {0 5e+12m}
     428
     429test convert_units-5.4.2.31 {Rappture::Units::convert, Pm->m} {
     430    list [catch {Rappture::Units::convert 5Pm -to m} msg] $msg
     431} {0 5e+15m}
     432
     433test convert_units-5.4.2.32 {Rappture::Units::convert, Em->m} {
     434    list [catch {Rappture::Units::convert 5Em -to m} msg] $msg
     435} {0 5e+18m}
     436
     437#--------------------------------------------------------------------
     438# Concentration Conversions
     439#--------------------------------------------------------------------
     440
     441test convert_units-5.4.3.0 {Rappture::Units::convert, pH->pOH} {
     442    list [catch {Rappture::Units::convert 5pH -to pOH} msg] $msg
     443} {0 9pOH}
     444
     445test convert_units-5.4.3.1 {Rappture::Units::convert, pOH->pH} {
     446    list [catch {Rappture::Units::convert 9pOH -to pH} msg] $msg
     447} {0 5pH}
     448
     449#--------------------------------------------------------------------
     450# Multiple Unit Conversions
     451#--------------------------------------------------------------------
     452
     453test convert_units-5.4.4.0 {Rappture::Units::convert, cm2/Vs->m2/kVus} {
     454    list [catch {Rappture::Units::convert 2cm2/Vs -to m2/kVus} msg] $msg
     455} {0 2e-07m2/kVus}
     456
     457#--------------------------------------------------------------------
     458# Inverse Unit Conversions
     459#--------------------------------------------------------------------
     460
     461test convert_units-5.4.5.0 {Rappture::Units::convert, /cm2->/m2} {
     462    list [catch {Rappture::Units::convert 2/cm2 -to /m2} msg] $msg
     463} {0 20000/m2}
     464
     465test convert_units-5.4.5.1 {Rappture::Units::convert, cm2->/m2} {
     466    list [catch {Rappture::Units::convert 1cm -to /m2} msg] $msg
     467} {1 {error while converting, returned string: "1/m2"}}
     468
     469#--------------------------------------------------------------------
     470# Temperature Conversions
     471#--------------------------------------------------------------------
     472
     473test convert_units-5.4.6.0 {Rappture::Units::convert, F->C} {
     474    list [catch {Rappture::Units::convert 78.8F -to C} msg] $msg
     475} {0 26C}
     476
     477test convert_units-5.4.6.1 {Rappture::Units::convert, C->F} {
     478    list [catch {Rappture::Units::convert 26C -to F} msg] $msg
     479} {0 78.8F}
     480
     481test convert_units-5.4.6.2 {Rappture::Units::convert, C->K} {
     482    list [catch {Rappture::Units::convert 26C -to K} msg] $msg
     483} {0 299.15K}
     484
     485test convert_units-5.4.6.3 {Rappture::Units::convert, K->C} {
     486    list [catch {Rappture::Units::convert 299.15K -to C} msg] $msg
     487} {0 26C}
     488
     489test convert_units-5.4.6.4 {Rappture::Units::convert, K->F} {
     490    list [catch {Rappture::Units::convert 299.15K -to F} msg] $msg
     491} {0 78.8F}
     492
     493test convert_units-5.4.6.5 {Rappture::Units::convert, F->K} {
     494    list [catch {Rappture::Units::convert 78.8F -to K} msg] $msg
     495} {0 299.15K}
     496
     497test convert_units-5.4.6.6 {Rappture::Units::convert, F->R} {
     498    list [catch {Rappture::Units::convert 78.8F -to R} msg] $msg
     499} {0 538.47R}
     500
     501test convert_units-5.4.6.7 {Rappture::Units::convert, R->F} {
     502    list [catch {Rappture::Units::convert 538.47R -to F} msg] $msg
     503} {0 78.8F}
     504
     505test convert_units-5.4.6.8 {Rappture::Units::convert, R->C} {
     506    list [catch {Rappture::Units::convert 538.47R -to C} msg] $msg
     507} {0 26C}
     508
     509test convert_units-5.4.6.9 {Rappture::Units::convert, C->R} {
     510    list [catch {Rappture::Units::convert 26C -to R} msg] $msg
     511} {0 538.47R}
     512
     513test convert_units-5.4.6.10 {Rappture::Units::convert, R->K} {
     514    list [catch {Rappture::Units::convert 538.47R -to K} msg] $msg
     515} {0 299.15K}
     516
     517test convert_units-5.4.6.11 {Rappture::Units::convert, K->R} {
     518    list [catch {Rappture::Units::convert 299.15K -to R} msg] $msg
     519} {0 538.47R}
     520
     521#--------------------------------------------------------------------
     522# Energy Conversions
     523#--------------------------------------------------------------------
     524
     525test convert_units-5.4.7.0 {Rappture::Units::convert, eV->J} {
     526    list [catch {Rappture::Units::convert 5eV -to J} msg] $msg
     527} {0 8.01089e-19J}
     528
     529test convert_units-5.4.7.1 {Rappture::Units::convert, J->eV} {
     530    list [catch {Rappture::Units::convert 8.01088231e-19J -to eV} msg] $msg
     531} {0 5eV}
     532
     533#--------------------------------------------------------------------
     534# Time Conversions
     535#--------------------------------------------------------------------
     536
     537test convert_units-5.4.8.0 {Rappture::Units::convert, s->s} {
     538    list [catch {Rappture::Units::convert 5s -to s} msg] $msg
     539} {0 5s}
     540
     541test convert_units-5.4.8.1 {Rappture::Units::convert, min->s} {
     542    list [catch {Rappture::Units::convert 5min -to s} msg] $msg
     543} {0 300s}
     544
     545test convert_units-5.4.8.2 {Rappture::Units::convert, h->s} {
     546    list [catch {Rappture::Units::convert 5h -to s} msg] $msg
     547} {0 18000s}
     548
     549test convert_units-5.4.8.3 {Rappture::Units::convert, d->s} {
     550    list [catch {Rappture::Units::convert 5d -to s} msg] $msg
     551} {0 432000s}
     552
     553test convert_units-5.4.8.4 {Rappture::Units::convert, s->min} {
     554    list [catch {Rappture::Units::convert 5s -to min} msg] $msg
     555} {0 0.0833333min}
     556
     557test convert_units-5.4.8.5 {Rappture::Units::convert, min->min} {
     558    list [catch {Rappture::Units::convert 5min -to min} msg] $msg
     559} {0 5min}
     560
     561test convert_units-5.4.8.6 {Rappture::Units::convert, h->min} {
     562    list [catch {Rappture::Units::convert 5h -to min} msg] $msg
     563} {0 300min}
     564
     565test convert_units-5.4.8.7 {Rappture::Units::convert, d->min} {
     566    list [catch {Rappture::Units::convert 5d -to min} msg] $msg
     567} {0 7200min}
     568
     569test convert_units-5.4.8.8 {Rappture::Units::convert, s->h} {
     570    list [catch {Rappture::Units::convert 5s -to h} msg] $msg
     571} {0 0.00138889h}
     572
     573test convert_units-5.4.8.9 {Rappture::Units::convert, min->h} {
     574    list [catch {Rappture::Units::convert 5min -to h} msg] $msg
     575} {0 0.0833333h}
     576
     577test convert_units-5.4.8.10 {Rappture::Units::convert, h->h} {
     578    list [catch {Rappture::Units::convert 5h -to h} msg] $msg
     579} {0 5h}
     580
     581test convert_units-5.4.8.11 {Rappture::Units::convert, d->h} {
     582    list [catch {Rappture::Units::convert 5d -to h} msg] $msg
     583} {0 120h}
     584
     585test convert_units-5.4.8.12 {Rappture::Units::convert, s->d} {
     586    list [catch {Rappture::Units::convert 5s -to d} msg] $msg
     587} {0 5.78704e-05d}
     588
     589test convert_units-5.4.8.13 {Rappture::Units::convert, min->d} {
     590    list [catch {Rappture::Units::convert 5min -to d} msg] $msg
     591} {0 0.00347222d}
     592
     593test convert_units-5.4.8.14 {Rappture::Units::convert, h->d} {
     594    list [catch {Rappture::Units::convert 5h -to d} msg] $msg
     595} {0 0.208333d}
     596
     597test convert_units-5.4.8.15 {Rappture::Units::convert, d->d} {
     598    list [catch {Rappture::Units::convert 5d -to d} msg] $msg
     599} {0 5d}
     600
     601#--------------------------------------------------------------------
     602# Pressure Conversions
     603#--------------------------------------------------------------------
     604
     605test convert_units-5.4.9.0 {Rappture::Units::convert, bar->Pa} {
     606    list [catch {Rappture::Units::convert 5bar -to Pa} msg] $msg
     607} {0 500000Pa}
     608
     609test convert_units-5.4.9.1 {Rappture::Units::convert, bar->atm} {
     610    list [catch {Rappture::Units::convert 5bar -to atm} msg] $msg
     611} {0 4.9346atm}
     612
     613test convert_units-5.4.9.2 {Rappture::Units::convert, bar->torr} {
     614    list [catch {Rappture::Units::convert 5bar -to torr} msg] $msg
     615} {0 3750.3torr}
     616
     617test convert_units-5.4.9.3 {Rappture::Units::convert, bar->psi} {
     618    list [catch {Rappture::Units::convert 5bar -to psi} msg] $msg
     619} {0 72.52psi}
     620
     621test convert_units-5.4.9.4 {Rappture::Units::convert, bar->bar} {
     622    list [catch {Rappture::Units::convert 5bar -to bar} msg] $msg
     623} {0 5bar}
     624
     625test convert_units-5.4.9.5 {Rappture::Units::convert, atm->Pa} {
     626    list [catch {Rappture::Units::convert 5atm -to Pa} msg] $msg
     627} {0 506625Pa}
     628
     629test convert_units-5.4.9.6 {Rappture::Units::convert, atm->atm} {
     630    list [catch {Rappture::Units::convert 5atm -to atm} msg] $msg
     631} {0 5atm}
     632
     633test convert_units-5.4.9.7 {Rappture::Units::convert, atm->torr} {
     634    list [catch {Rappture::Units::convert 5atm -to torr} msg] $msg
     635} {0 3800torr}
     636
     637test convert_units-5.4.9.8 {Rappture::Units::convert, atm->psi} {
     638    list [catch {Rappture::Units::convert 5bar -to psi} msg] $msg
     639} {0 72.52psi}
     640
     641test convert_units-5.4.9.9 {Rappture::Units::convert, atm->bar} {
     642    list [catch {Rappture::Units::convert 5atm -to bar} msg] $msg
     643} {0 5.06627bar}
     644
     645test convert_units-5.4.9.10 {Rappture::Units::convert, Pa->Pa} {
     646    list [catch {Rappture::Units::convert 5Pa -to Pa} msg] $msg
     647} {0 5Pa}
     648
     649test convert_units-5.4.9.11 {Rappture::Units::convert, Pa->atm} {
     650    list [catch {Rappture::Units::convert 5Pa -to atm} msg] $msg
     651} {0 4.9346e-05atm}
     652
     653test convert_units-5.4.9.12 {Rappture::Units::convert, Pa->torr} {
     654    list [catch {Rappture::Units::convert 5Pa -to torr} msg] $msg
     655} {0 0.037503torr}
     656
     657test convert_units-5.4.9.13 {Rappture::Units::convert, Pa->psi} {
     658    list [catch {Rappture::Units::convert 5Pa -to psi} msg] $msg
     659} {0 0.0007252psi}
     660
     661test convert_units-5.4.9.14 {Rappture::Units::convert, Pa->bar} {
     662    list [catch {Rappture::Units::convert 5Pa -to bar} msg] $msg
     663} {0 5e-05bar}
     664
     665test convert_units-5.4.9.15 {Rappture::Units::convert, torr->Pa} {
     666    list [catch {Rappture::Units::convert 5torr -to Pa} msg] $msg
     667} {0 666.613Pa}
     668
     669test convert_units-5.4.9.16 {Rappture::Units::convert, torr->atm} {
     670    list [catch {Rappture::Units::convert 5torr -to atm} msg] $msg
     671} {0 0.006579atm}
     672
     673test convert_units-5.4.9.17 {Rappture::Units::convert, torr->torr} {
     674    list [catch {Rappture::Units::convert 5torr -to torr} msg] $msg
     675} {0 5torr}
     676
     677test convert_units-5.4.9.18 {Rappture::Units::convert, torr->psi} {
     678    list [catch {Rappture::Units::convert 5torr -to psi} msg] $msg
     679} {0 0.096685psi}
     680
     681test convert_units-5.4.9.19 {Rappture::Units::convert, torr->bar} {
     682    list [catch {Rappture::Units::convert 5torr -to bar} msg] $msg
     683} {0 0.00666613bar}
     684
     685test convert_units-5.4.9.20 {Rappture::Units::convert, psi->Pa} {
     686    list [catch {Rappture::Units::convert 5psi -to Pa} msg] $msg
     687} {0 34473.8Pa}
     688
     689test convert_units-5.4.9.21 {Rappture::Units::convert, psi->atm} {
     690    list [catch {Rappture::Units::convert 5psi -to atm} msg] $msg
     691} {0 0.34023atm}
     692
     693test convert_units-5.4.9.22 {Rappture::Units::convert, psi->torr} {
     694    list [catch {Rappture::Units::convert 5psi -to torr} msg] $msg
     695} {0 258.575torr}
     696
     697test convert_units-5.4.9.23 {Rappture::Units::convert, psi->psi} {
     698    list [catch {Rappture::Units::convert 5psi -to psi} msg] $msg
     699} {0 5psi}
     700
     701test convert_units-5.4.9.24 {Rappture::Units::convert, psi->bar} {
     702    list [catch {Rappture::Units::convert 5psi -to bar} msg] $msg
     703} {0 0.344738bar}
     704
     705test convert_units-5.4.9.25 {Rappture::Units::convert, psi->kPa} {
     706    list [catch {Rappture::Units::convert 5psi -to kPa} msg] $msg
     707} {0 34.4738kPa}
     708
     709test convert_units-5.4.9.26 {Rappture::Units::convert, kPa->psi} {
     710    list [catch {Rappture::Units::convert 5kPa -to psi} msg] $msg
     711} {0 0.7252psi}
     712
     713test convert_units-5.4.9.27 {Rappture::Units::convert, mmHg->torr} {
     714    list [catch {Rappture::Units::convert 5mmHg -to torr} msg] $msg
     715} {0 5torr}
     716
     717test convert_units-5.4.9.28 {Rappture::Units::convert, torr->mmHg} {
     718    list [catch {Rappture::Units::convert 5torr -to mmHg} msg] $msg
     719} {0 5mmHg}
     720
     721
     722
     723
    292724
    293725::tcltest::cleanupTests
Note: See TracChangeset for help on using the changeset viewer.