Index: trunk/psLib/test/astronomy/tst_psAstrometry.c
===================================================================
--- trunk/psLib/test/astronomy/tst_psAstrometry.c	(revision 2536)
+++ trunk/psLib/test/astronomy/tst_psAstrometry.c	(revision 2855)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-30 21:47:19 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-30 20:18:36 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -278,5 +278,5 @@
 
     /*
-        2. Call psFPAAlloc with nChips = 0. Verify that the chips array is 
+        2. Call psFPAAlloc with nChips = 0. Verify that the chips array is
            zero in size and the program execution does not stop.
     */
@@ -291,5 +291,5 @@
 
     /*
-        3. Call psFPAAlloc with a NULL psExposure. Verify that the program 
+        3. Call psFPAAlloc with a NULL psExposure. Verify that the program
            execution doe not stop and the exposure attribute is NULL.
     */
@@ -303,6 +303,6 @@
 
     /*
-        4. Call psFPAAlloc and set all references in the struct to a memory 
-           buffer. Verify that psFree cleans up all the buffers referenced in 
+        4. Call psFPAAlloc and set all references in the struct to a memory
+           buffer. Verify that psFree cleans up all the buffers referenced in
            the struct, i.e., there is no memory leaks generated.
     */
@@ -353,8 +353,8 @@
 
     /*
-        1. invoke psChipAlloc with nCells > 0 and parentFPA non-NULL. Verify 
+        1. invoke psChipAlloc with nCells > 0 and parentFPA non-NULL. Verify
            that:
         a. the cells array is of the size nCells and all elements are NULL.
-        b. parent attribute is set to parentFPA parameter and the ref. count 
+        b. parent attribute is set to parentFPA parameter and the ref. count
            was incremented.
         c. all other attributes are initialized to NULL or 0.
@@ -368,7 +368,13 @@
     }
 
-    if (chip->cells->n != 8) {
+    if (chip->cells->n != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psChipAlloc did not set the number of cells properly.");
+        return 2;
+    }
+
+    if (chip->cells->nalloc != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psChipAlloc did not allocate cell array size properly.");
         return 2;
     }
@@ -382,4 +388,5 @@
         chip->cells->data[lcv] = psAlloc(4); // to check if these are freed.
     }
+    chip->cells->n = 8;
 
     if (chip->parent != fpa) {
@@ -419,5 +426,5 @@
         2. invoke psChipAlloc with nCells = 0. Verify that:
         a. execution does not halt
-        b. the cells array is of the size of zero.    
+        b. the cells array is of the size of one.
     */
 
@@ -435,4 +442,10 @@
     }
 
+    if (chip2->cells->nalloc != 1) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psChipAlloc did not allocate cell array size properly.");
+        return 12;
+    }
+
     if (chip2->parent != fpa) {
         psLogMsg(__func__,PS_LOG_ERROR,
@@ -448,5 +461,5 @@
 
     /*
-        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent 
+        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent
            attribute is NULL and no error is generated.
     */
@@ -459,8 +472,14 @@
     }
 
-    if (chip3->cells->n != 8) {
+    if (chip3->cells->n != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psChipAlloc did not set the number of cells properly.");
         return 22;
+    }
+
+    if (chip3->cells->nalloc != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psChipAlloc did not allocate cell array properly.");
+        return 23;
     }
 
@@ -487,8 +506,22 @@
 
     psObservatory* obs = psObservatoryAlloc(name,
-                                            20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 0.0065f);
-
-    psExposure* exp = psExposureAlloc(1.0, 2.0, 3.0, 4.0, 5.0,
-                                      now, 6.0f, 260.0f, 1013.0f, 0.7f, 10.0f, 0.650f, obs);
+                                            20.7*M_PI/180.0,
+                                            156.3*M_PI/180.0,
+                                            3055.0,
+                                            0.0065f);
+
+    psExposure* exp = psExposureAlloc(1.0,
+                                      2.0,
+                                      3.0,
+                                      4.0,
+                                      5.0,
+                                      now,
+                                      6.0f,
+                                      260.0f,
+                                      1013.0f,
+                                      0.7f,
+                                      10.0f,
+                                      0.650f,
+                                      obs);
 
     psFPA* fpa = psFPAAlloc(8, exp);
@@ -507,5 +540,5 @@
         1. invoke psCellAlloc with nReadouts > 0 and parentChip non-NULL. Verify that:
         a. the readouts array is of the size nReadouts and all elements are NULL.
-        b. parent attribute is set to parentChip parameter and the ref. count 
+        b. parent attribute is set to parentChip parameter and the ref. count
            was incremented.
         c. all other attributes are initialized to NULL or 0.
@@ -519,7 +552,13 @@
     }
 
