IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 11, 2004, 3:34:09 PM (22 years ago)
Author:
desonia
Message:

adjusted the psTime functions to conform to SDRS and made psGrommitAlloc
set all the inputs to slaAoppa function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astronomy/tst_psAstrometry.c

    r2006 r2048  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-07 19:51:30 $
     7 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-12 01:34:09 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1919static int testExposureAlloc(void);
    2020static int testObservatoryAlloc(void);
     21static int testFPAAlloc(void);
     22// static int testGrommitAlloc(void);
    2123
    2224testDescription tests[] = {
    2325                              {testExposureAlloc,735,"psExposureAlloc",0,false},
    2426                              {testObservatoryAlloc,736,"psObservatoryAlloc",0,false},
     27                              {testFPAAlloc,739,"psFPAAlloc",0,false},
    2528                              {NULL}
    2629                          };
     
    119122    char* name = "The Kaiser Royal Observatory";
    120123    psObservatory* obs = psObservatoryAlloc(name,
    121                                             20.7, 156.3, 3055.0, 9.0);
    122 
    123     if (fabs(obs->latitude - 20.7) > DBL_EPSILON) {
     124                                            20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 9.0);
     125
     126    if (fabs(obs->latitude - 20.7*M_PI/180.0) > DBL_EPSILON) {
    124127        psLogMsg(__func__,PS_LOG_ERROR,"psObservatoryAlloc did not set latitude.");
    125128        return 1;
    126129    }
    127130
    128     if (fabs(obs->longitude - 156.3) > DBL_EPSILON) {
     131    if (fabs(obs->longitude - 156.3*M_PI/180.0) > DBL_EPSILON) {
    129132        psLogMsg(__func__,PS_LOG_ERROR,"psObservatoryAlloc did not set longitude.");
    130133        return 2;
     
    152155
    153156    psObservatory* obs2 = psObservatoryAlloc(NULL,
    154                           20.7, 156.3, 3055.0, 9.0);
     157                          20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 9.0);
    155158
    156159    if (obs2->name != NULL) {
     
    164167    return 0;
    165168}
     169
     170static int testFPAAlloc(void)
     171{
     172
     173    psTime* now = psTimeGetTime(PS_TIME_UTC);
     174    char* name = "The Kaiser Royal Observatory";
     175
     176    psObservatory* obs = psObservatoryAlloc(name,
     177                                            20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 0.0065f);
     178
     179    psExposure* exp = psExposureAlloc(1.0, 2.0, 3.0, 4.0, 5.0,
     180                                      now, 6.0f, 260.0f, 1013.0f, 0.7f, 10.0f, 0.650f, obs);
     181
     182    /*
     183        1. Call psFPAAlloc with nChips > 0 and a non-NULL psExposure.
     184        a) Verify that the psExposure reference is: 1. is set in struct as
     185        exposure; 2. its reference count is incremented.
     186        b) Verify that the chip attribute is of the size specified by the
     187        parameter nChips and that the chips array elements are all NULL.
     188        c) verify that all other references in the struct is NULL.
     189    */
     190
     191    psFPA* fpa = psFPAAlloc(8, exp);
     192
     193    if (fpa == NULL) {
     194        psLogMsg(__func__,PS_LOG_ERROR,
     195                 "psFPAAlloc returned a NULL.");
     196        return 1;
     197    }
     198
     199    if (fpa->exposure != exp) {
     200        psLogMsg(__func__,PS_LOG_ERROR,
     201                 "psFPAAlloc did not set the exposure.");
     202        return 2;
     203    }
     204
     205    if (psMemGetRefCounter(exp) != 2) {
     206        psLogMsg(__func__,PS_LOG_ERROR,
     207                 "psFPAAlloc did not increment reference counter for exposure.");
     208        return 3;
     209    }
     210
     211    if (fpa->chips->n != 8) {
     212        psLogMsg(__func__,PS_LOG_ERROR,
     213                 "psFPAAlloc did not set the number of chips properly.");
     214        return 4;
     215    }
     216
     217    for (int lcv=0; lcv < 8; lcv++) {
     218        if (fpa->chips->data[lcv] != NULL) {
     219            psLogMsg(__func__,PS_LOG_ERROR,
     220                     "psFPAAlloc did not set chip %d to NULL.", lcv);
     221            return 5;
     222        }
     223    }
     224
     225    if (fpa->metadata != NULL) {
     226        psLogMsg(__func__,PS_LOG_ERROR,
     227                 "psFPAAlloc did not set metadata to NULL.");
     228        return 6;
     229    }
     230
     231    if (fpa->fromTangentPlane != NULL) {
     232        psLogMsg(__func__,PS_LOG_ERROR,
     233                 "psFPAAlloc did not set fromTangentPlane to NULL.");
     234        return 7;
     235    }
     236
     237    if (fpa->toTangentPlane != NULL) {
     238        psLogMsg(__func__,PS_LOG_ERROR,
     239                 "psFPAAlloc did not set toTangentPlane to NULL.");
     240        return 8;
     241    }
     242
     243    if (fpa->pattern != NULL) {
     244        psLogMsg(__func__,PS_LOG_ERROR,
     245                 "psFPAAlloc did not set pattern to NULL.");
     246        return 9;
     247    }
     248
     249    if (fpa->grommit == NULL) {
     250        psLogMsg(__func__,PS_LOG_ERROR,
     251                 "psFPAAlloc did not set grommit using given exposure.");
     252        return 10;
     253    }
     254
     255    if (fpa->colorPlus != NULL) {
     256        psLogMsg(__func__,PS_LOG_ERROR,
     257                 "psFPAAlloc did not set colorPlus to NULL.");
     258        return 11;
     259    }
     260
     261    if (fpa->colorMinus != NULL) {
     262        psLogMsg(__func__,PS_LOG_ERROR,
     263                 "psFPAAlloc did not set colorMinus to NULL.");
     264        return 12;
     265    }
     266
     267    if (fpa->projection != NULL) {
     268        psLogMsg(__func__,PS_LOG_ERROR,
     269                 "psFPAAlloc did not set projection to NULL.");
     270        return 13;
     271    }
     272
     273    /*
     274        2. Call psFPAAlloc with nChips = 0. Verify that the chips array is
     275           zero in size and the program execution does not stop.
     276    */
     277
     278    psFPA* fpa2 = psFPAAlloc(0,exp);
     279
     280    if (fpa2->chips->n != 0) {
     281        psLogMsg(__func__,PS_LOG_ERROR,
     282                 "psFPAAlloc did not set the number of chips properly.");
     283        return 14;
     284    }
     285
     286    /*
     287        3. Call psFPAAlloc with a NULL psExposure. Verify that the program
     288           execution doe not stop and the exposure attribute is NULL.
     289    */
     290
     291    psFPA* fpa3 = psFPAAlloc(4,NULL);
     292    if (fpa3->exposure != NULL) {
     293        psLogMsg(__func__,PS_LOG_ERROR,
     294                 "psFPAAlloc did not set the exposure to NULL given NULL parameter.");
     295        return 15;
     296    }
     297
     298    /*
     299        4. Call psFPAAlloc and set all references in the struct to a memory
     300           buffer. Verify that psFree cleans up all the buffers referenced in
     301           the struct, i.e., there is no memory leaks generated.
     302    */
     303
     304    for (int lcv=0; lcv < 8; lcv++) {
     305        fpa->chips->data[lcv] = psAlloc(4);
     306    }
     307
     308    fpa->metadata = psAlloc(4);
     309    fpa->fromTangentPlane = psAlloc(4);
     310    fpa->toTangentPlane = psAlloc(4);
     311    fpa->pattern = psAlloc(4);
     312    fpa->colorPlus  = psAlloc(4);
     313    fpa->colorMinus  = psAlloc(4);
     314    fpa->projection  = psAlloc(4);
     315
     316    psFree(fpa3);
     317    psFree(fpa2);
     318    psFree(fpa);
     319    psFree(exp);
     320    psFree(obs);
     321
     322    return 0;
     323}
Note: See TracChangeset for help on using the changeset viewer.