IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 20, 2005, 1:06:24 PM (21 years ago)
Author:
gusciora
Message:

....

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/astrom/tst_pmAstrometry.c

    r5169 r5435  
    11/** @file  tst_pmAstrometry.c
    22 *
    3  *  @brief Contains the tests for pmAstrometry.[ch].  Only the pmxxxAlloc()
     3 *  @brief Contains the tests: pmAstrometry.[ch].  Only the pmxxxAlloc()
    44 *  and psFree() functionality are used here.
    55 *
    66 *  @author George Gusciora, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-09-28 20:42:51 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-10-20 23:06:24 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3232                          };
    3333
     34#define CHIP_ALLOC_NAME "ChipName"
     35#define CELL_ALLOC_NAME "CellName"
     36
    3437psS32 main(psS32 argc, char* argv[])
    3538{
     
    4447    // XXX: Do something more with these arguments.
    4548    const psMetadata *camera = psMetadataAlloc();
    46     psDB *db = NULL;
    47     pmFPA* fpa = pmFPAAlloc(camera, db);
     49    pmFPA* fpa = pmFPAAlloc(camera);
    4850
    4951    if (fpa == NULL) {
    50         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");
     52        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.");
    5153        return 1;
    5254    }
    5355
    5456    if (fpa->fromTangentPlane != NULL) {
    55         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->fromTangentPlane to NULL.");
     57        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->fromTangentPlane to NULL.");
    5658        return 2;
    5759    }
    5860
    5961    if (fpa->toTangentPlane != NULL) {
    60         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->toTangentPlane to NULL.");
     62        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->toTangentPlane to NULL.");
    6163        return 3;
    6264    }
    6365    if (fpa->projection != NULL) {
    64         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->projection to NULL.");
     66        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->projection to NULL.");
    6567        return 4;
    6668    }
    6769
    6870    if (fpa->concepts == NULL) {
    69         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->concepts.");
     71        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->concepts.");
    7072        return 5;
    7173    }
    7274
    73     if (fpa->analysis == NULL) {
    74         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->analysis.");
     75    if (fpa->analysis != NULL) {
     76        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->analysis to NULL.");
    7577        return 6;
    7678    }
    7779
    7880    if (fpa->camera != camera) {
    79         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->camera.");
     81        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->camera.");
    8082        return 7;
    8183    }
    8284
    8385    if (fpa->chips == NULL) {
    84         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->chips.");
     86        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->chips.");
    8587        return 8;
    8688    }
    8789
    88     if (fpa->header != NULL) {
    89         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->header to NULL.");
     90    if (fpa->private != NULL) {
     91        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->private to NULL.");
    9092        return 9;
    9193    }
    9294
    93     if (fpa->db != db) {
    94         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->db.");
     95    psFree(fpa);
     96    psFree(camera);
     97
     98    return 0;
     99}
     100
     101static psS32 testChipAlloc(void)
     102{
     103    const psMetadata *camera = psMetadataAlloc();
     104    pmFPA* fpa = pmFPAAlloc(camera);
     105    if (fpa == NULL) {
     106        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.");
     107        return 1;
     108    }
     109
     110    pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME);
     111    if (chip == NULL) {
     112        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.");
     113        return 1;
     114    }
     115
     116    if (chip->col0 != -1) {
     117        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->col0 set improperly.\n");
     118        return 5;
     119    }
     120
     121    if (chip->row0 != -1) {
     122        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->row0 set improperly.\n");
     123        return 6;
     124    }
     125
     126    if (chip->toFPA != NULL) {
     127        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->toChip set improperly.\n");
     128        return 7;
     129    }
     130
     131    if (chip->fromFPA != NULL) {
     132        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->toFPA set improperly.\n");
     133        return 8;
     134    }
     135
     136    if (chip->concepts == NULL) {
     137        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->concepts set improperly.\n");
     138        return 21;
     139    } else {
     140        psMetadataItem *tmpMeta = psMetadataLookup(chip->concepts, "CHIP.NAME");
     141        if (0 != strcmp((char *) tmpMeta->data.V, CHIP_ALLOC_NAME)) {
     142            psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: The metadata was set improperly.\n");
     143            return (32);
     144        }
     145        // XXX: Code a test to ensure the metadata has the correct type
     146    }
     147
     148    if (chip->analysis != NULL) {
     149        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->analysis set improperly.\n");
    95150        return 10;
    96151    }
    97152
    98     psFree(camera);
    99     psFree(fpa);
    100 
    101     return 0;
    102 }
    103 
    104 static psS32 testChipAlloc(void)
    105 {
    106     const psMetadata *camera = psMetadataAlloc();
    107     psDB *db = NULL;
    108     pmFPA* fpa = pmFPAAlloc(camera, db);
    109     if (fpa == NULL) {
    110         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");
    111         return 1;
    112     }
    113 
    114     pmChip *chip = pmChipAlloc(fpa);
    115     if (chip == NULL) {
    116         psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.");
    117         return 1;
    118     }
    119 
    120     if (chip->col0 != -1) {
    121         psLogMsg(__func__, PS_LOG_ERROR, "chip->col0 set improperly.\n");
    122         return 5;
    123     }
    124 
    125     if (chip->row0 != -1) {
    126         psLogMsg(__func__, PS_LOG_ERROR, "chip->row0 set improperly.\n");
    127         return 6;
    128     }
    129 
    130     if (chip->toFPA != NULL) {
    131         psLogMsg(__func__, PS_LOG_ERROR, "chip->toChip set improperly.\n");
    132         return 7;
    133     }
    134 
    135     if (chip->fromFPA != NULL) {
    136         psLogMsg(__func__, PS_LOG_ERROR, "chip->toFPA set improperly.\n");
    137         return 8;
    138     }
    139 
    140     if (chip->concepts == NULL) {
    141         psLogMsg(__func__, PS_LOG_ERROR, "chip->concepts set improperly.\n");
    142         return 21;
    143     }
    144 
    145     if (chip->analysis == NULL) {
    146         psLogMsg(__func__, PS_LOG_ERROR, "chip->analysis set improperly.\n");
    147         return 10;
    148     }
    149 
    150153    if (chip->cells == NULL) {
    151         psLogMsg(__func__, PS_LOG_ERROR, "chip->cells set improperly.\n");
     154        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->cells set improperly.\n");
    152155        return 22;
    153156    }
    154157
    155158    if (chip->parent != fpa) {
    156         psLogMsg(__func__, PS_LOG_ERROR, "chip->parent set improperly.\n");
     159        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->parent set improperly.\n");
    157160        return 23;
    158161    }
    159162
    160163    if (chip->valid != false) {
    161         psLogMsg(__func__, PS_LOG_ERROR, "chip->valid set improperly.\n");
     164        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->valid set improperly.\n");
    162165        return 24;
    163166    }
    164167
    165     if (chip->extname != NULL) {
    166         psLogMsg(__func__, PS_LOG_ERROR, "chip->extname set improperly.\n");
     168    if (chip->private != NULL) {
     169        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->private set improperly.\n");
    167170        return 25;
    168     }
    169 
    170     if (chip->pixels != NULL) {
    171         psLogMsg(__func__, PS_LOG_ERROR, "chip->pixels set improperly.\n");
    172         return 26;
    173     }
    174 
    175     if (chip->header != NULL) {
    176         psLogMsg(__func__, PS_LOG_ERROR, "chip->header set improperly.\n");
    177         return 27;
    178171    }
    179172
     
    187180static psS32 testCellAlloc(void)
    188181{
    189     psDB *db = NULL;
    190182    const psMetadata *camera = psMetadataAlloc();
    191     pmFPA* fpa = pmFPAAlloc(camera, db);
     183    pmFPA* fpa = pmFPAAlloc(camera);
    192184    if (fpa == NULL) {
    193         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.n");
    194         return 1;
    195     }
    196 
    197     pmChip *chip = pmChipAlloc(fpa);
     185        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.n");
     186        return 1;
     187    }
     188
     189    pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME);
    198190    if (chip == NULL) {
    199         psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.n");
     191        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.n");
    200192        return 2;
    201193    }
    202194
    203     pmCell *cell = pmCellAlloc(chip);
     195    pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, CELL_ALLOC_NAME);
    204196    if (cell == NULL) {
    205         psLogMsg(__func__,PS_LOG_ERROR, "pmCellAlloc returned a NULL.n");
     197        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmCellAlloc returned a NULL.n");
    206198        return 3;
    207199    }
    208200
    209201    if (cell->col0 != -1) {
    210         psLogMsg(__func__, PS_LOG_ERROR, "cell->col0 set improperly.\n");
     202        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->col0 set improperly.\n");
    211203        return 5;
    212204    }
    213205
    214206    if (cell->row0 != -1) {
    215         psLogMsg(__func__, PS_LOG_ERROR, "cell->row0 set improperly.\n");
     207        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->row0 set improperly.\n");
    216208        return 6;
    217209    }
    218210
    219211    if (cell->toChip != NULL) {
    220         psLogMsg(__func__, PS_LOG_ERROR, "cell->toChip set improperly.\n");
     212        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toChip set improperly.\n");
    221213        return 7;
    222214    }
    223215
    224216    if (cell->toFPA != NULL) {
    225         psLogMsg(__func__, PS_LOG_ERROR, "cell->toFPA set improperly.\n");
     217        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toFPA set improperly.\n");
    226218        return 8;
    227219    }
    228220
    229221    if (cell->toSky != NULL) {
    230         psLogMsg(__func__, PS_LOG_ERROR, "cell->toSky set improperly.\n");
     222        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toSky set improperly.\n");
    231223        return 9;
    232224    }
    233225
    234     if (cell->analysis == NULL) {
    235         psLogMsg(__func__, PS_LOG_ERROR, "cell->analysis set improperly.\n");
     226    if (cell->concepts == NULL) {
     227        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->concepts set improperly.\n");
     228        return 21;
     229    } else {
     230        psMetadataItem *tmpMeta = psMetadataLookup(cell->concepts, "CELL.NAME");
     231        if (0 != strcmp((char *) tmpMeta->data.V, CELL_ALLOC_NAME)) {
     232            psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: The metadata was set improperly.\n");
     233            return (32);
     234        }
     235        // XXX: Code a test to ensure the metadata has the correct type
     236    }
     237
     238    if (cell->camera != camera) {
     239        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->camera set improperly.\n");
     240        return 20;
     241    }
     242
     243    if (cell->analysis != NULL) {
     244        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->analysis set improperly.\n");
    236245        return 10;
    237246    }
    238247
    239     if (cell->concepts == NULL) {
    240         psLogMsg(__func__, PS_LOG_ERROR, "cell->concepts set improperly.\n");
    241         return 21;
    242     }
    243 
    244248    if (cell->readouts == NULL) {
    245         psLogMsg(__func__, PS_LOG_ERROR, "cell->readouts set improperly.\n");
     249        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->readouts set improperly.\n");
    246250        return 22;
    247251    }
    248252
    249253    if (cell->parent != chip) {
    250         psLogMsg(__func__, PS_LOG_ERROR, "cell->parent set improperly.\n");
     254        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->parent set improperly.\n");
    251255        return 23;
    252256    }
    253257
    254258    if (cell->valid != false) {
    255         psLogMsg(__func__, PS_LOG_ERROR, "cell->valid set improperly.\n");
     259        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->valid set improperly.\n");
    256260        return 24;
    257261    }
    258262
    259     if (cell->extname != NULL) {
    260         psLogMsg(__func__, PS_LOG_ERROR, "cell->extname set improperly.\n");
    261         return 25;
    262     }
    263 
    264     if (cell->pixels != NULL) {
    265         psLogMsg(__func__, PS_LOG_ERROR, "cell->pixels set improperly.\n");
    266         return 26;
    267     }
    268 
    269     if (cell->header != NULL) {
    270         psLogMsg(__func__, PS_LOG_ERROR, "cell->header set improperly.\n");
     263    if (cell->private != NULL) {
     264        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->private set improperly.\n");
    271265        return 27;
    272266    }
     
    282276static psS32 testReadoutAlloc(void)
    283277{
    284     psDB *db = NULL;
    285278    const psMetadata *camera = psMetadataAlloc();
    286     pmFPA* fpa = pmFPAAlloc(camera, db);
     279    pmFPA* fpa = pmFPAAlloc(camera);
    287280
    288281    if (fpa == NULL) {
    289         psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.\n");
    290         return 1;
    291     }
    292 
    293     pmChip *chip = pmChipAlloc(fpa);
     282        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.\n");
     283        return 1;
     284    }
     285
     286    pmChip *chip = pmChipAlloc(fpa, "ChipName");
    294287    if (chip == NULL) {
    295         psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.\n");
     288        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.\n");
    296289        return 2;
    297290    }
    298291
    299     pmCell *cell = pmCellAlloc(chip);
     292    pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, "CellName");
    300293    if (cell == NULL) {
    301         psLogMsg(__func__,PS_LOG_ERROR, "pmCellAlloc returned a NULL.\n");
     294        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmCellAlloc returned a NULL.\n");
    302295        return 3;
    303296    }
     
    305298    pmReadout *readout = pmReadoutAlloc(cell);
    306299    if (readout == NULL) {
    307         psLogMsg(__func__,PS_LOG_ERROR, "pmReadoutAlloc returned a NULL.\n");
     300        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmReadoutAlloc returned a NULL.\n");
    308301        return 4;
    309302    }
    310303
    311304    if (readout->col0 != -1) {
    312         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->col0 set improperly.\n");
     305        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->col0 set improperly.\n");
    313306        return 5;
    314307    }
    315308
    316309    if (readout->row0 != -1) {
    317         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->row0 set improperly.\n");
     310        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->row0 set improperly.\n");
    318311        return 6;
    319312    }
    320313
    321314    if (readout->colBins != -1) {
    322         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->colBins set improperly.\n");
     315        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->colBins set improperly.\n");
    323316        return 7;
    324317    }
    325318
    326319    if (readout->rowBins != -1) {
    327         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->colBins set improperly.\n");
     320        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->colBins set improperly.\n");
    328321        return 8;
    329322    }
    330323
    331324    if (readout->image != NULL) {
    332         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->image set improperly.\n");
    333         return 9;
     325        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->image set improperly.\n");
     326        return 10;
    334327    }
    335328
    336329    if (readout->mask != NULL) {
    337         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->mask set improperly.\n");
    338         return 10;
     330        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->mask set improperly.\n");
     331        return 12;
     332    }
     333
     334    if (readout->weight != NULL) {
     335        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->weight set improperly.\n");
     336        return 14;
     337    }
     338
     339    if (readout->bias != NULL) {
     340        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->bias set improperly.\n");
     341        return 16;
    339342    }
    340343
    341344    if (readout->analysis == NULL) {
    342         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->analysis set improperly.\n");
    343         return 11;
    344     }
    345 
    346     if (readout->concepts == NULL) {
    347         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->concepts set improperly.\n");
    348         return 12;
     345        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->analysis set improperly.\n");
     346        return 18;
    349347    }
    350348
    351349    if (readout->parent != cell) {
    352         psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->parent set improperly.\n");
    353         return 15;
     350        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->parent set improperly.\n");
     351        return 20;
    354352    }
    355353
     
    362360    return 0;
    363361}
     362
Note: See TracChangeset for help on using the changeset viewer.