IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2967


Ignore:
Timestamp:
Jan 12, 2005, 4:08:30 PM (22 years ago)
Author:
desonia
Message:

added test for psFitsGetExtNum/psFitsGetExtName.

Location:
trunk/psLib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataIO/psFits.c

    r2965 r2967  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-01-13 01:54:25 $
     9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-01-13 02:08:30 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    313313int psFitsGetExtNum(psFits* fits)
    314314{
     315    int hdunum;
     316
    315317    if (fits == NULL) {
    316318        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     
    319321    }
    320322
    321     int hdutype = ANY_HDU;
    322     int status = 0;
    323 
    324     if (fits_get_hdu_type(fits->p_fd, &hdutype, &status) != 0) {
    325         char fitsErr[MAX_STRING_LENGTH];
    326         fits_get_errstatus(status, fitsErr);
    327         psError(PS_ERR_LOCATION_INVALID, true,
    328                 PS_ERRORTEXT_psFits_GET_EXTNUM_FAILED,
    329                 fits->filename, fitsErr);
    330         return -1;
    331     }
    332 
    333     return hdutype;
     323
     324    return fits_get_hdu_num(fits->p_fd,&hdunum) - 1;
    334325}
    335326
  • trunk/psLib/src/fileUtils/psFits.c

    r2965 r2967  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-01-13 01:54:25 $
     9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-01-13 02:08:30 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    313313int psFitsGetExtNum(psFits* fits)
    314314{
     315    int hdunum;
     316
    315317    if (fits == NULL) {
    316318        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     
    319321    }
    320322
    321     int hdutype = ANY_HDU;
    322     int status = 0;
    323 
    324     if (fits_get_hdu_type(fits->p_fd, &hdutype, &status) != 0) {
    325         char fitsErr[MAX_STRING_LENGTH];
    326         fits_get_errstatus(status, fitsErr);
    327         psError(PS_ERR_LOCATION_INVALID, true,
    328                 PS_ERRORTEXT_psFits_GET_EXTNUM_FAILED,
    329                 fits->filename, fitsErr);
    330         return -1;
    331     }
    332 
    333     return hdutype;
     323
     324    return fits_get_hdu_num(fits->p_fd,&hdunum) - 1;
    334325}
    335326
  • trunk/psLib/src/fits/psFits.c

    r2965 r2967  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-01-13 01:54:25 $
     9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-01-13 02:08:30 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    313313int psFitsGetExtNum(psFits* fits)
    314314{
     315    int hdunum;
     316
    315317    if (fits == NULL) {
    316318        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     
    319321    }
    320322
    321     int hdutype = ANY_HDU;
    322     int status = 0;
    323 
    324     if (fits_get_hdu_type(fits->p_fd, &hdutype, &status) != 0) {
    325         char fitsErr[MAX_STRING_LENGTH];
    326         fits_get_errstatus(status, fitsErr);
    327         psError(PS_ERR_LOCATION_INVALID, true,
    328                 PS_ERRORTEXT_psFits_GET_EXTNUM_FAILED,
    329                 fits->filename, fitsErr);
    330         return -1;
    331     }
    332 
    333     return hdutype;
     323
     324    return fits_get_hdu_num(fits->p_fd,&hdunum) - 1;
    334325}
    335326
  • trunk/psLib/test/dataIO/tst_psFits.c

    r2965 r2967  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-01-13 01:54:26 $
     8*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-01-13 02:08:30 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1616
    1717#include <unistd.h>
     18#include <string.h>
    1819
    1920static bool makeMulti(void);
     
    2122
    2223static psS32 tst_psFitsAlloc( void );
    23 static psS32 tst_psFitsMoveExtName( void );
    24 static psS32 tst_psFitsMoveExtNum( void );
     24static psS32 tst_psFitsMoveExtName( void ); // also tests psFitsGetExtName
     25static psS32 tst_psFitsMoveExtNum( void );  // also tests psFitsGetExtNum
    2526
    2627testDescription tests[] = {
     
    125126        }
    126127
     128        // check to see if I can retrieve the name back from the psFits object.
     129        char* nameFromFile = psFitsGetExtName(fits);
     130        if (strcmp(nameFromFile,extName) != 0) { // hey, it didn't move?
     131            psError(PS_ERR_UNKNOWN, false,
     132                    "Failed to retrieve the extension name back ('%s' vs '%s'",
     133                    nameFromFile, extName);
     134            return 3;
     135        }
     136        psFree(nameFromFile);
     137
    127138        // check that the image is associated to the extension moved, i.e.,
    128139        // did we really move to the proper extension?
     
    148159        }
    149160
     161        // check to see if I can retrieve the name back from the psFits object.
     162        char* nameFromFile = psFitsGetExtName(fits);
     163        if (strcmp(nameFromFile,extName) != 0) { // hey, it didn't move?
     164            psError(PS_ERR_UNKNOWN, false,
     165                    "Failed to retrieve the extension name back ('%s' vs '%s'",
     166                    nameFromFile, extName);
     167            return 5;
     168        }
     169        psFree(nameFromFile);
     170
    150171        // check that the image is associated to the extension moved, i.e.,
    151172        // did we really move to the proper extension?
     
    217238                    lcv);
    218239            return 3;
     240        }
     241
     242        // check to see if I can retrieve the number back from the psFits object.
     243        if (psFitsGetExtNum(fits) != lcv) { // hey, it didn't move?
     244            psError(PS_ERR_UNKNOWN, false,
     245                    "Failed to retrieve the extension number back (%d vs %d)",
     246                    psFitsGetExtNum(fits), lcv);
     247            return 5;
    219248        }
    220249
     
    265294        }
    266295
     296        // check to see if I can retrieve the number back from the psFits object.
     297        if (psFitsGetExtNum(fits) != lcv) { // hey, it didn't move?
     298            psError(PS_ERR_UNKNOWN, false,
     299                    "Failed to retrieve the extension number back (%d vs %d)",
     300                    psFitsGetExtNum(fits), lcv);
     301            return 13;
     302        }
     303
    267304        // check that the image is associated to the extension moved, i.e.,
    268305        // did we really move to the proper extension?
     
    284321                    "Failed to move to extension %d.",
    285322                    lcv);
     323            return 15;
     324        }
     325
     326        // check to see if I can retrieve the number back from the psFits object.
     327        if (psFitsGetExtNum(fits) != lcv) { // hey, it didn't move?
     328            psError(PS_ERR_UNKNOWN, false,
     329                    "Failed to retrieve the extension number back (%d vs %d)",
     330                    psFitsGetExtNum(fits), lcv);
    286331            return 15;
    287332        }
  • trunk/psLib/test/fileUtils/tst_psFits.c

    r2965 r2967  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-01-13 01:54:26 $
     8*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-01-13 02:08:30 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1616
    1717#include <unistd.h>
     18#include <string.h>
    1819
    1920static bool makeMulti(void);
     
    2122
    2223static psS32 tst_psFitsAlloc( void );
    23 static psS32 tst_psFitsMoveExtName( void );
    24 static psS32 tst_psFitsMoveExtNum( void );
     24static psS32 tst_psFitsMoveExtName( void ); // also tests psFitsGetExtName
     25static psS32 tst_psFitsMoveExtNum( void );  // also tests psFitsGetExtNum
    2526
    2627testDescription tests[] = {
     
    125126        }
    126127
     128        // check to see if I can retrieve the name back from the psFits object.
     129        char* nameFromFile = psFitsGetExtName(fits);
     130        if (strcmp(nameFromFile,extName) != 0) { // hey, it didn't move?
     131            psError(PS_ERR_UNKNOWN, false,
     132                    "Failed to retrieve the extension name back ('%s' vs '%s'",
     133                    nameFromFile, extName);
     134            return 3;
     135        }
     136        psFree(nameFromFile);
     137
    127138        // check that the image is associated to the extension moved, i.e.,
    128139        // did we really move to the proper extension?
     
    148159        }
    149160
     161        // check to see if I can retrieve the name back from the psFits object.
     162        char* nameFromFile = psFitsGetExtName(fits);
     163        if (strcmp(nameFromFile,extName) != 0) { // hey, it didn't move?
     164            psError(PS_ERR_UNKNOWN, false,
     165                    "Failed to retrieve the extension name back ('%s' vs '%s'",
     166                    nameFromFile, extName);
     167            return 5;
     168        }
     169        psFree(nameFromFile);
     170
    150171        // check that the image is associated to the extension moved, i.e.,
    151172        // did we really move to the proper extension?
     
    217238                    lcv);
    218239            return 3;
     240        }
     241
     242        // check to see if I can retrieve the number back from the psFits object.
     243        if (psFitsGetExtNum(fits) != lcv) { // hey, it didn't move?
     244            psError(PS_ERR_UNKNOWN, false,
     245                    "Failed to retrieve the extension number back (%d vs %d)",
     246                    psFitsGetExtNum(fits), lcv);
     247            return 5;
    219248        }
    220249
     
    265294        }
    266295
     296        // check to see if I can retrieve the number back from the psFits object.
     297        if (psFitsGetExtNum(fits) != lcv) { // hey, it didn't move?
     298            psError(PS_ERR_UNKNOWN, false,
     299                    "Failed to retrieve the extension number back (%d vs %d)",
     300                    psFitsGetExtNum(fits), lcv);
     301            return 13;
     302        }
     303
    267304        // check that the image is associated to the extension moved, i.e.,
    268305        // did we really move to the proper extension?
     
    284321                    "Failed to move to extension %d.",
    285322                    lcv);
     323            return 15;
     324        }
     325
     326        // check to see if I can retrieve the number back from the psFits object.
     327        if (psFitsGetExtNum(fits) != lcv) { // hey, it didn't move?
     328            psError(PS_ERR_UNKNOWN, false,
     329                    "Failed to retrieve the extension number back (%d vs %d)",
     330                    psFitsGetExtNum(fits), lcv);
    286331            return 15;
    287332        }
Note: See TracChangeset for help on using the changeset viewer.