Changeset 525
- Timestamp:
- Sep 20, 2006 10:14:40 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpUnits.cc
r520 r525 1212 1212 } 1213 1213 1214 // outVal.flags(std::ios::fixed); 1215 // outVal.precision(10); 1216 1214 1217 if (showUnits) { 1215 1218 outVal << numVal << toUnitsName; … … 1673 1676 retVal = RpUnitsPreset::addPresetAll(); 1674 1677 } 1675 else if (group.compare( "energy") == 0) {1678 else if (group.compare(RP_TYPE_ENERGY) == 0) { 1676 1679 retVal = RpUnitsPreset::addPresetEnergy(); 1677 1680 } 1678 else if (group.compare( "length") == 0) {1681 else if (group.compare(RP_TYPE_LENGTH) == 0) { 1679 1682 retVal = RpUnitsPreset::addPresetLength(); 1680 1683 } 1681 else if (group.compare( "temp") == 0) {1684 else if (group.compare(RP_TYPE_TEMP) == 0) { 1682 1685 retVal = RpUnitsPreset::addPresetTemp(); 1683 1686 } 1684 else if (group.compare( "time") == 0) {1687 else if (group.compare(RP_TYPE_TIME) == 0) { 1685 1688 retVal = RpUnitsPreset::addPresetTime(); 1686 1689 } 1687 else if (group.compare( "volume") == 0) {1690 else if (group.compare(RP_TYPE_VOLUME) == 0) { 1688 1691 retVal = RpUnitsPreset::addPresetVolume(); 1689 1692 } 1690 else if (group.compare( "angle") == 0) {1693 else if (group.compare(RP_TYPE_ANGLE) == 0) { 1691 1694 retVal = RpUnitsPreset::addPresetAngle(); 1695 } 1696 else if (group.compare(RP_TYPE_MASS) == 0) { 1697 retVal = RpUnitsPreset::addPresetMass(); 1698 } 1699 else if (group.compare(RP_TYPE_PRESSURE) == 0) { 1700 retVal = RpUnitsPreset::addPresetPressure(); 1701 } 1702 else if (group.compare(RP_TYPE_MISC) == 0) { 1703 retVal = RpUnitsPreset::addPresetMisc(); 1692 1704 } 1693 1705 … … 1716 1728 result += addPresetAngle(); 1717 1729 result += addPresetMass(); 1730 result += addPresetPressure(); 1718 1731 result += addPresetMisc(); 1719 1732 … … 1932 1945 1933 1946 /**********************************************************************/ 1947 // METHOD: addPresetPressure() 1948 /// Add pressure related units to the dictionary 1949 /** 1950 * http://www.ilpi.com/msds/ref/pressureunits.html 1951 * 1952 * Defines the following units: 1953 * bar (bar) 1954 * pascal (Pa) 1955 * pounds/(in^2) (psi) 1956 * torr (torr) 1957 * millimeters Mercury (mmHg) 1958 * 1959 * mmHg was added because as a convenience to those who have not 1960 * yet switched over to the new representation of torr. 1961 * 1962 * Return codes: 0 success, anything else is error 1963 */ 1964 1965 int 1966 RpUnitsPreset::addPresetPressure () { 1967 1968 RpUnits* atmosphere = RpUnits::define("atm", NULL, RP_TYPE_PRESSURE); 1969 RpUnits* bar = RpUnits::define("bar", NULL, RP_TYPE_PRESSURE); 1970 RpUnits* pascal = RpUnits::define("Pa", NULL, RP_TYPE_PRESSURE); 1971 RpUnits* psi = RpUnits::define("psi", NULL, RP_TYPE_PRESSURE); 1972 RpUnits* torr = RpUnits::define("torr", NULL, RP_TYPE_PRESSURE); 1973 RpUnits* mmHg = RpUnits::define("mmHg", torr, RP_TYPE_PRESSURE); 1974 1975 RpUnits::makeMetric(pascal); 1976 RpUnits::makeMetric(bar); 1977 1978 RpUnits::define(bar,pascal,bar2Pa,Pa2bar); 1979 RpUnits::define(bar,atmosphere,bar2atm,atm2bar); 1980 RpUnits::define(bar,psi,bar2psi,psi2bar); 1981 RpUnits::define(bar,torr,bar2torr,torr2bar); 1982 RpUnits::define(pascal,atmosphere,Pa2atm,atm2Pa); 1983 RpUnits::define(pascal,torr,Pa2torr,torr2Pa); 1984 RpUnits::define(pascal,psi,Pa2psi,psi2Pa); 1985 RpUnits::define(torr,atmosphere,torr2atm,atm2torr); 1986 RpUnits::define(torr,psi,torr2psi,psi2torr); 1987 1988 RpUnits::define(torr,mmHg,torr2mmHg,mmHg2torr); 1989 1990 return 0; 1991 } 1992 1993 /**********************************************************************/ 1934 1994 // METHOD: addPresetMisc() 1935 1995 /// Add Misc related units to the dictionary -
trunk/src/core/RpUnits.h
r520 r525 30 30 31 31 //define our different types of units 32 #define RP_TYPE_ENERGY "energy" 33 #define RP_TYPE_LENGTH "length" 34 #define RP_TYPE_TEMP "temperature" 35 #define RP_TYPE_TIME "time" 36 #define RP_TYPE_VOLUME "volume" 37 #define RP_TYPE_ANGLE "angle" 38 #define RP_TYPE_MASS "mass" 39 #define RP_TYPE_MISC "misc" 32 #define RP_TYPE_ENERGY "energy" 33 #define RP_TYPE_LENGTH "length" 34 #define RP_TYPE_TEMP "temperature" 35 #define RP_TYPE_TIME "time" 36 #define RP_TYPE_VOLUME "volume" 37 #define RP_TYPE_ANGLE "angle" 38 #define RP_TYPE_MASS "mass" 39 #define RP_TYPE_PRESSURE "pressure" 40 #define RP_TYPE_MISC "misc" 40 41 41 42 // should the define function: … … 64 65 static int addPresetAngle(); 65 66 static int addPresetMass(); 67 static int addPresetPressure(); 66 68 static int addPresetMisc(); 67 69 }; -
trunk/src/core/RpUnitsStd.cc
r515 r525 336 336 } 337 337 338 /**************************************** 339 * PRESSURE CONVERSIONS 340 * http://www.ilpi.com/msds/ref/pressureunits.html 341 * http://en.wikipedia.org/wiki/Bar_%28unit%29 342 ****************************************/ 343 344 double bar2Pa (double bar) 345 { 346 return (bar*100000.00); 347 } 348 349 double Pa2bar (double Pa) 350 { 351 return (Pa/100000.00); 352 } 353 354 double bar2atm (double bar) 355 { 356 return (bar*0.98692); 357 } 358 359 double atm2bar (double atm) 360 { 361 return (atm/0.98692); 362 } 363 364 double bar2torr (double bar) 365 { 366 return (bar*750.06); 367 } 368 369 double torr2bar (double torr) 370 { 371 return (torr/750.06); 372 } 373 374 double bar2psi (double bar) 375 { 376 return (bar*14.504); 377 } 378 379 double psi2bar (double psi) 380 { 381 return (psi*0.0689476); 382 } 383 384 double Pa2atm (double Pa) 385 { 386 return (Pa*9.8692e-6); 387 } 388 389 double atm2Pa (double atm) 390 { 391 // need to check this conversion 392 // tests fail 393 return (atm*101325.024); 394 } 395 396 double Pa2torr (double Pa) 397 { 398 return (Pa*7.5006e-3); 399 } 400 401 double torr2Pa (double torr) 402 { 403 return (torr/7.5006e-3); 404 } 405 406 double Pa2psi (double Pa) 407 { 408 return (Pa*145.04e-6); 409 } 410 411 double psi2Pa (double psi) 412 { 413 // need to check this conversion 414 // test fails because of truncation 415 return (psi*6894.7625831); 416 } 417 418 double torr2atm (double torr) 419 { 420 return (torr*1.3158e-3); 421 } 422 423 double atm2torr (double atm) 424 { 425 return (atm*760); 426 } 427 428 double torr2psi (double torr) 429 { 430 return (torr*19.337e-3); 431 } 432 433 double psi2torr (double psi) 434 { 435 return (psi*51.71496); 436 } 437 438 double torr2mmHg (double torr) 439 { 440 return (torr); 441 } 442 443 double mmHg2torr (double mmHg) 444 { 445 return (mmHg); 446 } 338 447 339 448 -
trunk/src/core/RpUnitsStd.h
r515 r525 93 93 double day2sec (double day); 94 94 95 96 97 98 double bar2Pa (double bar); 99 double Pa2bar (double Pa); 100 double bar2atm (double bar); 101 double atm2bar (double atm); 102 double bar2torr (double bar); 103 double torr2bar (double torr); 104 double bar2psi (double bar); 105 double psi2bar (double psi); 106 double Pa2atm (double Pa); 107 double atm2Pa (double atm); 108 double Pa2torr (double Pa); 109 double torr2Pa (double torr); 110 double Pa2psi (double Pa); 111 double psi2Pa (double psi); 112 double torr2atm (double torr); 113 double atm2torr (double atm); 114 double torr2psi (double torr); 115 double psi2torr (double psi); 116 double torr2mmHg (double torr); 117 double mmHg2torr (double mmHg); 118 double kPa2KPa (double kPa); 119 double KPa2kPa (double KPa); 120 121 122 95 123 #ifdef __cplusplus 96 124 } -
trunk/test/src/RpUnits_test.cc
r515 r525 10 10 #include <list> 11 11 #include <string> 12 #include <cassert> 12 13 13 14 … … 23 24 } 24 25 26 // compare_numbers() 25 27 26 28 int main() … … 328 330 329 331 // day hour min sec test 330 std::cout << "convert(\"5.00s\",\"s\",1) = " << RpUnits::convert("5.00s","s",1) << " = 5s" << std::endl; 331 std::cout << "convert(\"5.00s\",\"s\",0) = " << RpUnits::convert("5.00s","s",0) << " = 5" << std::endl; 332 std::cout << "convert(\"5.00min\",\"s\",1) = " << RpUnits::convert("5.00min","s",1) << " = 300s" << std::endl; 333 std::cout << "convert(\"5.00min\",\"s\",0) = " << RpUnits::convert("5.00min","s",0) << " = 300" << std::endl; 334 std::cout << "convert(\"5.00h\",\"s\",1) = " << RpUnits::convert("5.00h","s",1) << " = 18000s" << std::endl; 335 std::cout << "convert(\"5.00h\",\"s\",0) = " << RpUnits::convert("5.00h","s",0) << " = 18000" << std::endl; 336 std::cout << "convert(\"5.00d\",\"s\",1) = " << RpUnits::convert("5.00d","s",1) << " = 432000s" << std::endl; 337 std::cout << "convert(\"5.00d\",\"s\",0) = " << RpUnits::convert("5.00d","s",0) << " = 432000" << std::endl; 338 339 std::cout << "convert(\"5.00s\",\"min\",1) = " << RpUnits::convert("5.00s","min",1) << " = 300min" << std::endl; 340 std::cout << "convert(\"5.00s\",\"min\",0) = " << RpUnits::convert("5.00s","min",0) << " = 300" << std::endl; 341 std::cout << "convert(\"5.00min\",\"min\",1) = " << RpUnits::convert("5.00min","min",1) << " = 5min" << std::endl; 342 std::cout << "convert(\"5.00min\",\"min\",0) = " << RpUnits::convert("5.00min","min",0) << " = 5" << std::endl; 343 std::cout << "convert(\"5.00h\",\"min\",1) = " << RpUnits::convert("5.00h","min",1) << " = 300min" << std::endl; 344 std::cout << "convert(\"5.00h\",\"min\",0) = " << RpUnits::convert("5.00h","min",0) << " = 300" << std::endl; 345 std::cout << "convert(\"5.00d\",\"min\",1) = " << RpUnits::convert("5.00d","min",1) << " = 7200min" << std::endl; 346 std::cout << "convert(\"5.00d\",\"min\",0) = " << RpUnits::convert("5.00d","min",0) << " = 7200" << std::endl; 347 348 std::cout << "convert(\"5.00s\",\"h\",1) = " << RpUnits::convert("5.00s","h",1) << " = 0.001388h" << std::endl; 349 std::cout << "convert(\"5.00s\",\"h\",0) = " << RpUnits::convert("5.00s","h",0) << " = 0.001388" << std::endl; 350 std::cout << "convert(\"5.00min\",\"h\",1) = " << RpUnits::convert("5.00min","h",1) << " = 0.0833h" << std::endl; 351 std::cout << "convert(\"5.00min\",\"h\",0) = " << RpUnits::convert("5.00min","h",0) << " = 0.0833" << std::endl; 352 std::cout << "convert(\"5.00h\",\"h\",1) = " << RpUnits::convert("5.00h","h",1) << " = 5h" << std::endl; 353 std::cout << "convert(\"5.00h\",\"h\",0) = " << RpUnits::convert("5.00h","h",0) << " = 5" << std::endl; 354 std::cout << "convert(\"5.00d\",\"h\",1) = " << RpUnits::convert("5.00d","h",1) << " = 120h" << std::endl; 355 std::cout << "convert(\"5.00d\",\"h\",0) = " << RpUnits::convert("5.00d","h",0) << " = 120" << std::endl; 356 357 std::cout << "convert(\"5.00s\",\"d\",1) = " << RpUnits::convert("5.00s","d",1) << " = 5.7870e-05d" << std::endl; 358 std::cout << "convert(\"5.00s\",\"d\",0) = " << RpUnits::convert("5.00s","d",0) << " = 5.7870e-05" << std::endl; 359 std::cout << "convert(\"5.00min\",\"d\",1) = " << RpUnits::convert("5.00min","d",1) << " = 0.00347222d" << std::endl; 360 std::cout << "convert(\"5.00min\",\"d\",0) = " << RpUnits::convert("5.00min","d",0) << " = 0.00347222" << std::endl; 361 std::cout << "convert(\"5.00h\",\"d\",1) = " << RpUnits::convert("5.00h","d",1) << " = 0.208333d" << std::endl; 362 std::cout << "convert(\"5.00h\",\"d\",0) = " << RpUnits::convert("5.00h","d",0) << " = 0.208333" << std::endl; 363 std::cout << "convert(\"5.00d\",\"d\",1) = " << RpUnits::convert("5.00d","d",1) << " = 5d" << std::endl; 364 std::cout << "convert(\"5.00d\",\"d\",0) = " << RpUnits::convert("5.00d","d",0) << " = 5" << std::endl; 332 assert((RpUnits::convert("5.00s","s",RpUnits::UNITS_ON)) == "5s"); 333 std::cout << "convert(\"5.00s\",\"s\",UNITS_ON) passed" << std::endl; 334 assert((RpUnits::convert("5.00s","s",RpUnits::UNITS_OFF)) == "5"); 335 std::cout << "convert(\"5.00s\",\"s\",UNITS_OFF) passed" << std::endl; 336 assert((RpUnits::convert("5.00min","s",RpUnits::UNITS_ON)) == "300s"); 337 std::cout << "convert(\"5.00min\",\"s\",UNITS_ON) passed" << std::endl; 338 assert((RpUnits::convert("5.00min","s",RpUnits::UNITS_OFF)) == "300"); 339 std::cout << "convert(\"5.00min\",\"s\",UNITS_OFF) passed" << std::endl; 340 assert((RpUnits::convert("5.00h","s",RpUnits::UNITS_ON)) == "18000s"); 341 std::cout << "convert(\"5.00h\",\"s\",UNITS_ON) passed" << std::endl; 342 assert((RpUnits::convert("5.00h","s",RpUnits::UNITS_OFF)) == "18000"); 343 std::cout << "convert(\"5.00h\",\"s\",UNITS_OFF) passed" << std::endl; 344 assert((RpUnits::convert("5.00d","s",RpUnits::UNITS_ON)) == "432000s"); 345 std::cout << "convert(\"5.00d\",\"s\",UNITS_ON) passed" << std::endl; 346 assert((RpUnits::convert("5.00d","s",RpUnits::UNITS_OFF)) == "432000"); 347 std::cout << "convert(\"5.00d\",\"s\",UNITS_OFF) passed" << std::endl; 348 349 assert((RpUnits::convert("5.00s","min",RpUnits::UNITS_ON)) == "0.0833333min"); 350 std::cout << "convert(\"5.00s\",\"min\",UNITS_ON) passed" << std::endl; 351 assert((RpUnits::convert("5.00s","min",RpUnits::UNITS_OFF)) == "0.0833333"); 352 std::cout << "convert(\"5.00s\",\"min\",UNITS_OFF) passed" << std::endl; 353 assert((RpUnits::convert("5.00min","min",RpUnits::UNITS_ON)) == "5min"); 354 std::cout << "convert(\"5.00min\",\"min\",UNITS_ON) passed" << std::endl; 355 assert((RpUnits::convert("5.00min","min",RpUnits::UNITS_OFF)) == "5"); 356 std::cout << "convert(\"5.00min\",\"min\",UNITS_OFF) passed" << std::endl; 357 assert((RpUnits::convert("5.00h","min",RpUnits::UNITS_ON)) == "300min"); 358 std::cout << "convert(\"5.00h\",\"min\",UNITS_ON) passed" << std::endl; 359 assert((RpUnits::convert("5.00h","min",RpUnits::UNITS_OFF)) == "300"); 360 std::cout << "convert(\"5.00h\",\"min\",UNITS_OFF) passed" << std::endl; 361 assert((RpUnits::convert("5.00d","min",RpUnits::UNITS_ON)) == "7200min"); 362 std::cout << "convert(\"5.00d\",\"min\",UNITS_ON) passed" << std::endl; 363 assert((RpUnits::convert("5.00d","min",RpUnits::UNITS_OFF)) == "7200"); 364 std::cout << "convert(\"5.00d\",\"min\",UNITS_OFF) passed" << std::endl; 365 366 assert((RpUnits::convert("5.00s","h",RpUnits::UNITS_ON)) == "0.00138889h"); 367 std::cout << "convert(\"5.00s\",\"h\",UNITS_ON) passed" << std::endl; 368 assert((RpUnits::convert("5.00s","h",RpUnits::UNITS_OFF)) == "0.00138889"); 369 std::cout << "convert(\"5.00s\",\"h\",UNITS_OFF) passed" << std::endl; 370 assert((RpUnits::convert("5.00min","h",RpUnits::UNITS_ON)) == "0.0833333h"); 371 std::cout << "convert(\"5.00min\",\"h\",UNITS_ON) passed" << std::endl; 372 assert((RpUnits::convert("5.00min","h",RpUnits::UNITS_OFF)) == "0.0833333"); 373 std::cout << "convert(\"5.00min\",\"h\",UNITS_OFF) passed" << std::endl; 374 assert((RpUnits::convert("5.00h","h",RpUnits::UNITS_ON)) == "5h"); 375 std::cout << "convert(\"5.00h\",\"h\",UNITS_ON) passed" << std::endl; 376 assert((RpUnits::convert("5.00h","h",RpUnits::UNITS_OFF)) == "5"); 377 std::cout << "convert(\"5.00h\",\"h\",UNITS_OFF) passed" << std::endl; 378 assert((RpUnits::convert("5.00d","h",RpUnits::UNITS_ON)) == "120h"); 379 std::cout << "convert(\"5.00d\",\"h\",UNITS_ON) passed" << std::endl; 380 assert((RpUnits::convert("5.00d","h",RpUnits::UNITS_OFF)) == "120"); 381 std::cout << "convert(\"5.00d\",\"h\",UNITS_OFF) passed" << std::endl; 382 383 assert((RpUnits::convert("5.00s","d",RpUnits::UNITS_ON)) == "5.78704e-05d"); 384 std::cout << "convert(\"5.00s\",\"d\",UNITS_ON) passed" << std::endl; 385 assert((RpUnits::convert("5.00s","d",RpUnits::UNITS_OFF)) == "5.78704e-05"); 386 std::cout << "convert(\"5.00s\",\"d\",UNITS_OFF) passed" << std::endl; 387 assert((RpUnits::convert("5.00min","d",RpUnits::UNITS_ON)) == "0.00347222d"); 388 std::cout << "convert(\"5.00min\",\"d\",UNITS_ON) passed" << std::endl; 389 assert((RpUnits::convert("5.00min","d",RpUnits::UNITS_OFF)) == "0.00347222"); 390 std::cout << "convert(\"5.00min\",\"d\",UNITS_OFF) passed" << std::endl; 391 assert((RpUnits::convert("5.00h","d",RpUnits::UNITS_ON)) == "0.208333d"); 392 std::cout << "convert(\"5.00h\",\"d\",UNITS_ON) passed" << std::endl; 393 assert((RpUnits::convert("5.00h","d",RpUnits::UNITS_OFF)) == "0.208333"); 394 std::cout << "convert(\"5.00h\",\"d\",UNITS_OFF) passed" << std::endl; 395 assert((RpUnits::convert("5.00d","d",RpUnits::UNITS_ON)) == "5d"); 396 std::cout << "convert(\"5.00d\",\"d\",UNITS_ON) passed" << std::endl; 397 assert((RpUnits::convert("5.00d","d",RpUnits::UNITS_OFF)) == "5"); 398 std::cout << "convert(\"5.00d\",\"d\",UNITS_OFF) passed" << std::endl; 399 400 401 402 assert((RpUnits::convert("5.00bar","Pa",RpUnits::UNITS_OFF)) == "500000"); 403 std::cout << "convert(\"5.00bar\",\"Pa\",UNITS_OFF) passed" << std::endl; 404 assert((RpUnits::convert("5.00bar","Pa",RpUnits::UNITS_ON)) == "500000Pa"); 405 std::cout << "convert(\"5.00bar\",\"Pa\",UNITS_ON) passed" << std::endl; 406 assert((RpUnits::convert("5.00bar","atm",RpUnits::UNITS_OFF)) == "4.9346"); 407 std::cout << "convert(\"5.00bar\",\"atm\",UNITS_OFF) passed" << std::endl; 408 assert((RpUnits::convert("5.00bar","atm",RpUnits::UNITS_ON)) == "4.9346atm"); 409 std::cout << "convert(\"5.00bar\",\"atm\",UNITS_ON) passed" << std::endl; 410 assert((RpUnits::convert("5.00bar","torr",RpUnits::UNITS_OFF)) == "3750.3"); 411 std::cout << "convert(\"5.00bar\",\"torr\",UNITS_OFF) passed" << std::endl; 412 assert((RpUnits::convert("5.00bar","torr",RpUnits::UNITS_ON)) == "3750.3torr"); 413 std::cout << "convert(\"5.00bar\",\"torr\",UNITS_ON) passed" << std::endl; 414 assert((RpUnits::convert("5.00bar","psi",RpUnits::UNITS_OFF)) == "72.52"); 415 std::cout << "convert(\"5.00bar\",\"psi\",UNITS_OFF) passed" << std::endl; 416 assert((RpUnits::convert("5.00bar","psi",RpUnits::UNITS_ON)) == "72.52psi"); 417 std::cout << "convert(\"5.00bar\",\"psi\",UNITS_ON) passed" << std::endl; 418 419 420 421 422 assert((RpUnits::convert("5.00atm","bar",RpUnits::UNITS_OFF)) == "5.06627"); 423 std::cout << "convert(\"5.00atm\",\"bar\",UNITS_OFF) passed" << std::endl; 424 assert((RpUnits::convert("5.00atm","bar",RpUnits::UNITS_ON)) == "5.06627bar"); 425 std::cout << "convert(\"5.00atm\",\"bar\",UNITS_ON) passed" << std::endl; 426 /* 427 assert((RpUnits::convert("5.00atm","Pa",RpUnits::UNITS_OFF)) == "506625.12"); 428 std::cout << "convert(\"5.00atm\",\"Pa\",UNITS_OFF) passed" << std::endl; 429 assert((RpUnits::convert("5.00atm","Pa",RpUnits::UNITS_ON)) == "506625.12Pa"); 430 std::cout << "convert(\"5.00atm\",\"Pa\",UNITS_ON) passed" << std::endl; 431 */ 432 assert((RpUnits::convert("5.00atm","torr",RpUnits::UNITS_OFF)) == "3800"); 433 std::cout << "convert(\"5.00atm\",\"torr\",UNITS_OFF) passed" << std::endl; 434 assert((RpUnits::convert("5.00atm","torr",RpUnits::UNITS_ON)) == "3800torr"); 435 std::cout << "convert(\"5.00atm\",\"torr\",UNITS_ON) passed" << std::endl; 436 437 438 439 440 assert((RpUnits::convert("5.00Pa","bar",RpUnits::UNITS_OFF)) == "5e-05"); 441 std::cout << "convert(\"5.00Pa\",\"bar\",UNITS_OFF) passed" << std::endl; 442 assert((RpUnits::convert("5.00Pa","bar",RpUnits::UNITS_ON)) == "5e-05bar"); 443 std::cout << "convert(\"5.00Pa\",\"bar\",UNITS_ON) passed" << std::endl; 444 assert((RpUnits::convert("5.00Pa","atm",RpUnits::UNITS_OFF)) == "4.9346e-05"); 445 std::cout << "convert(\"5.00Pa\",\"atm\",UNITS_OFF) passed" << std::endl; 446 assert((RpUnits::convert("5.00Pa","atm",RpUnits::UNITS_ON)) == "4.9346e-05atm"); 447 std::cout << "convert(\"5.00Pa\",\"atm\",UNITS_ON) passed" << std::endl; 448 assert((RpUnits::convert("5.00Pa","torr",RpUnits::UNITS_OFF)) == "0.037503"); 449 std::cout << "convert(\"5.00Pa\",\"torr\",UNITS_OFF) passed" << std::endl; 450 assert((RpUnits::convert("5.00Pa","torr",RpUnits::UNITS_ON)) == "0.037503torr"); 451 std::cout << "convert(\"5.00Pa\",\"torr\",UNITS_ON) passed" << std::endl; 452 assert((RpUnits::convert("5.00Pa","psi",RpUnits::UNITS_OFF)) == "0.0007252"); 453 std::cout << "convert(\"5.00Pa\",\"psi\",UNITS_OFF) passed" << std::endl; 454 assert((RpUnits::convert("5.00Pa","psi",RpUnits::UNITS_ON)) == "0.0007252psi"); 455 std::cout << "convert(\"5.00Pa\",\"psi\",UNITS_ON) passed" << std::endl; 456 457 458 459 460 assert((RpUnits::convert("5.00torr","bar",RpUnits::UNITS_OFF)) == "0.00666613"); 461 std::cout << "convert(\"5.00torr\",\"bar\",UNITS_OFF) passed" << std::endl; 462 assert((RpUnits::convert("5.00torr","bar",RpUnits::UNITS_ON)) == "0.00666613bar"); 463 std::cout << "convert(\"5.00torr\",\"bar\",UNITS_ON) passed" << std::endl; 464 assert((RpUnits::convert("5.00torr","Pa",RpUnits::UNITS_OFF)) == "666.613"); 465 std::cout << "convert(\"5.00torr\",\"Pa\",UNITS_OFF) passed" << std::endl; 466 assert((RpUnits::convert("5.00torr","Pa",RpUnits::UNITS_ON)) == "666.613Pa"); 467 std::cout << "convert(\"5.00torr\",\"Pa\",UNITS_ON) passed" << std::endl; 468 assert((RpUnits::convert("5.00torr","atm",RpUnits::UNITS_OFF)) == "0.006579"); 469 std::cout << "convert(\"5.00torr\",\"atm\",UNITS_OFF) passed" << std::endl; 470 assert((RpUnits::convert("5.00torr","atm",RpUnits::UNITS_ON)) == "0.006579atm"); 471 std::cout << "convert(\"5.00torr\",\"atm\",UNITS_ON) passed" << std::endl; 472 assert((RpUnits::convert("5.00torr","psi",RpUnits::UNITS_OFF)) == "0.096685"); 473 std::cout << "convert(\"5.00torr\",\"psi\",UNITS_OFF) passed" << std::endl; 474 assert((RpUnits::convert("5.00torr","psi",RpUnits::UNITS_ON)) == "0.096685psi"); 475 std::cout << "convert(\"5.00torr\",\"psi\",UNITS_ON) passed" << std::endl; 476 477 478 assert((RpUnits::convert("5.00psi","bar",RpUnits::UNITS_OFF)) == "0.344738"); 479 std::cout << "convert(\"5.00psi\",\"bar\",UNITS_OFF) passed" << std::endl; 480 assert((RpUnits::convert("5.00psi","bar",RpUnits::UNITS_ON)) == "0.344738bar"); 481 std::cout << "convert(\"5.00psi\",\"bar\",UNITS_ON) passed" << std::endl; 482 /* 483 assert((RpUnits::convert("5.00psi","Pa",RpUnits::UNITS_OFF)) == "34473.8129155"); 484 std::cout << "convert(\"5.00psi\",\"Pa\",UNITS_OFF) passed" << std::endl; 485 assert((RpUnits::convert("5.00psi","Pa",RpUnits::UNITS_ON)) == "34473.8129155Pa"); 486 std::cout << "convert(\"5.00psi\",\"Pa\",UNITS_ON) passed" << std::endl; 487 */ 488 assert((RpUnits::convert("5.00psi","torr",RpUnits::UNITS_OFF)) == "258.575"); 489 std::cout << "convert(\"5.00psi\",\"torr\",UNITS_OFF) passed" << std::endl; 490 assert((RpUnits::convert("5.00psi","torr",RpUnits::UNITS_ON)) == "258.575torr"); 491 std::cout << "convert(\"5.00psi\",\"torr\",UNITS_ON) passed" << std::endl; 492 493 494 495 496 assert((RpUnits::convert("5.00psi","kPa",RpUnits::UNITS_OFF)) == "34.4738"); 497 std::cout << "convert(\"5.00psi\",\"kPa\",UNITS_OFF) passed" << std::endl; 498 assert((RpUnits::convert("5.00psi","kPa",RpUnits::UNITS_ON)) == "34.4738kPa"); 499 std::cout << "convert(\"5.00psi\",\"kPa\",UNITS_ON) passed" << std::endl; 500 501 502 503 504 assert((RpUnits::convert("5.00torr","mmHg",RpUnits::UNITS_OFF)) == "5"); 505 std::cout << "convert(\"5.00torr\",\"mmHg\",UNITS_OFF) passed" << std::endl; 506 assert((RpUnits::convert("5.00torr","mmHg",RpUnits::UNITS_ON)) == "5mmHg"); 507 std::cout << "convert(\"5.00torr\",\"mmHg\",UNITS_ON) passed" << std::endl; 365 508 366 509 return 0;
Note: See TracChangeset
for help on using the changeset viewer.