Index: trunk/psModules/test/astrom/tst_pmAstrometry.c
===================================================================
--- trunk/psModules/test/astrom/tst_pmAstrometry.c	(revision 5169)
+++ trunk/psModules/test/astrom/tst_pmAstrometry.c	(revision 5435)
@@ -1,11 +1,11 @@
 /** @file  tst_pmAstrometry.c
  *
- *  @brief Contains the tests for pmAstrometry.[ch].  Only the pmxxxAlloc()
+ *  @brief Contains the tests: pmAstrometry.[ch].  Only the pmxxxAlloc()
  *  and psFree() functionality are used here.
  *
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-28 20:42:51 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-10-20 23:06:24 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,4 +32,7 @@
                           };
 
+#define CHIP_ALLOC_NAME "ChipName"
+#define CELL_ALLOC_NAME "CellName"
+
 psS32 main(psS32 argc, char* argv[])
 {
@@ -44,136 +47,126 @@
     // XXX: Do something more with these arguments.
     const psMetadata *camera = psMetadataAlloc();
-    psDB *db = NULL;
-    pmFPA* fpa = pmFPAAlloc(camera, db);
+    pmFPA* fpa = pmFPAAlloc(camera);
 
     if (fpa == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.");
         return 1;
     }
 
     if (fpa->fromTangentPlane != NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->fromTangentPlane to NULL.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->fromTangentPlane to NULL.");
         return 2;
     }
 
     if (fpa->toTangentPlane != NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->toTangentPlane to NULL.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->toTangentPlane to NULL.");
         return 3;
     }
     if (fpa->projection != NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->projection to NULL.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->projection to NULL.");
         return 4;
     }
 
     if (fpa->concepts == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->concepts.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->concepts.");
         return 5;
     }
 
-    if (fpa->analysis == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->analysis.");
+    if (fpa->analysis != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->analysis to NULL.");
         return 6;
     }
 
     if (fpa->camera != camera) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->camera.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->camera.");
         return 7;
     }
 
     if (fpa->chips == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->chips.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->chips.");
         return 8;
     }
 
-    if (fpa->header != NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->header to NULL.");
+    if (fpa->private != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->private to NULL.");
         return 9;
     }
 
-    if (fpa->db != db) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->db.");
+    psFree(fpa);
+    psFree(camera);
+
+    return 0;
+}
+
+static psS32 testChipAlloc(void)
+{
+    const psMetadata *camera = psMetadataAlloc();
+    pmFPA* fpa = pmFPAAlloc(camera);
+    if (fpa == NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.");
+        return 1;
+    }
+
+    pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME);
+    if (chip == NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.");
+        return 1;
+    }
+
+    if (chip->col0 != -1) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->col0 set improperly.\n");
+        return 5;
+    }
+
+    if (chip->row0 != -1) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->row0 set improperly.\n");
+        return 6;
+    }
+
+    if (chip->toFPA != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->toChip set improperly.\n");
+        return 7;
+    }
+
+    if (chip->fromFPA != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->toFPA set improperly.\n");
+        return 8;
+    }
+
+    if (chip->concepts == NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->concepts set improperly.\n");
+        return 21;
+    } else {
+        psMetadataItem *tmpMeta = psMetadataLookup(chip->concepts, "CHIP.NAME");
+        if (0 != strcmp((char *) tmpMeta->data.V, CHIP_ALLOC_NAME)) {
+            psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: The metadata was set improperly.\n");
+            return (32);
+        }
+        // XXX: Code a test to ensure the metadata has the correct type
+    }
+
+    if (chip->analysis != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->analysis set improperly.\n");
         return 10;
     }
 
-    psFree(camera);
-    psFree(fpa);
-
-    return 0;
-}
-
-static psS32 testChipAlloc(void)
-{
-    const psMetadata *camera = psMetadataAlloc();
-    psDB *db = NULL;
-    pmFPA* fpa = pmFPAAlloc(camera, db);
-    if (fpa == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");
-        return 1;
-    }
-
-    pmChip *chip = pmChipAlloc(fpa);
-    if (chip == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.");
-        return 1;
-    }
-
-    if (chip->col0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->col0 set improperly.\n");
-        return 5;
-    }
-
-    if (chip->row0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->row0 set improperly.\n");
-        return 6;
-    }
-
-    if (chip->toFPA != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->toChip set improperly.\n");
-        return 7;
-    }
-
-    if (chip->fromFPA != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->toFPA set improperly.\n");
-        return 8;
-    }
-
-    if (chip->concepts == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->concepts set improperly.\n");
-        return 21;
-    }
-
-    if (chip->analysis == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->analysis set improperly.\n");
-        return 10;
-    }
-
     if (chip->cells == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->cells set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->cells set improperly.\n");
         return 22;
     }
 
     if (chip->parent != fpa) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->parent set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->parent set improperly.\n");
         return 23;
     }
 
     if (chip->valid != false) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->valid set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->valid set improperly.\n");
         return 24;
     }
 
-    if (chip->extname != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->extname set improperly.\n");
+    if (chip->private != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->private set improperly.\n");
         return 25;
-    }
-
-    if (chip->pixels != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->pixels set improperly.\n");
-        return 26;
-    }
-
-    if (chip->header != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->header set improperly.\n");
-        return 27;
     }
 
@@ -187,86 +180,87 @@
 static psS32 testCellAlloc(void)
 {
-    psDB *db = NULL;
     const psMetadata *camera = psMetadataAlloc();
-    pmFPA* fpa = pmFPAAlloc(camera, db);
+    pmFPA* fpa = pmFPAAlloc(camera);
     if (fpa == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.n");
-        return 1;
-    }
-
-    pmChip *chip = pmChipAlloc(fpa);
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.n");
+        return 1;
+    }
+
+    pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME);
     if (chip == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.n");
         return 2;
     }
 
-    pmCell *cell = pmCellAlloc(chip);
+    pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, CELL_ALLOC_NAME);
     if (cell == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmCellAlloc returned a NULL.n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmCellAlloc returned a NULL.n");
         return 3;
     }
 
     if (cell->col0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->col0 set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->col0 set improperly.\n");
         return 5;
     }
 
     if (cell->row0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->row0 set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->row0 set improperly.\n");
         return 6;
     }
 
     if (cell->toChip != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->toChip set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toChip set improperly.\n");
         return 7;
     }
 
     if (cell->toFPA != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->toFPA set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toFPA set improperly.\n");
         return 8;
     }
 
     if (cell->toSky != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->toSky set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toSky set improperly.\n");
         return 9;
     }
 
-    if (cell->analysis == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->analysis set improperly.\n");
+    if (cell->concepts == NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->concepts set improperly.\n");
+        return 21;
+    } else {
+        psMetadataItem *tmpMeta = psMetadataLookup(cell->concepts, "CELL.NAME");
+        if (0 != strcmp((char *) tmpMeta->data.V, CELL_ALLOC_NAME)) {
+            psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: The metadata was set improperly.\n");
+            return (32);
+        }
+        // XXX: Code a test to ensure the metadata has the correct type
+    }
+
+    if (cell->camera != camera) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->camera set improperly.\n");
+        return 20;
+    }
+
+    if (cell->analysis != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->analysis set improperly.\n");
         return 10;
     }
 
-    if (cell->concepts == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->concepts set improperly.\n");
-        return 21;
-    }
-
     if (cell->readouts == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->readouts set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->readouts set improperly.\n");
         return 22;
     }
 
     if (cell->parent != chip) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->parent set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->parent set improperly.\n");
         return 23;
     }
 
     if (cell->valid != false) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->valid set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->valid set improperly.\n");
         return 24;
     }
 
-    if (cell->extname != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->extname set improperly.\n");
-        return 25;
-    }
-
-    if (cell->pixels != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->pixels set improperly.\n");
-        return 26;
-    }
-
-    if (cell->header != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->header set improperly.\n");
+    if (cell->private != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->private set improperly.\n");
         return 27;
     }
@@ -282,22 +276,21 @@
 static psS32 testReadoutAlloc(void)
 {
-    psDB *db = NULL;
     const psMetadata *camera = psMetadataAlloc();
-    pmFPA* fpa = pmFPAAlloc(camera, db);
+    pmFPA* fpa = pmFPAAlloc(camera);
 
     if (fpa == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.\n");
-        return 1;
-    }
-
-    pmChip *chip = pmChipAlloc(fpa);
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.\n");
+        return 1;
+    }
+
+    pmChip *chip = pmChipAlloc(fpa, "ChipName");
     if (chip == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.\n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.\n");
         return 2;
     }
 
-    pmCell *cell = pmCellAlloc(chip);
+    pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, "CellName");
     if (cell == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmCellAlloc returned a NULL.\n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmCellAlloc returned a NULL.\n");
         return 3;
     }
@@ -305,51 +298,56 @@
     pmReadout *readout = pmReadoutAlloc(cell);
     if (readout == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmReadoutAlloc returned a NULL.\n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmReadoutAlloc returned a NULL.\n");
         return 4;
     }
 
     if (readout->col0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->col0 set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->col0 set improperly.\n");
         return 5;
     }
 
     if (readout->row0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->row0 set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->row0 set improperly.\n");
         return 6;
     }
 
     if (readout->colBins != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->colBins set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->colBins set improperly.\n");
         return 7;
     }
 
     if (readout->rowBins != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->colBins set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->colBins set improperly.\n");
         return 8;
     }
 
     if (readout->image != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->image set improperly.\n");
-        return 9;
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->image set improperly.\n");
+        return 10;
     }
 
     if (readout->mask != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->mask set improperly.\n");
-        return 10;
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->mask set improperly.\n");
+        return 12;
+    }
+
+    if (readout->weight != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->weight set improperly.\n");
+        return 14;
+    }
+
+    if (readout->bias != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->bias set improperly.\n");
+        return 16;
     }
 
     if (readout->analysis == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->analysis set improperly.\n");
-        return 11;
-    }
-
-    if (readout->concepts == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->concepts set improperly.\n");
-        return 12;
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->analysis set improperly.\n");
+        return 18;
     }
 
     if (readout->parent != cell) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->parent set improperly.\n");
-        return 15;
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->parent set improperly.\n");
+        return 20;
     }
 
@@ -362,2 +360,3 @@
     return 0;
 }
+
