Changeset 560 for trunk


Ignore:
Timestamp:
Dec 14, 2006, 9:10:14 AM (18 years ago)
Author:
dkearney
Message:

updated the tcl units.tcl test file to reflect changes in the core units code

Location:
trunk/src/tcl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tcl/src/RpUnitsTclInterface.cc

    r549 r560  
    5353
    5454
    55 static int list2str (std::list<std::string>& inList, std::string& outString);
    5655
    5756
     
    113112{
    114113    std::string inValue       = ""; // value provided by the user
     114    std::string origUnitsName = "";
    115115    std::string fromUnitsName = ""; // name of the units for user's value
    116116    std::string toUnitsName   = ""; // name of the units to convert to
     
    158158                    fromUnitsName = std::string(argv[nextarg]);
    159159                    err = 0;
     160                    origUnitsName = fromUnitsName;
    160161                    err = RpUnits::validate(fromUnitsName,type,&compatList);
    161162                    if ( err != 0) {
    162163                        Tcl_AppendResult(interp,
    163                             "bad value \"", fromUnitsName.c_str(),
     164                            "bad value \"", origUnitsName.c_str(),
    164165                            "\": should be a recognized unit for Rappture",
    165166                            (char*)NULL);
     
    178179                    toUnitsName = std::string(argv[nextarg]);
    179180                    err = 0;
     181                    origUnitsName = toUnitsName;
    180182                    err = RpUnits::validate(toUnitsName,type);
    181183                    if (err != 0) {
    182184                        Tcl_AppendResult(interp,
    183                             "bad value \"", toUnitsName.c_str(),
     185                            "bad value \"", origUnitsName.c_str(),
    184186                            "\": should be a recognized unit for Rappture",
    185187                            (char*)NULL);
     
    317319    // const RpUnits* unitsObj   = NULL;
    318320    std::list<std::string> compatList;
    319     std::list<std::string>::iterator compatListIter;
    320321
    321322    int nextarg               = 1; // start parsing using the '2'th argument
     
    536537    return TCL_OK;
    537538}
    538 
    539 /**********************************************************************/
    540 // FUNCTION: list2str()
    541 /// Convert a std::list<std::string> into a comma delimited std::string
    542 /**
    543  * Iterates through a std::list<std::string> and returns a comma
    544  * delimited std::string containing the elements of the inputted std::list.
    545  *
    546  * Returns 0 on success, anything else is error
    547  */
    548 
    549 int
    550 list2str (std::list<std::string>& inList, std::string& outString)
    551 {
    552     int retVal = 1;  // return Value 0 is success, everything else is failure
    553     unsigned int counter = 0; // check if we hit all elements of inList
    554     std::list<std::string>::iterator inListIter; // list interator
    555 
    556     inListIter = inList.begin();
    557 
    558     while (inListIter != inList.end()) {
    559         if ( outString.empty() ) {
    560             outString = *inListIter;
    561         }
    562         else {
    563             outString =  outString + "," + *inListIter;
    564         }
    565 
    566         // increment the iterator and loop counter
    567         inListIter++;
    568         counter++;
    569     }
    570 
    571     if (counter == inList.size()) {
    572         retVal = 0;
    573     }
    574 
    575     return retVal;
    576 }
  • trunk/src/tcl/tests/units.test

    r549 r560  
    168168test convert-1.8.0 {Rappture::Units::convert, convert undefined unit} {
    169169    list [catch {Rappture::Units::convert 33Q -to nm } msg] $msg
    170 } {1 {unrecognized units: "Q"}}
     170} {1 {Unrecognized units: "Q".
     171Should be units of type length (A,in,m,nm)}}
    171172
    172173#----------------------------------------------------------
     
    465466test convert_units-5.4.4.2 {Rappture::Units::convert, cm2nZ/Vs->m2/us} {
    466467    list [catch {Rappture::Units::convert 2cm2nZ/Vs -to m2/us} msg] $msg
    467 } {1 {unrecognized units: "cm2nZ/Vs"}}
     468} {1 {Unrecognized units: "cm2nZ/Vs".
     469Should be units of type length/time (/s,/us,A2,in2,m2)}}
    468470
    469471test convert_units-5.4.4.3 {Rappture::Units::convert, cm2/s->m2/kVus} {
    470472    list [catch {Rappture::Units::convert 2cm2/s -to m2/kVus} msg] $msg
    471 } {1 {unmatched units in conversion: (kV-1)}}
     473} {1 {unmatched units in conversion: (kV-1)
     474Please enter units of type length/electric_potential*time (/V,/kV,/s,/us,A2,in2,m2)}}
    472475
    473476test convert_units-5.4.4.4 {Rappture::Units::convert, cm2/s->m2/uskV} {
    474477    list [catch {Rappture::Units::convert 2cm2/s -to m2/uskV} msg] $msg
    475 } {1 {unmatched units in conversion: (kV-1)}}
     478} {1 {unmatched units in conversion: (kV-1)
     479Please enter units of type length/time*electric_potential (/V,/kV,/s,/us,A2,in2,m2)}}
    476480
    477481test convert_units-5.4.4.5 {Rappture::Units::convert, cm2V/s->m2/us} {
    478482    list [catch {Rappture::Units::convert 2cm2V/s -to m2/us} msg] $msg
    479 } {1 {unmatched units in conversion: (V1)}}
     483} {1 {unmatched units in conversion: (V)
     484Please enter units of type length/time (/s,/us,A2,in2,m2)}}
    480485
    481486test convert_units-5.4.4.6 {Rappture::Units::convert, cm2V/s->m2/us} {
    482487    list [catch {Rappture::Units::convert 2cm2V/s -to m2/us} msg] $msg
    483 } {1 {unmatched units in conversion: (V1)}}
     488} {1 {unmatched units in conversion: (V)
     489Please enter units of type length/time (/s,/us,A2,in2,m2)}}
    484490
    485491test convert_units-5.4.4.7 {Rappture::Units::convert, cm2V->m2} {
    486492    list [catch {Rappture::Units::convert 2cm2V -to m2} msg] $msg
    487 } {1 {unmatched units in conversion: (V1)}}
     493} {1 {unmatched units in conversion: (V)
     494Please enter units of type length (A2,in2,m2)}}
    488495
    489496test convert_units-5.4.4.8 {Rappture::Units::convert, Vcm2->m2} {
    490497    list [catch {Rappture::Units::convert 2Vcm2 -to m2} msg] $msg
    491 } {1 {unmatched units in conversion: (V1)}}
     498} {1 {unmatched units in conversion: (V)
     499Please enter units of type length (A2,in2,m2)}}
    492500
    493501test convert_units-5.4.4.9 {Rappture::Units::convert, cm2->Vm2} {
    494502    list [catch {Rappture::Units::convert 2cm2 -to Vm2} msg] $msg
    495 } {1 {unmatched units in conversion: (V1)}}
     503} {1 {unmatched units in conversion: (V)
     504Please enter units of type electric_potential*length (A2,V,in2,m2)}}
    496505
    497506test convert_units-5.4.4.10 {Rappture::Units::convert, cm2->m2V} {
    498507    list [catch {Rappture::Units::convert 2cm2 -to m2V} msg] $msg
    499 } {1 {unmatched units in conversion: (V1)}}
     508} {1 {unmatched units in conversion: (V)
     509Please enter units of type length*electric_potential (A2,V,in2,m2)}}
    500510
    501511test convert_units-5.4.4.11 {Rappture::Units::convert, cm2A->Vm2} {
    502512    list [catch {Rappture::Units::convert 2cm2A -to Vm2} msg] $msg
    503 } {1 {unmatched units in conversion: (A1) -> (V1)}}
     513} {1 {unmatched units in conversion: (A) -> (V)
     514Please enter units of type electric_potential*length (A2,V,in2,m2)}}
    504515
    505516test convert_units-5.4.4.12 {Rappture::Units::convert, cm2A->m2V} {
    506517    list [catch {Rappture::Units::convert 2cm2A -to m2V} msg] $msg
    507 } {1 {conversion unavailable: (A1) -> (V1)}}
     518} {1 {Conversion unavailable: (A) -> (V)
     519Please enter units of type length*electric_potential (A2,V,in2,m2)}}
    508520
    509521test convert_units-5.4.4.13 {Rappture::Units::convert, Acm2->Vm2} {
    510522    list [catch {Rappture::Units::convert 2Acm2 -to Vm2} msg] $msg
    511 } {1 {unmatched units in conversion: (A1) -> (V1)}}
     523} {1 {unmatched units in conversion: (A) -> (V)
     524Please enter units of type electric_potential*length (A2,V,in2,m2)}}
    512525
    513526test convert_units-5.4.4.14 {Rappture::Units::convert, Acm2->m2V} {
    514527    list [catch {Rappture::Units::convert 2Acm2 -to m2V} msg] $msg
    515 } {1 {conversion unavailable: (A1) -> (V1)}}
     528} {1 {Conversion unavailable: (A) -> (V)
     529Please enter units of type length*electric_potential (A2,V,in2,m2)}}
    516530
    517531#--------------------------------------------------------------------
     
    525539test convert_units-5.4.5.1 {Rappture::Units::convert, cm2->/m2} {
    526540    list [catch {Rappture::Units::convert 1cm -to /m2} msg] $msg
    527 } {1 {conversion unavailable: (cm1) -> (m-2)}}
     541} {1 {Conversion unavailable: (cm) -> (m-2)
     542Please enter units of type /length (/A2,/in2,/m2)}}
    528543
    529544#--------------------------------------------------------------------
     
    785800test convert_units-5.4.10.1 {Rappture::Units::convert, torr->mmhg} {
    786801    list [catch {Rappture::Units::convert 5torr -to mmhg} msg] $msg
    787 } {0 5mmhg}
     802} {0 5mmHg}
    788803
    789804test convert_units-5.4.10.2 {Rappture::Units::convert, ToRr->mmhg} {
    790805    list [catch {Rappture::Units::convert 5ToRr -to mmhg} msg] $msg
    791 } {0 5mmhg}
     806} {0 5mmHg}
    792807
    793808test convert_units-5.4.10.3 {Rappture::Units::convert, kpa->PSI} {
    794809    list [catch {Rappture::Units::convert 5kpa -to PSI} msg] $msg
    795 } {0 0.7252PSI}
     810} {0 0.7252psi}
    796811
    797812test convert_units-5.4.10.4 {Rappture::Units::convert, KPA->PsI} {
    798813    list [catch {Rappture::Units::convert 5KPA -to PsI} msg] $msg
    799 } {0 0.7252PsI}
     814} {0 0.7252psi}
    800815
    801816test convert_units-5.4.10.5 {Rappture::Units::convert, Cm2/vS->M2/KVUS} {
    802817    list [catch {Rappture::Units::convert 2Cm2/vS -to M2/KVUS} msg] $msg
    803 } {0 2e-07M2/KVUS}
     818} {0 2e-07m2/kVus}
    804819
    805820#--------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.