IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 12, 2004, 9:10:00 AM (22 years ago)
Author:
desonia
Message:

fixed psGrommitAlloc, SLALIB calls, added tests for psFPAAlloc and psChipAlloc.

File:
1 edited

Legend:

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

    r2048 r2052  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-12 01:34:09 $
     7 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-12 19:10:00 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020static int testObservatoryAlloc(void);
    2121static int testFPAAlloc(void);
    22 // static int testGrommitAlloc(void);
     22static int testChipAlloc(void);
    2323
    2424testDescription tests[] = {
     
    2626                              {testObservatoryAlloc,736,"psObservatoryAlloc",0,false},
    2727                              {testFPAAlloc,739,"psFPAAlloc",0,false},
     28                              {testChipAlloc,740,"psChipAlloc",0,false},
    2829                              {NULL}
    2930                          };
     
    319320    psFree(exp);
    320321    psFree(obs);
     322    psFree(now);
    321323
    322324    return 0;
    323325}
     326
     327static int testChipAlloc(void)
     328{
     329    char* name = "The Kaiser Royal Observatory";
     330
     331    psTime* now = psTimeGetTime(PS_TIME_UTC);
     332
     333    psObservatory* obs = psObservatoryAlloc(name,
     334                                            20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 0.0065f);
     335
     336    psExposure* exp = psExposureAlloc(1.0, 2.0, 3.0, 4.0, 5.0,
     337                                      now, 6.0f, 260.0f, 1013.0f, 0.7f, 10.0f, 0.650f, obs);
     338
     339    psFPA* fpa = psFPAAlloc(8, exp);
     340
     341    // N.B. psFPAAlloc made made a reference to any of these that it is
     342    // referencing, so these don't necessary are actually freed here.  Just
     343    // these references to the buffers are freed.
     344    psFree(exp);
     345    psFree(obs);
     346    psFree(now);
     347
     348    /*
     349        1. invoke psChipAlloc with nCells > 0 and parentFPA non-NULL. Verify
     350           that:
     351        a. the cells array is of the size nCells and all elements are NULL.
     352        b. parent attribute is set to parentFPA parameter and the ref. count
     353           was incremented.
     354        c. all other attributes are initialized to NULL or 0.
     355    */
     356
     357    psChip* chip = psChipAlloc(8, fpa);
     358
     359    if (chip == NULL) {
     360        psLogMsg(__func__,PS_LOG_ERROR,"psChipAlloc returned NULL.");
     361        return 1;
     362    }
     363
     364    if (chip->cells->n != 8) {
     365        psLogMsg(__func__,PS_LOG_ERROR,
     366                 "psChipAlloc did not set the number of cells properly.");
     367        return 2;
     368    }
     369
     370    for (int lcv=0; lcv < 8; lcv++) {
     371        if (chip->cells->data[lcv] != NULL) {
     372            psLogMsg(__func__,PS_LOG_ERROR,
     373                     "psChipAlloc did not set cell %d to NULL.", lcv);
     374            return 3;
     375        }
     376    }
     377
     378    if (chip->parent != fpa) {
     379        psLogMsg(__func__,PS_LOG_ERROR,
     380                 "psChipAlloc did not set the parent properly.");
     381        return 4;
     382    }
     383
     384    if (psMemGetRefCounter(fpa) != 2) {
     385        psLogMsg(__func__,PS_LOG_ERROR,
     386                 "psChipAlloc did not increment reference counter for parent FPA.");
     387        return 5;
     388    }
     389
     390    if (chip->metadata != NULL) {
     391        psLogMsg(__func__,PS_LOG_ERROR,
     392                 "psChipAlloc did not set metadata to NULL.");
     393        return 6;
     394    }
     395
     396    if (chip->toFPA != NULL) {
     397        psLogMsg(__func__,PS_LOG_ERROR,
     398                 "psChipAlloc did not set toFPA to NULL.");
     399        return 7;
     400    }
     401
     402    if (chip->fromFPA != NULL) {
     403        psLogMsg(__func__,PS_LOG_ERROR,
     404                 "psChipAlloc did not set fromFPA to NULL.");
     405        return 8;
     406    }
     407
     408    /*
     409        2. invoke psChipAlloc with nCells = 0. Verify that:
     410        a. execution does not halt
     411        b. the cells array is of the size of zero.   
     412    */
     413
     414    psChip* chip2 = psChipAlloc(0,fpa);
     415
     416    if (chip2 == NULL) {
     417        psLogMsg(__func__,PS_LOG_ERROR,"psChipAlloc returned NULL.");
     418        return 11;
     419    }
     420
     421    if (chip2->cells->n != 0) {
     422        psLogMsg(__func__,PS_LOG_ERROR,
     423                 "psChipAlloc did not set the number of cells properly.");
     424        return 12;
     425    }
     426
     427    if (chip2->parent != fpa) {
     428        psLogMsg(__func__,PS_LOG_ERROR,
     429                 "psChipAlloc did not set the parent properly.");
     430        return 14;
     431    }
     432
     433    if (psMemGetRefCounter(fpa) != 3) {
     434        psLogMsg(__func__,PS_LOG_ERROR,
     435                 "psChipAlloc did not increment reference counter for parent FPA.");
     436        return 15;
     437    }
     438
     439    /*
     440        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent
     441           attribute is NULL and no error is generated.
     442    */
     443
     444    psChip* chip3 = psChipAlloc(8,NULL);
     445
     446    if (chip3 == NULL) {
     447        psLogMsg(__func__,PS_LOG_ERROR,"psChipAlloc returned NULL.");
     448        return 21;
     449    }
     450
     451    if (chip3->cells->n != 8) {
     452        psLogMsg(__func__,PS_LOG_ERROR,
     453                 "psChipAlloc did not set the number of cells properly.");
     454        return 22;
     455    }
     456
     457    if (chip3->parent != NULL) {
     458        psLogMsg(__func__,PS_LOG_ERROR,
     459                 "psChipAlloc did not set the parent to NULL.");
     460        return 24;
     461    }
     462
     463    psFree(chip);
     464    psFree(chip2);
     465    psFree(chip3);
     466    psFree(fpa);
     467
     468    return 0;
     469}
Note: See TracChangeset for help on using the changeset viewer.