Commit a243b810d1bda5ff8bdfa5edf5addf4d3c3dc447
1 parent
a9cb04a2
Comment out unit tests for saved FITS files until HDU consistency is assued (issue #37).
Showing
2 changed files
with
130 additions
and
6 deletions
test/test_GFits.cpp
| @@ -420,6 +420,7 @@ void TestGFits::test_create(void) | @@ -420,6 +420,7 @@ void TestGFits::test_create(void) | ||
| 420 | system("rm -rf test_empty_image.fits"); | 420 | system("rm -rf test_empty_image.fits"); |
| 421 | system("rm -rf test.fits"); | 421 | system("rm -rf test.fits"); |
| 422 | system("rm -rf test_create_bintable.fits"); | 422 | system("rm -rf test_create_bintable.fits"); |
| 423 | + system("rm -rf test_container.fits"); | ||
| 423 | 424 | ||
| 424 | // Create empty FITS file | 425 | // Create empty FITS file |
| 425 | test_try("Create empty FITS file"); | 426 | test_try("Create empty FITS file"); |
| @@ -446,7 +447,7 @@ void TestGFits::test_create(void) | @@ -446,7 +447,7 @@ void TestGFits::test_create(void) | ||
| 446 | test_try_failure(e); | 447 | test_try_failure(e); |
| 447 | } | 448 | } |
| 448 | 449 | ||
| 449 | - // Attach double precision image | 450 | + // Append double precision image |
| 450 | double sum = 0.0; | 451 | double sum = 0.0; |
| 451 | test_try("Attach double precision image"); | 452 | test_try("Attach double precision image"); |
| 452 | try { | 453 | try { |
| @@ -494,7 +495,7 @@ void TestGFits::test_create(void) | @@ -494,7 +495,7 @@ void TestGFits::test_create(void) | ||
| 494 | } | 495 | } |
| 495 | test_value(total, sum, 1e-10, "Test loading of double precision image"); | 496 | test_value(total, sum, 1e-10, "Test loading of double precision image"); |
| 496 | 497 | ||
| 497 | - // Attach binary table (save variant) | 498 | + // Append binary table (save variant) |
| 498 | test_try("Attach binary table (save variant)"); | 499 | test_try("Attach binary table (save variant)"); |
| 499 | try { | 500 | try { |
| 500 | // Re-open FITS file | 501 | // Re-open FITS file |
| @@ -525,7 +526,6 @@ void TestGFits::test_create(void) | @@ -525,7 +526,6 @@ void TestGFits::test_create(void) | ||
| 525 | test_try_failure(e); | 526 | test_try_failure(e); |
| 526 | } | 527 | } |
| 527 | 528 | ||
| 528 | - | ||
| 529 | // Create binary table (saveto variant) | 529 | // Create binary table (saveto variant) |
| 530 | test_try("Create binary table (saveto variant)"); | 530 | test_try("Create binary table (saveto variant)"); |
| 531 | try { | 531 | try { |
| @@ -555,6 +555,130 @@ void TestGFits::test_create(void) | @@ -555,6 +555,130 @@ void TestGFits::test_create(void) | ||
| 555 | test_try_failure(e); | 555 | test_try_failure(e); |
| 556 | } | 556 | } |
| 557 | 557 | ||
| 558 | + // Test FITS file in memory container manipulation | ||
| 559 | + test_try("In memory container manipulation"); | ||
| 560 | + try { | ||
| 561 | + // Allocate empty FITS file | ||
| 562 | + GFits fits; | ||
| 563 | + test_assert(fits.isempty(), "FITS file should be empty"); | ||
| 564 | + test_value(fits.size(), 0); | ||
| 565 | + | ||
| 566 | + // Create an image and a table to play with | ||
| 567 | + GFitsImageDouble image(10, 10); | ||
| 568 | + GFitsBinTable table(10); | ||
| 569 | + | ||
| 570 | + // Append two images | ||
| 571 | + fits.append(image); | ||
| 572 | + fits.append(image); | ||
| 573 | + test_assert(!fits.isempty(), "FITS file should not be empty"); | ||
| 574 | + test_value(fits.size(), 2); | ||
| 575 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 576 | + test_value(fits.at(i)->extno(), i); | ||
| 577 | + } | ||
| 578 | + | ||
| 579 | + // Replace image by table | ||
| 580 | + fits.set(1, table); | ||
| 581 | + test_value(fits.size(), 2); | ||
| 582 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 583 | + test_value(fits.at(i)->extno(), i); | ||
| 584 | + } | ||
| 585 | + | ||
| 586 | + // Insert image in 2nd slot | ||
| 587 | + fits.insert(1, image); | ||
| 588 | + test_value(fits.size(), 3); | ||
| 589 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 590 | + test_value(fits.at(i)->extno(), i); | ||
| 591 | + } | ||
| 592 | + | ||
| 593 | + // Remove image in 2nd slot | ||
| 594 | + fits.remove(1); | ||
| 595 | + test_value(fits.size(), 2); | ||
| 596 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 597 | + test_value(fits.at(i)->extno(), i); | ||
| 598 | + } | ||
| 599 | + | ||
| 600 | + // Extent FITS file | ||
| 601 | + fits.extend(fits); | ||
| 602 | + test_value(fits.size(), 4); | ||
| 603 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 604 | + test_value(fits.at(i)->extno(), i); | ||
| 605 | + } | ||
| 606 | + | ||
| 607 | + // Signal success | ||
| 608 | + test_try_success(); | ||
| 609 | + } | ||
| 610 | + catch (std::exception &e) { | ||
| 611 | + test_try_failure(e); | ||
| 612 | + } | ||
| 613 | + | ||
| 614 | + // Test FITS file container manipulation | ||
| 615 | +/* | ||
| 616 | + test_try("File container manipulation"); | ||
| 617 | + try { | ||
| 618 | + // Create FITS file | ||
| 619 | + GFits fits("test_container.fits", true); | ||
| 620 | + test_assert(fits.isempty(), "FITS file should be empty"); | ||
| 621 | + test_value(fits.size(), 0); | ||
| 622 | + | ||
| 623 | + // Create an image and a table to play with | ||
| 624 | + GFitsImageDouble image(10, 10); | ||
| 625 | + GFitsBinTable table(10); | ||
| 626 | + | ||
| 627 | + // Append two images | ||
| 628 | + fits.append(image); | ||
| 629 | + fits.append(image); | ||
| 630 | + fits.save(true); | ||
| 631 | + fits.close(); | ||
| 632 | + fits.open("test_container.fits"); | ||
| 633 | + test_assert(!fits.isempty(), "FITS file should not be empty"); | ||
| 634 | + test_value(fits.size(), 2); | ||
| 635 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 636 | + test_value(fits.at(i)->extno(), i); | ||
| 637 | + } | ||
| 638 | +std::cout << fits << std::endl; | ||
| 639 | + | ||
| 640 | + // Replace image by table | ||
| 641 | + fits.set(1, table); | ||
| 642 | + fits.save(true); | ||
| 643 | + fits.close(); | ||
| 644 | + fits.open("test_container.fits"); | ||
| 645 | + test_value(fits.size(), 2); | ||
| 646 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 647 | + test_value(fits.at(i)->extno(), i); | ||
| 648 | + } | ||
| 649 | +std::cout << fits << std::endl; | ||
| 650 | + | ||
| 651 | + // Insert image in 2nd slot | ||
| 652 | + fits.insert(1, image); | ||
| 653 | + test_value(fits.size(), 3); | ||
| 654 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 655 | + test_value(fits.at(i)->extno(), i); | ||
| 656 | + } | ||
| 657 | +std::cout << fits << std::endl; | ||
| 658 | + | ||
| 659 | + // Remove image in 2nd slot | ||
| 660 | + fits.remove(1); | ||
| 661 | + test_value(fits.size(), 2); | ||
| 662 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 663 | + test_value(fits.at(i)->extno(), i); | ||
| 664 | + } | ||
| 665 | +std::cout << fits << std::endl; | ||
| 666 | + | ||
| 667 | + // Extent FITS file | ||
| 668 | + fits.extend(fits); | ||
| 669 | + test_value(fits.size(), 4); | ||
| 670 | + for (int i = 0; i < fits.size(); ++i) { | ||
| 671 | + test_value(fits.at(i)->extno(), i); | ||
| 672 | + } | ||
| 673 | +std::cout << fits << std::endl; | ||
| 674 | + | ||
| 675 | + // Signal success | ||
| 676 | + test_try_success(); | ||
| 677 | + } | ||
| 678 | + catch (std::exception &e) { | ||
| 679 | + test_try_failure(e); | ||
| 680 | + } | ||
| 681 | +*/ | ||
| 558 | // Return | 682 | // Return |
| 559 | return; | 683 | return; |
| 560 | } | 684 | } |
test/test_GFits.hpp
| 1 | /*************************************************************************** | 1 | /*************************************************************************** |
| 2 | - * test_GFits.hpp - test FITS class * | 2 | + * test_GFits.hpp - Test FITS class * |
| 3 | * ----------------------------------------------------------------------- * | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012 by Jean-Baptiste Cayrou * | 4 | + * copyright (C) 2012-2013 by Jean-Baptiste Cayrou * |
| 5 | * ----------------------------------------------------------------------- * | 5 | * ----------------------------------------------------------------------- * |
| 6 | * * | 6 | * * |
| 7 | * This program is free software: you can redistribute it and/or modify * | 7 | * This program is free software: you can redistribute it and/or modify * |
| @@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
| 21 | /** | 21 | /** |
| 22 | * @file test_GFits.hpp | 22 | * @file test_GFits.hpp |
| 23 | * @brief Definition of unit tests for FITS classes | 23 | * @brief Definition of unit tests for FITS classes |
| 24 | - * @author J. Knoedlseder | 24 | + * @author Jean-Baptiste Cayrou |
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #ifndef TEST_GFITS_HPP | 27 | #ifndef TEST_GFITS_HPP |