Changeset 114 for trunk/test


Ignore:
Timestamp:
Oct 20, 2005 8:47:25 PM (19 years ago)
Author:
dkearney
Message:

updates to RpUnits to reduce memory leaks
created copy constructors, destructors, and copy assignment operators
for Units classes. removed conv as a data member and removed several
constructors. removed prev & next pointers from conversion class.
this removes linked list feature from conversion class which was not
being used. this update does not fix python's problem with performing
conversion between RpUnits objects or the allow for the recognition of
/cm3 as an object related to cm3.

also removed some outdated files rappture_interface.h, rappture_interface.c.
RpDict?.cc has been moved into RpDict?.h in previous checkins to reduce
dependencies on include files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/src/RpUnits_test.cc

    r104 r114  
    258258    const RpUnits* eV  = RpUnits::define("eV", NULL);
    259259    const RpUnits* joules  = RpUnits::define("J", NULL);
    260    
     260
    261261    RpUnits::define(eV, joules, electronVolt2joule, joule2electronVolt);
    262    
     262
    263263    value = joules->convert(eV,1,&result);
    264264    std::cout << "1 joule = " << value << " electronVolts" << std::endl;
    265    
     265
    266266    value = eV->convert(joules,1,&result);
    267267    std::cout << "1 electronVolt = " << value << " joules" << std::endl;
    268    
     268
    269269    strValue = RpUnits::convert("10eV","J",1);
    270270    std::cout << "strValue convert(10eV,J,1) = " << strValue << std::endl;
     
    272272    strValue = RpUnits::convert("1eV","J",0);
    273273    std::cout << "strValue convert(1eV,J,0) = " << strValue << std::endl;
    274    
     274
    275275    strValue = RpUnits::convert("10J","eV",1);
    276276    std::cout << "strValue convert(10J,eV,1) = " << strValue << std::endl;
     
    278278    strValue = RpUnits::convert("1J","eV",0);
    279279    std::cout << "strValue convert(1J,eV,0) = " << strValue << std::endl;
    280    
     280
     281
     282
     283
     284
     285
     286    std::cout << "TESTING COPY CONSTRUCTOR" << std::endl;
     287
     288    RpUnits *origRpUnits = RpUnits::define("obj2", NULL);
     289    RpUnits copyRpUnits = *origRpUnits;
     290
     291    std::cout << "origRpUnits = " << origRpUnits->getUnitsName() << std::endl;
     292    std::cout << "copyRpUnits = " << copyRpUnits.getUnitsName() << std::endl;
     293    std::cout << "modifying origRpUnits" << std::endl;
     294    delete origRpUnits;
     295    origRpUnits = RpUnits::define("obj3",NULL);
     296    std::cout << "origRpUnits = " << origRpUnits->getUnitsName() << std::endl;
     297    std::cout << "copyRpUnits = " << copyRpUnits.getUnitsName() << std::endl;
     298    std::cout << "deleting origRpUnits" << std::endl;
     299    delete origRpUnits;
     300    std::cout << "copyRpUnits = " << copyRpUnits.getUnitsName() << std::endl;
     301
     302    std::cout << "TESTING COPY ASSIGNMENT OPERATOR" << std::endl;
     303
     304    RpUnits *testRpUnits = RpUnits::define("test2", NULL);
     305    copyRpUnits = *testRpUnits;
     306
     307    std::cout << "testRpUnits = " << testRpUnits->getUnitsName() << std::endl;
     308    std::cout << "copyRpUnits = " << copyRpUnits.getUnitsName() << std::endl;
     309    std::cout << "modifying testRpUnits" << std::endl;
     310    delete testRpUnits;
     311    testRpUnits = RpUnits::define("test3",NULL);
     312    std::cout << "testRpUnits = " << testRpUnits->getUnitsName() << std::endl;
     313    std::cout << "copyRpUnits = " << copyRpUnits.getUnitsName() << std::endl;
     314    std::cout << "deleting testRpUnits" << std::endl;
     315    delete testRpUnits;
     316    std::cout << "copyRpUnits = " << copyRpUnits.getUnitsName() << std::endl;
    281317    return 0;
    282318}
Note: See TracChangeset for help on using the changeset viewer.