-    if (cell1->readouts->n != 8) {
+    if (cell1->readouts->n != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psCellAlloc did not set the number of readouts properly.");
+        return 2;
+    }
+
+    if (cell1->readouts->nalloc != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psCellAlloc did not allocat the readout array properly.");
         return 2;
     }
@@ -533,4 +572,5 @@
         cell1->readouts->data[lcv] = psAlloc(4); // to check if these are freed.
     }
+    cell1->readouts->n = 8;
 
     if (cell1->parent != chip) {
@@ -584,5 +624,5 @@
         2. invoke psChipAlloc with nCells = 0. Verify that:
         a. execution does not halt
-        b. the cells array is of the size of zero.    
+        b. the cells array is of the size of one.
     */
 
@@ -600,4 +640,10 @@
     }
 
+    if (cell2->readouts->nalloc != 1) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psCellAlloc did not allocate the readout array properly.");
+        return 13;
+    }
+
     if (cell2->parent != chip) {
         psLogMsg(__func__,PS_LOG_ERROR,
@@ -613,5 +659,5 @@
 
     /*
-        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent 
+        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent
            attribute is NULL and no error is generated.
     */
@@ -624,8 +670,14 @@
     }
 
-    if (cell3->readouts->n != 8) {
+    if (cell3->readouts->n != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psCellAlloc did not set the number of cells properly.");
         return 22;
+    }
+
+    if (cell3->readouts->nalloc != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psCellAlloc did not set the number of cells properly.");
+        return 23;
     }
 
@@ -647,14 +699,5 @@
 static psS32 testReadoutAlloc(void)
 {
-    psImage* image = psImageAlloc(64,64,PS_TYPE_S8);
-
-
-    /*
-        1. invoke psReadoutAlloc with unique/non-zero x0,y0 and non-NULL image. Verify that:
-        a. col0 & row0 are set to the parameters x0 and y0, respectively.
-        b. image attribute is set to image parameter and referenece is incremented
-        c. mask, objects, and metadata attributes are all NULL
-    */
-    psReadout* readout = psReadoutAlloc(1,2,image);
+    psReadout* readout = psReadoutAlloc();
 
     if (readout == NULL) {
@@ -663,5 +706,5 @@
     }
 
-    if (readout->col0 != 1) {
+    if (readout->col0 != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psReadoutAlloc did not set col0 properly.");
@@ -669,5 +712,5 @@
     }
 
-    if (readout->row0 != 2) {
+    if (readout->row0 != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psReadoutAlloc did not set row0 properly.");
@@ -675,5 +718,5 @@
     }
 
-    if (readout->image != image) {
+    if (readout->image != NULL) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psReadoutAlloc did not set the image properly.");
@@ -681,9 +724,5 @@
     }
 
-    if (psMemGetRefCounter(image) != 1) {
-        psLogMsg(__func__,PS_LOG_ERROR,
-                 "psReadoutAlloc incremented reference counter for image.");
-        return 5;
-    }
+    readout->image = psAlloc(4); // to check if these are freed.
 
     if (readout->metadata != NULL) {
