Changeset 532
- Timestamp:
- Oct 9, 2006 12:19:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tcl/tests/units.test
r403 r532 53 53 test convert-1.1.2 {Rappture::Units::convert, invalid value, valid context} { 54 54 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)}} 56 56 57 57 test convert-1.1.3 {Rappture::Units::convert, 1 valid argument} { … … 163 163 # this test passes for new tcl bindings, fails for old tcl version 164 164 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)}} 166 166 167 167 … … 268 268 } {0 {}} 269 269 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} { 271 271 ## this test passes for old tcl version, fails for new tcl bindings 272 272 ## because different order of units … … 274 274 #} {0 {eV J}} 275 275 276 test all- 3.2.0.2 {Rappture::Units::System::all, valid units} {276 test all-4.2.0.2 {Rappture::Units::System::all, valid units} { 277 277 # this test passes for new tcl bindings, fails for old tcl version 278 278 list [catch {Rappture::Units::System::all eV} msg] $msg 279 279 } {0 {J eV}} 280 280 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} { 282 282 ## this test passes for old tcl version, fails for new tcl bindings 283 283 ## because of additional "::" prefixed on object name … … 285 285 #} {1 {wrong # args: should be "::Rappture::Units::System::all units"}} 286 286 287 test all- 3.3.0.2 {Rappture::Units::System::all, too many args} {287 test all-4.3.0.2 {Rappture::Units::System::all, too many args} { 288 288 # this test passes for new tcl bindings, fails for old tcl version 289 289 list [catch {Rappture::Units::System::all eV ee} msg] $msg 290 290 } {1 {wrong # args: should be "Rappture::Units::System::all units"}} 291 291 292 #---------------------------------------------------------- 293 #---------------------------------------------------------- 294 # convert command - testing units conversions 295 #---------------------------------------------------------- 296 297 test 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 301 test 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 309 test 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 313 test 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 317 test 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 321 test 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 325 test 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 329 test 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 333 test 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 337 test 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 341 test 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 345 test 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 349 test 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 353 test 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 357 test 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 361 test 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 365 test 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 369 test 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 373 test 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 377 test 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 381 test 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 385 test 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 389 test 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 393 test 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 397 test 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 401 test 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 405 test 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 409 test 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 413 test 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 417 test 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 421 test 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 425 test 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 429 test 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 433 test 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 441 test 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 445 test 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 453 test 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 461 test 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 465 test 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 473 test 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 477 test 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 481 test 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 485 test 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 489 test 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 493 test 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 497 test 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 501 test 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 505 test 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 509 test 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 513 test 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 517 test 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 525 test 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 529 test 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 537 test 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 541 test 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 545 test 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 549 test 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 553 test 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 557 test 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 561 test 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 565 test 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 569 test 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 573 test 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 577 test 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 581 test 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 585 test 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 589 test 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 593 test 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 597 test 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 605 test 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 609 test 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 613 test 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 617 test 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 621 test 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 625 test 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 629 test 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 633 test 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 637 test 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 641 test 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 645 test 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 649 test 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 653 test 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 657 test 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 661 test 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 665 test 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 669 test 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 673 test 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 677 test 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 681 test 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 685 test 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 689 test 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 693 test 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 697 test 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 701 test 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 705 test 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 709 test 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 713 test 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 717 test 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 292 724 293 725 ::tcltest::cleanupTests
Note: See TracChangeset
for help on using the changeset viewer.