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.

Location:
trunk/psLib/test/astronomy
Files:
3 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}
  • trunk/psLib/test/astronomy/tst_psTime_01.c

    r2030 r2048  
    2323 *  @author  Ross Harman, MHPCC
    2424 *
    25  *  @version $Revision: 1.11 $  $Name: not supported by cvs2svn $
    26  *  @date  $Date: 2004-10-08 23:30:47 $
     25 *  @version $Revision: 1.12 $  $Name: not supported by cvs2svn $
     26 *  @date  $Date: 2004-10-12 01:34:09 $
    2727 *
    2828 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6262    printPositiveTestHeader(stdout,"psTime", "Convert psTime to ISO time");
    6363    char *isoString;
    64     isoString = psTimeToISO(testTime);
     64    isoString = psTimeToISOTime(testTime);
    6565    printf("%s\n", isoString);
    6666    if(strncmp(isoString, testString, 256)) {
     
    7474    printPositiveTestHeader(stdout,"psTime", "Convert ISO time to psTime");
    7575    psTime *timeD = NULL;
    76     timeD = psISOToTime(isoString);
     76    timeD = psTimeFromISOTime(isoString);
    7777    printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeD->sec, (psU32)timeD->usec);
    7878    psFree(isoString);
     
    118118    printPositiveTestHeader(stdout,"psTime", "Convert MJD time to psTime");
    119119    psTime *timeH = NULL;
    120     timeH = psMJDToTime(mjdTime);
     120    timeH = psTimeFromMJD(mjdTime);
    121121    printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeH->sec, (psU32)timeH->usec);
    122122    psFree(timeH);
     
    135135    printPositiveTestHeader(stdout,"psTime", "Convert JD time to psTime");
    136136    psTime *timeJ = NULL;
    137     timeJ = psJDToTime(jdTime);
     137    timeJ = psTimeFromJD(jdTime);
    138138    printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeJ->sec, (psU32)timeJ->usec);
    139139    psFree(timeJ);
     
    152152    printPositiveTestHeader(stdout,"psTime", "Convert timeval time to psTime");
    153153    psTime *timeL = NULL;
    154     timeL = psTimevalToTime(&timevalTime);
     154    timeL = psTimeFromTimeval(&timevalTime);
    155155    printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeL->sec, (psU32)timeL->usec);
    156156    psFree(timeL);
     
    175175    printPositiveTestHeader(stdout, "psTime", "Convert tm time to psTime");
    176176    psTime *timeN = NULL;
    177     timeN = psTMToTime(tmTime);
     177    timeN = psTimeFromTM(tmTime);
    178178    printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeN->sec, (psU32)timeN->usec);
    179179    psFree(timeN);
     
    186186    char *testString2 = "2004-09-10T1:00:00.00Z";
    187187    psTime* testTime2 = NULL;
    188     testTime2 = psISOToTime(testString2);
     188    testTime2 = psTimeFromISOTime(testString2);
    189189    double dblTime = psTimeToLST(testTime2, 1);
    190190    printf("LST (rad): %lf\n", dblTime);
  • trunk/psLib/test/astronomy/tst_psTime_02.c

    r2024 r2048  
    99 *  @author  Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
    12  *  @date  $Date: 2004-10-08 22:58:47 $
     11 *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
     12 *  @date  $Date: 2004-10-12 01:34:09 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2424    // Test A - Incorrect ISO time data
    2525    printNegativeTestHeader(stdout,"psTime", "Incorrect ISO time data", "Time not allowed", 0);
    26     psISOToTime("2004-99-21T18:22:24.272Z");
    27     psISOToTime("2004-07-99T18:22:24.272Z");
    28     psISOToTime("2004-07-21T99:22:24.272Z");
    29     psISOToTime("2004-07-21T18:99:24.272Z");
    30     psISOToTime("2004-07-21T18:22:99.272Z");
    31     psISOToTime("2004-07-21T18:22:24.-999Z");
     26    psTimeFromISOTime("2004-99-21T18:22:24.272Z");
     27    psTimeFromISOTime("2004-07-99T18:22:24.272Z");
     28    psTimeFromISOTime("2004-07-21T99:22:24.272Z");
     29    psTimeFromISOTime("2004-07-21T18:99:24.272Z");
     30    psTimeFromISOTime("2004-07-21T18:22:99.272Z");
     31    psTimeFromISOTime("2004-07-21T18:22:24.-999Z");
    3232    printFooter(stdout, "psTime", "Incorrect ISO time data", true);
    3333
     
    3636    printNegativeTestHeader(stdout,"psTime", "Attempt to use null timeval",
    3737                            "Null value for timeval arg not allowed", 0);
    38     psTimevalToTime(NULL);
     38    psTimeFromTimeval(NULL);
    3939    printFooter(stdout, "psTime", "Attempt to use null timeval", true);
    4040
Note: See TracChangeset for help on using the changeset viewer.