Changeset 5435 for trunk/psModules/test/astrom/tst_pmAstrometry.c
- Timestamp:
- Oct 20, 2005, 1:06:24 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/astrom/tst_pmAstrometry.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/astrom/tst_pmAstrometry.c
r5169 r5435 1 1 /** @file tst_pmAstrometry.c 2 2 * 3 * @brief Contains the tests forpmAstrometry.[ch]. Only the pmxxxAlloc()3 * @brief Contains the tests: pmAstrometry.[ch]. Only the pmxxxAlloc() 4 4 * and psFree() functionality are used here. 5 5 * 6 6 * @author George Gusciora, MHPCC 7 7 * 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 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 32 32 }; 33 33 34 #define CHIP_ALLOC_NAME "ChipName" 35 #define CELL_ALLOC_NAME "CellName" 36 34 37 psS32 main(psS32 argc, char* argv[]) 35 38 { … … 44 47 // XXX: Do something more with these arguments. 45 48 const psMetadata *camera = psMetadataAlloc(); 46 psDB *db = NULL; 47 pmFPA* fpa = pmFPAAlloc(camera, db); 49 pmFPA* fpa = pmFPAAlloc(camera); 48 50 49 51 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."); 51 53 return 1; 52 54 } 53 55 54 56 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."); 56 58 return 2; 57 59 } 58 60 59 61 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."); 61 63 return 3; 62 64 } 63 65 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."); 65 67 return 4; 66 68 } 67 69 68 70 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."); 70 72 return 5; 71 73 } 72 74 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."); 75 77 return 6; 76 78 } 77 79 78 80 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."); 80 82 return 7; 81 83 } 82 84 83 85 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."); 85 87 return 8; 86 88 } 87 89 88 if (fpa-> header!= NULL) {89 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->headerto NULL.");90 if (fpa->private != NULL) { 91 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->private to NULL."); 90 92 return 9; 91 93 } 92 94 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 101 static 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"); 95 150 return 10; 96 151 } 97 152 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 150 153 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"); 152 155 return 22; 153 156 } 154 157 155 158 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"); 157 160 return 23; 158 161 } 159 162 160 163 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"); 162 165 return 24; 163 166 } 164 167 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"); 167 170 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;178 171 } 179 172 … … 187 180 static psS32 testCellAlloc(void) 188 181 { 189 psDB *db = NULL;190 182 const psMetadata *camera = psMetadataAlloc(); 191 pmFPA* fpa = pmFPAAlloc(camera , db);183 pmFPA* fpa = pmFPAAlloc(camera); 192 184 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); 198 190 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"); 200 192 return 2; 201 193 } 202 194 203 pmCell *cell = pmCellAlloc(chip );195 pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, CELL_ALLOC_NAME); 204 196 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"); 206 198 return 3; 207 199 } 208 200 209 201 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"); 211 203 return 5; 212 204 } 213 205 214 206 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"); 216 208 return 6; 217 209 } 218 210 219 211 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"); 221 213 return 7; 222 214 } 223 215 224 216 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"); 226 218 return 8; 227 219 } 228 220 229 221 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"); 231 223 return 9; 232 224 } 233 225 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"); 236 245 return 10; 237 246 } 238 247 239 if (cell->concepts == NULL) {240 psLogMsg(__func__, PS_LOG_ERROR, "cell->concepts set improperly.\n");241 return 21;242 }243 244 248 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"); 246 250 return 22; 247 251 } 248 252 249 253 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"); 251 255 return 23; 252 256 } 253 257 254 258 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"); 256 260 return 24; 257 261 } 258 262 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"); 271 265 return 27; 272 266 } … … 282 276 static psS32 testReadoutAlloc(void) 283 277 { 284 psDB *db = NULL;285 278 const psMetadata *camera = psMetadataAlloc(); 286 pmFPA* fpa = pmFPAAlloc(camera , db);279 pmFPA* fpa = pmFPAAlloc(camera); 287 280 288 281 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"); 294 287 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"); 296 289 return 2; 297 290 } 298 291 299 pmCell *cell = pmCellAlloc(chip );292 pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, "CellName"); 300 293 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"); 302 295 return 3; 303 296 } … … 305 298 pmReadout *readout = pmReadoutAlloc(cell); 306 299 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"); 308 301 return 4; 309 302 } 310 303 311 304 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"); 313 306 return 5; 314 307 } 315 308 316 309 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"); 318 311 return 6; 319 312 } 320 313 321 314 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"); 323 316 return 7; 324 317 } 325 318 326 319 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"); 328 321 return 8; 329 322 } 330 323 331 324 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; 334 327 } 335 328 336 329 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; 339 342 } 340 343 341 344 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; 349 347 } 350 348 351 349 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; 354 352 } 355 353 … … 362 360 return 0; 363 361 } 362
Note:
See TracChangeset
for help on using the changeset viewer.
