Index: trunk/psLib/test/astronomy/tst_psAstrometry.c
===================================================================
--- trunk/psLib/test/astronomy/tst_psAstrometry.c	(revision 2006)
+++ trunk/psLib/test/astronomy/tst_psAstrometry.c	(revision 2048)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-07 19:51:30 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-12 01:34:09 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -19,8 +19,11 @@
 static int testExposureAlloc(void);
 static int testObservatoryAlloc(void);
+static int testFPAAlloc(void);
+// static int testGrommitAlloc(void);
 
 testDescription tests[] = {
                               {testExposureAlloc,735,"psExposureAlloc",0,false},
                               {testObservatoryAlloc,736,"psObservatoryAlloc",0,false},
+                              {testFPAAlloc,739,"psFPAAlloc",0,false},
                               {NULL}
                           };
@@ -119,12 +122,12 @@
     char* name = "The Kaiser Royal Observatory";
     psObservatory* obs = psObservatoryAlloc(name,
-                                            20.7, 156.3, 3055.0, 9.0);
-
-    if (fabs(obs->latitude - 20.7) > DBL_EPSILON) {
+                                            20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 9.0);
+
+    if (fabs(obs->latitude - 20.7*M_PI/180.0) > DBL_EPSILON) {
         psLogMsg(__func__,PS_LOG_ERROR,"psObservatoryAlloc did not set latitude.");
         return 1;
     }
 
-    if (fabs(obs->longitude - 156.3) > DBL_EPSILON) {
+    if (fabs(obs->longitude - 156.3*M_PI/180.0) > DBL_EPSILON) {
         psLogMsg(__func__,PS_LOG_ERROR,"psObservatoryAlloc did not set longitude.");
         return 2;
@@ -152,5 +155,5 @@
 
     psObservatory* obs2 = psObservatoryAlloc(NULL,
-                          20.7, 156.3, 3055.0, 9.0);
+                          20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 9.0);
 
     if (obs2->name != NULL) {
@@ -164,2 +167,157 @@
     return 0;
 }
+
+static int testFPAAlloc(void)
+{
+
+    psTime* now = psTimeGetTime(PS_TIME_UTC);
+    char* name = "The Kaiser Royal Observatory";
+
+    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);
+
+    /*
+        1. Call psFPAAlloc with nChips > 0 and a non-NULL psExposure.
+        a) Verify that the psExposure reference is: 1. is set in struct as
+        exposure; 2. its reference count is incremented.
+        b) Verify that the chip attribute is of the size specified by the
+        parameter nChips and that the chips array elements are all NULL.
+        c) verify that all other references in the struct is NULL.
+    */
+
+    psFPA* fpa = psFPAAlloc(8, exp);
+
+    if (fpa == NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc returned a NULL.");
+        return 1;
+    }
+
+    if (fpa->exposure != exp) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set the exposure.");
+        return 2;
+    }
+
+    if (psMemGetRefCounter(exp) != 2) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not increment reference counter for exposure.");
+        return 3;
+    }
+
+    if (fpa->chips->n != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set the number of chips properly.");
+        return 4;
+    }
+
+    for (int lcv=0; lcv < 8; lcv++) {
+        if (fpa->chips->data[lcv] != NULL) {
+            psLogMsg(__func__,PS_LOG_ERROR,
+                     "psFPAAlloc did not set chip %d to NULL.", lcv);
+            return 5;
+        }
+    }
+
+    if (fpa->metadata != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set metadata to NULL.");
+        return 6;
+    }
+
+    if (fpa->fromTangentPlane != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set fromTangentPlane to NULL.");
+        return 7;
+    }
+
+    if (fpa->toTangentPlane != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set toTangentPlane to NULL.");
+        return 8;
+    }
+
+    if (fpa->pattern != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set pattern to NULL.");
+        return 9;
+    }
+
+    if (fpa->grommit == NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set grommit using given exposure.");
+        return 10;
+    }
+
+    if (fpa->colorPlus != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set colorPlus to NULL.");
+        return 11;
+    }
+
+    if (fpa->colorMinus != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set colorMinus to NULL.");
+        return 12;
+    }
+
+    if (fpa->projection != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set projection to NULL.");
+        return 13;
+    }
+
+    /*
+        2. Call psFPAAlloc with nChips = 0. Verify that the chips array is 
+           zero in size and the program execution does not stop.
+    */
+
+    psFPA* fpa2 = psFPAAlloc(0,exp);
+
+    if (fpa2->chips->n != 0) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set the number of chips properly.");
+        return 14;
+    }
+
+    /*
+        3. Call psFPAAlloc with a NULL psExposure. Verify that the program 
+           execution doe not stop and the exposure attribute is NULL.
+    */
+
+    psFPA* fpa3 = psFPAAlloc(4,NULL);
+    if (fpa3->exposure != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psFPAAlloc did not set the exposure to NULL given NULL parameter.");
+        return 15;
+    }
+
+    /*
+        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.
+    */
+
+    for (int lcv=0; lcv < 8; lcv++) {
+        fpa->chips->data[lcv] = psAlloc(4);
+    }
+
+    fpa->metadata = psAlloc(4);
+    fpa->fromTangentPlane = psAlloc(4);
+    fpa->toTangentPlane = psAlloc(4);
+    fpa->pattern = psAlloc(4);
+    fpa->colorPlus  = psAlloc(4);
+    fpa->colorMinus  = psAlloc(4);
+    fpa->projection  = psAlloc(4);
+
+    psFree(fpa3);
+    psFree(fpa2);
+    psFree(fpa);
+    psFree(exp);
+    psFree(obs);
+
+    return 0;
+}
