IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2056


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

added test for psReadoutAlloc.

File:
1 edited

Legend:

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

    r2054 r2056  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-12 19:28:40 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-12 19:51:53 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222static int testChipAlloc(void);
    2323static int testCellAlloc(void);
     24static int testReadoutAlloc(void);
    2425
    2526testDescription tests[] = {
     
    2930                              {testChipAlloc,740,"psChipAlloc",0,false},
    3031                              {testCellAlloc,741,"psCellAlloc",0,false},
     32                              {testReadoutAlloc,742,"psReadoutAlloc",0,false},
    3133                              {NULL}
    3234                          };
     
    376378            return 3;
    377379        }
     380        chip->cells->data[lcv] = psAlloc(4); // to check if these are freed.
    378381    }
    379382
     
    395398        return 6;
    396399    }
     400    chip->metadata = psAlloc(4); // to check if these are freed.
    397401
    398402    if (chip->toFPA != NULL) {
     
    401405        return 7;
    402406    }
     407    chip->toFPA = psAlloc(4); // to check if these are freed.
    403408
    404409    if (chip->fromFPA != NULL) {
     
    407412        return 8;
    408413    }
     414    chip->fromFPA = psAlloc(4); // to check if these are freed.
    409415
    410416    /*
     
    522528            return 3;
    523529        }
     530        cell1->readouts->data[lcv] = psAlloc(4); // to check if these are freed.
    524531    }
    525532
     
    541548        return 6;
    542549    }
     550    cell1->metadata = psAlloc(4); // to check if these are freed.
    543551
    544552    if (cell1->toChip != NULL) {
     
    547555        return 7;
    548556    }
     557    cell1->toChip = psAlloc(4); // to check if these are freed.
    549558
    550559    if (cell1->fromChip != NULL) {
     
    553562        return 8;
    554563    }
     564    cell1->fromChip = psAlloc(4); // to check if these are freed.
    555565
    556566    if (cell1->toFPA != NULL) {
     
    559569        return 9;
    560570    }
     571    cell1->toFPA = psAlloc(4); // to check if these are freed.
    561572
    562573    if (cell1->toTP != NULL) {
     
    565576        return 10;
    566577    }
     578    cell1->toTP = psAlloc(4); // to check if these are freed.
    567579
    568580    /*
     
    628640    return 0;
    629641}
     642
     643static int testReadoutAlloc(void)
     644{
     645    psImage* image = psImageAlloc(64,64,PS_TYPE_S8);
     646
     647
     648    /*
     649        1. invoke psReadoutAlloc with unique/non-zero x0,y0 and non-NULL image. Verify that:
     650        a. col0 & row0 are set to the parameters x0 and y0, respectively.
     651        b. image attribute is set to image parameter and referenece is incremented
     652        c. mask, objects, and metadata attributes are all NULL
     653    */
     654    psReadout* readout = psReadoutAlloc(1,2,image);
     655
     656    if (readout == NULL) {
     657        psLogMsg(__func__,PS_LOG_ERROR,"psReadoutAlloc returned NULL.");
     658        return 1;
     659    }
     660
     661    if (readout->col0 != 1) {
     662        psLogMsg(__func__,PS_LOG_ERROR,
     663                 "psReadoutAlloc did not set col0 properly.");
     664        return 2;
     665    }
     666
     667    if (readout->row0 != 2) {
     668        psLogMsg(__func__,PS_LOG_ERROR,
     669                 "psReadoutAlloc did not set row0 properly.");
     670        return 3;
     671    }
     672
     673    if (readout->image != image) {
     674        psLogMsg(__func__,PS_LOG_ERROR,
     675                 "psReadoutAlloc did not set the image properly.");
     676        return 4;
     677    }
     678
     679    if (psMemGetRefCounter(image) != 2) {
     680        psLogMsg(__func__,PS_LOG_ERROR,
     681                 "psReadoutAlloc did not increment reference counter for image.");
     682        return 5;
     683    }
     684
     685    if (readout->metadata != NULL) {
     686        psLogMsg(__func__,PS_LOG_ERROR,
     687                 "psReadoutAlloc did not set metadata to NULL.");
     688        return 6;
     689    }
     690    readout->metadata = psAlloc(4); // to check if these are freed.
     691
     692    if (readout->mask != NULL) {
     693        psLogMsg(__func__,PS_LOG_ERROR,
     694                 "psReadoutAlloc did not set mask to NULL.");
     695        return 7;
     696    }
     697    readout->mask = psAlloc(4); // to check if these are freed.
     698
     699    if (readout->objects != NULL) {
     700        psLogMsg(__func__,PS_LOG_ERROR,
     701                 "psReadoutAlloc did not set objects to NULL.");
     702        return 8;
     703    }
     704    readout->objects = psAlloc(4); // to check if these are freed.
     705
     706    /*
     707        2. invoke psReadoutAlloc with NULL image. Verify that:
     708        a. execution does not halt
     709        b. the image attribute is NULL.
     710    */
     711
     712    psReadout* readout2 = psReadoutAlloc(3,4,NULL);
     713
     714    if (readout2 == NULL) {
     715        psLogMsg(__func__,PS_LOG_ERROR,"psReadoutAlloc returned NULL.");
     716        return 11;
     717    }
     718
     719    if (readout2->image != NULL) {
     720        psLogMsg(__func__,PS_LOG_ERROR,"psReadoutAlloc didn't set image to NULL, as given.");
     721        return 12;
     722    }
     723
     724    psFree(readout);
     725    psFree(readout2);
     726    psFree(image);
     727
     728    return 0;
     729}
Note: See TracChangeset for help on using the changeset viewer.