Index: trunk/psLib/test/astro/tap_psCoord.c
===================================================================
--- trunk/psLib/test/astro/tap_psCoord.c	(revision 13614)
+++ trunk/psLib/test/astro/tap_psCoord.c	(revision 13623)
@@ -5,6 +5,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-05-01 00:08:52 $
+*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-06-05 01:10:22 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -50,5 +50,5 @@
         psPlaneTransform *myPT = psPlaneTransformAlloc(ORDER_X, ORDER_Y);
         ok(myPT != NULL, "psPlaneTransformAlloc() returned non-NULL");
-        skip_start(myPT == NULL, 6, "Skipping tests because psPlaneTransformAlloc() returned NULL");
+        skip_start(myPT == NULL, 4, "Skipping tests because psPlaneTransformAlloc() returned NULL");
         ok(myPT->x->nX == ORDER_X, "psPlaneTransform->x->nX set correctly");
         ok(myPT->y->nX == ORDER_X, "psPlaneTransform->y->nX set correctly");
@@ -64,5 +64,5 @@
 
         myPT = psPlaneTransformAlloc(1, -1);
-        ok(myPT == NULL, "psPlaneTransformAlloc(1, -11) returned NULL");
+        ok(myPT == NULL, "psPlaneTransformAlloc(1, -1) returned NULL");
         psFree(myPT);
 
@@ -127,5 +127,6 @@
             in->yErr = 0.0;
 
-            // XXX: psPlane *out = psPlaneTransformApply(out, pt, in); causes a seg-fault.  Why?
+            // XXX: psPlane *out = psPlaneTransformApply(out, pt, in); causes a seg-fault.
+            // Why?
             psPlane *out = psPlaneTransformApply(NULL, pt, in);
             if(out == NULL) {
@@ -154,5 +155,5 @@
 
     // psPlaneTransformApply should generate error message for NULL psPlaneTransform
-    if (1) {
+    {
         psMemId id = psMemGetId();
         psPlane* in = psPlaneAlloc();
@@ -165,5 +166,5 @@
 
     // psPlaneTransformApply should generate error message for NULL x coeff psPlaneTransform
-    if (1) {
+    {
         psMemId id = psMemGetId();
         psPlane *in = psPlaneAlloc();
@@ -180,5 +181,5 @@
 
     // psPlaneTransformApply Should generate error message for NULL y coeff psPlaneTransform");
-    if (1) {
+    {
         psMemId id = psMemGetId();
         psPlane* in = psPlaneAlloc();
@@ -195,5 +196,5 @@
 
     // psPlaneTransformApply() should generate error message for NULL psPlane");
-    if (1) {
+    {
         psMemId id = psMemGetId();
         psPlaneTransform* pt = psPlaneTransformAlloc(2,2);
Index: trunk/psLib/test/astro/tap_psCoord02.c
===================================================================
--- trunk/psLib/test/astro/tap_psCoord02.c	(revision 13614)
+++ trunk/psLib/test/astro/tap_psCoord02.c	(revision 13623)
@@ -7,6 +7,6 @@
 *  XXX: These tests should probably be split among several files
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-05-01 00:08:52 $
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-06-05 01:10:22 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -449,6 +449,6 @@
         // We calling psPlaneTransformInvert with acceptable linear transformations
         for (psS32 n = 0 ; n < NUM_TRANSFORMS ; n++)
-    {
-        if (n == 0) {
+        {
+            if (n == 0) {
                 // I ensure that we test the identity transformation since this was
                 // giving us probs before.
Index: trunk/psLib/test/astro/tap_psEarthOrientation_corrections.c
===================================================================
--- trunk/psLib/test/astro/tap_psEarthOrientation_corrections.c	(revision 13614)
+++ trunk/psLib/test/astro/tap_psEarthOrientation_corrections.c	(revision 13623)
@@ -71,5 +71,5 @@
 void testAberration(void)
 {
-//    diag("  >>>Test 2:  psAberration ");
+    // psAberration()
     psSphere *apparent = NULL;
     psSphere *empty = NULL;
@@ -152,8 +152,8 @@
 void testGravDef(void)
 {
-//    diag("  >>>Test 3:  psGravityDeflection ");
-    //Test for psGravityDeflection
-    //Return properly allocated psEarthPole
-    /*
+    // psGravityDeflection
+    // Test for psGravityDeflection
+    // Return properly allocated psEarthPole
+    /* XXX: Fix this
         psSphere *apparent = NULL;
         psSphere *empty = NULL;
@@ -282,7 +282,7 @@
 void testEOC_Corrs(void)
 {
-//    diag("  >>>Test 4:  psEOC Correction Functions");
+    // psEOC Correction Functions");
     //Tests for psEOC_PrecessionCorr
-    /*
+    /* XXX: Fix this
         psTime *empty = NULL;
         psTime *time2 = psTimeAlloc(PS_TIME_UTC);
Index: trunk/psLib/test/astro/tap_psEarthOrientation_motion.c
===================================================================
--- trunk/psLib/test/astro/tap_psEarthOrientation_motion.c	(revision 13614)
+++ trunk/psLib/test/astro/tap_psEarthOrientation_motion.c	(revision 13623)
@@ -11,8 +11,6 @@
  *
  */
-
 #include <pslib.h>
 #include <string.h>
-
 #include "tap.h"
 #include "pstap.h"
@@ -22,5 +20,4 @@
 static void testSphereRots(void);
 static void testSpherePrecess(void);
-
 #define MJD_1900  15021.0        // Modified Julian Day 1/1/1900 00:00:00
 #define MJD_2100  88069.0        // Modified Julian Day 1/1/2100 00:00:00
@@ -30,8 +27,7 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(48);
-
-//    diag("Tests for psEarthOrientation Motion Functions");
-
+    plan_tests(78);
+
+    // Tests for psEarthOrientation Motion Functions
     // Initialize library internal structures
     psLibInit("pslib.config");
@@ -42,7 +38,5 @@
     testSpherePrecess();
 
-    // Cleanup library
     psLibFinalize();
-
     done();
 }
@@ -50,34 +44,45 @@
 void testPrecessionModel(void)
 {
-//    diag("  >>>Test 1:  psEOC_PrecessionModel");
+    // psEOC_PrecessionModel
 
     psEarthPole *ep = NULL;
     psTime *testTime = NULL;
 
+
     //Test for psEarthPoleAlloc
     //Return properly allocated psEarthPole
     {
+        psMemId id = psMemGetId();
         ep = psEarthPoleAlloc();
-        ok( ep != NULL,
-            "psEarthPoleAlloc:               return properly allocated psEarthPole.");
+        ok( ep != NULL, "psEarthPoleAlloc: return properly allocated psEarthPole.");
         psFree(ep);
         ep = NULL;
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Tests for psEOC_PrecessionModel
     //Return NULL for NULL time input.
     {
+        psMemId id = psMemGetId();
         ep = psEOC_PrecessionModel(NULL);
-        ok( ep == NULL,
-            "psEOC_PrecessionModel:          return NULL for NULL time input.");
-    }
+        ok( ep == NULL, "psEOC_PrecessionModel: return NULL for NULL time input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for UT1 time input.
     {
+        psMemId id = psMemGetId();
         testTime = psTimeAlloc(PS_TIME_UT1);
         ep = psEOC_PrecessionModel(testTime);
-        ok( ep == NULL,
-            "psEOC_PrecessionModel:          return NULL for UT1 time input.");
-    }
+        ok( ep == NULL, "psEOC_PrecessionModel: return NULL for UT1 time input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for invalid time input.
     {
+        psMemId id = psMemGetId();
         psFree(testTime);
         testTime = psTimeAlloc(PS_TIME_UTC);
@@ -87,5 +92,8 @@
             "psEOC_PrecessionModel:          return NULL for invalid time input.");
         testTime->nsec = 0;
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for failed eoc init - missing file
     //printf("\n filename = '%s' \n", p_psGetConfigFileName());
@@ -93,4 +101,5 @@
     //to define where the real pslib config is.
     {
+        psMemId id = psMemGetId();
         testTime->sec = 1049160600;
         testTime->nsec = 0;
@@ -103,8 +112,11 @@
         rename("../../etc/pslib/pslib_config.bak", "../../etc/pslib/pslib.config");
         skip_end();
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     //Return valid EarthPole for valid time input
     {
+        psMemId id = psMemGetId();
         double x, y, s;
         x = 2.857175590089105e-4;
@@ -121,4 +133,5 @@
                       "psEOC_PrecessionModel:          return valid EarthPole for valid inputs (s).");
         skip_end();
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
 
@@ -147,5 +160,5 @@
 void testPolarMotion(void)
 {
-//    diag("  >>>Test 2:  psEOC_GetPolarMotion ");
+    // psEOC_GetPolarMotion()
 
     psTime *in = psTimeAlloc(PS_TIME_UTC);
@@ -155,40 +168,54 @@
     psEarthPole *polarMotion = NULL;
 
+
     //Tests for psEOC_GetPolarMotion
     //Return NULL for NULL time input.
     {
+        psMemId id = psMemGetId();
         polarMotion = psEOC_GetPolarMotion(NULL, PS_IERS_B);
-        ok( polarMotion == NULL,
-            "psEOC_GetPolarMotion:           return NULL for NULL time input.");
-    }
+        ok( polarMotion == NULL, "psEOC_GetPolarMotion: return NULL for NULL time input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for invalid IERS table input
     {
+        psMemId id = psMemGetId();
         polarMotion = psEOC_GetPolarMotion(NULL, PS_IERS_B+1);
-        ok( polarMotion == NULL,
-            "psEOC_GetPolarMotion:          return NULL for invalid IERS table input.");
-    }
+        ok( polarMotion == NULL, "psEOC_GetPolarMotion: return NULL for invalid IERS table input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for invalid time input.
     {
+        psMemId id = psMemGetId();
         in->nsec = 2e9;
         polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B);
-        ok( polarMotion == NULL,
-            "psEOC_GetPolarMotion:          return NULL for invalid time input.");
+        ok( polarMotion == NULL, "psEOC_GetPolarMotion: return NULL for invalid time input.");
         in->nsec = 0;
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for failed eoc init - missing file
     //XXX: Use the PS_CONFIG_FILE_DEFAULT macro, or PS_CONFIG_FILE environment variable
     //to define where the real pslib config is.
     {
+        psMemId id = psMemGetId();
         p_psEOCFinalize();
         skip_start(rename("../../etc/pslib/pslib.config", "../../etc/pslib/pslib_config.bak"),
                    1, "Skipping 1 tests because file rename failed!");
         polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B);
-        ok( polarMotion == NULL,
-            "psEOC_GetPolarMotion:          return NULL for failed eoc init.");
+        ok( polarMotion == NULL, "psEOC_GetPolarMotion: return NULL for failed eoc init.");
         rename("../../etc/pslib/pslib_config.bak", "../../etc/pslib/pslib.config");
         skip_end();
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return valid EarthPole for valid time input - IERS B
     {
+        psMemId id = psMemGetId();
         double x, y, s;
         x = -6.454389659777e-07;
@@ -199,17 +226,21 @@
                      "Skipping 3 tests because psEarthPole is NULL!");
         is_double_tol(polarMotion->x, x, 0.1,
-                      "psEOC_GetPolarMotion:          return valid EarthPole for valid inputs "
+                      "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "
                       "(x) - IERS B.");
         is_double_tol(polarMotion->y, y, 0.1,
-                      "psEOC_GetPolarMotion:          return valid EarthPole for valid inputs "
+                      "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "
                       "(y) - IERS B.");
         is_double_tol(polarMotion->s, s, 0.1,
-                      "psEOC_GetPolarMotion:          return valid EarthPole for valid inputs "
+                      "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "
                       "(s) - IERS B.");
         skip_end();
         psFree(polarMotion);
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return valid EarthPole for valid time input - IERS A
     {
+        psMemId id = psMemGetId();
         double x, y, s;
         x = -6.45381397904e-07;
@@ -220,22 +251,27 @@
                      "Skipping 3 tests because psEarthPole is NULL!");
         is_double_tol(polarMotion->x, x, 0.1,
-                      "psEOC_GetPolarMotion:          return valid EarthPole for valid inputs "
+                      "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "
                       "(x) - IERS A.");
         is_double_tol(polarMotion->y, y, 0.1,
-                      "psEOC_GetPolarMotion:          return valid EarthPole for valid inputs "
+                      "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "
                       "(y) - IERS A.");
         is_double_tol(polarMotion->s, s, 0.1,
-                      "psEOC_GetPolarMotion:          return valid EarthPole for valid inputs "
+                      "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "
                       "(s) - IERS A.");
         skip_end();
         psFree(polarMotion);
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return valid EarthPole for valid time input - IERS A
     {
+        psMemId id = psMemGetId();
         psTime *firstTime = psTimeFromMJD(41684.50);
         polarMotion = psEOC_GetPolarMotion(firstTime, PS_IERS_B);
         ok( polarMotion != NULL,
-            "psEOC_GetPolarMotion:          return valid EarthPole for valid inputs.");
+            "psEOC_GetPolarMotion: return valid EarthPole for valid inputs.");
         psFree(firstTime);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
 
@@ -264,5 +300,5 @@
 void testSphereRots(void)
 {
-//    diag("  >>>Test 3:  psSphereRot Functions");
+    // psSphereRot Functions
     psSphereRot *out = NULL;
     psEarthPole *in = NULL;
@@ -276,9 +312,12 @@
     //Return NULL for NULL earthPole input
     {
+        psMemId id = psMemGetId();
         out = psSphereRot_CEOtoGCRS(in);
-        ok( out == NULL,
-            "psSphereRot_CEOtoGCRS:         return NULL for NULL earthPole input.");
+        ok( out == NULL, "psSphereRot_CEOtoGCRS: return NULL for NULL earthPole input.");
         in = psEarthPoleAlloc();
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     in->x = 2.857175590089105e-4;
     in->y = 2.3968739377734732e-5;
@@ -286,17 +325,20 @@
     //Return correct psSphereRot for valid input
     {
+        psMemId id = psMemGetId();
         out = psSphereRot_CEOtoGCRS(in);
         skip_start(  out == NULL, 4,
                      "Skipping 4 tests because psSphereRot output is NULL!");
         is_double_tol( out->q0, q0, 0.0001,
-                       "psSphereRot_CEOtoGCRS:         return correct psSphereRot for valid input (q0).");
+                       "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q0).");
         is_double_tol( out->q1, q1, 0.0001,
-                       "psSphereRot_CEOtoGCRS:         return correct psSphereRot for valid input (q1).");
+                       "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q1).");
         is_double_tol( out->q2, q2, 0.0001,
-                       "psSphereRot_CEOtoGCRS:         return correct psSphereRot for valid input (q2).");
+                       "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q2).");
         is_double_tol( out->q3, -q3, 0.0001,
-                       "psSphereRot_CEOtoGCRS:         return correct psSphereRot for valid input (q3).");
-        skip_end();
-    }
+                       "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q3).");
+        skip_end();
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     //Tests for psSphereRot_TEOtoCEO
@@ -311,17 +353,24 @@
     //Return NULL for NULL time input
     {
+        psMemId id = psMemGetId();
         out = psSphereRot_TEOtoCEO(NULL, NULL);
-        ok( out == NULL,
-            "psSphereRot_TEOtoCEO:          return NULL for NULL time input.");
-    }
+        ok( out == NULL, "psSphereRot_TEOtoCEO: return NULL for NULL time input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for invalid time input - large nsec, UTC time type
     {
+        psMemId id = psMemGetId();
         time2->nsec = 3e9;
         out = psSphereRot_TEOtoCEO(time2, NULL);
-        ok( out == NULL,
-            "psSphereRot_TEOtoCEO:          return NULL for invalid time input.");
-    }
+        ok( out == NULL, "psSphereRot_TEOtoCEO: return NULL for invalid time input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for invalid time input - UT1 time type, large nsec
     {
+        psMemId id = psMemGetId();
         psFree(time2);
         time2 = psTimeAlloc(PS_TIME_UT1);
@@ -329,16 +378,21 @@
         temp->s = 1.0;
         out = psSphereRot_TEOtoCEO(time2, temp);
-        ok( out == NULL,
-            "psSphereRot_TEOtoCEO:          return NULL for invalid time input.");
-    }
+        ok( out == NULL, "psSphereRot_TEOtoCEO: return NULL for invalid time input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for invalid earthPole input
     {
+        psMemId id = psMemGetId();
         time2->nsec = 0;
         psEarthPole *temp = psEarthPoleAlloc();
         temp->s = -2.0;
         out = psSphereRot_TEOtoCEO(time2, temp);
-        ok( out == NULL,
-            "psSphereRot_TEOtoCEO:          return NULL for invalid earthPole input.");
-    }
+        ok( out == NULL, "psSphereRot_TEOtoCEO: return NULL for invalid earthPole input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct psSphereRot for valid inputs
     double x, y, z;
@@ -347,4 +401,5 @@
     z = 0.7496183628158023;
     {
+        psMemId id = psMemGetId();
         psEarthPole *polarTideCorr = psEOC_PolarTideCorr(time);
         out = psSphereRot_TEOtoCEO(time, polarTideCorr);
@@ -356,9 +411,8 @@
         psCube *cube = psSphereToCube(result);
         is_double_tol( cube->x, x, 0.0001,
-                       "psSphereRot_TEOtoCEO:          return NULL for NULL time input. (x)");
+                       "psSphereRot_TEOtoCEO: return NULL for NULL time input. (x)");
         is_double_tol( cube->y, y, 0.0001,
-                       "psSphereRot_TEOtoCEO:          return NULL for NULL time input. (y)");
-        is_double_tol( cube->z, z, 0.0001,
-                       "psSphereRot_TEOtoCEO:          return NULL for NULL time input. (z)");
+                       "psSphereRot_TEOtoCEO: return NULL for NULL time input. (y)");
+        is_double_tol( cube->z, z, 0.0001, "psSphereRot_TEOtoCEO: return NULL for NULL time input. (z)");
         psFree(earthRot);
         psFree(result);
@@ -367,9 +421,12 @@
         skip_end();
         psFree(polarTideCorr);
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     //Tests for psSphereRot_ITRStoTEO
     //Return NULL for NULL earthPole input
     {
+        psMemId id = psMemGetId();
         psFree(out);
         out = psSphereRot_ITRStoTEO(NULL);
@@ -377,7 +434,11 @@
             "psSphereRot_ITRStoTEO:         return NULL for NULL earthPole input.");
         in = psEarthPoleAlloc();
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct psSphereRot for valid input
     {
+        psMemId id = psMemGetId();
         q0 = -1.0567571848664005e-6;
         q1 = 3.218036562931509e-7;
@@ -391,12 +452,13 @@
                      "Skipping 4 tests because psSphereRot output is NULL!");
         is_double_tol( out->q0, q0, 0.0001,
-                       "psSphereRot_ITRStoTEO:         return correct psSphereRot for valid input (q0).");
+                       "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q0).");
         is_double_tol( out->q1, q1, 0.0001,
-                       "psSphereRot_ITRStoTEO:         return correct psSphereRot for valid input (q1).");
+                       "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q1).");
         is_double_tol( out->q2, q2, 0.0001,
-                       "psSphereRot_ITRStoTEO:         return correct psSphereRot for valid input (q2).");
+                       "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q2).");
         is_double_tol( out->q3, q3, 0.0001,
-                       "psSphereRot_ITRStoTEO:         return correct psSphereRot for valid input (q3).");
-        skip_end();
+                       "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q3).");
+        skip_end();
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
 
@@ -428,5 +490,5 @@
 void testSpherePrecess(void)
 {
-//    diag("  >>>Test 4:  psSpherePrecess");
+    // psSpherePrecess
     psSphereRot *rot = NULL;
     psTime *fromTime = NULL;
@@ -435,20 +497,28 @@
     psSphere* outputCoord = NULL;
 
+
     //Return NULL for NULL time inputs
     {
+        psMemId id = psMemGetId();
         rot = psSpherePrecess(fromTime, toTime, PS_PRECESS_ROUGH);
-        ok( rot == NULL,
-            "psSpherePrecess:               return NULL for NULL time inputs.");
-    }
+        ok( rot == NULL, "psSpherePrecess: return NULL for NULL time inputs.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for invalid mode input
     {
+        psMemId id = psMemGetId();
         fromTime    = psTimeFromMJD(MJD_2100);
         toTime      = psTimeFromMJD(MJD_1900);
         rot = psSpherePrecess(fromTime, toTime, -1);
-        ok( rot == NULL,
-            "psSpherePrecess:               return NULL for invalid mode input.");
-    }
+        ok( rot == NULL, "psSpherePrecess: return NULL for invalid mode input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct psSphereRot for valid inputs, mode = ROUGH
     {
+        psMemId id = psMemGetId();
         inputCoord->r = SPHERE_PRECESS_TP1_R;
         inputCoord->d = SPHERE_PRECESS_TP1_D;
@@ -463,15 +533,19 @@
                     "Skipping 2 tests because psSphereRot output is NULL!");
         is_double_tol( outputCoord->r, SPHERE_PRECESS_TP1_EXPECT_R, ERROR_TOL,
-                       "psSpherePrecess:               return correct psSphereRot for valid"
+                       "psSpherePrecess: return correct psSphereRot for valid"
                        " inputs and PS_PRECESS_ROUGH mode. (r)");
         is_double_tol( outputCoord->d, SPHERE_PRECESS_TP1_EXPECT_D, ERROR_TOL,
-                       "psSpherePrecess:               return correct psSphereRot for valid"
+                       "psSpherePrecess: return correct psSphereRot for valid"
                        " inputs and PS_PRECESS_ROUGH mode. (d)");
         skip_end();
         psFree(outputCoord);
         psFree(rot);
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct psSphereRot for valid inputs, mode = ROUGH
     {
+        psMemId id = psMemGetId();
         inputCoord->r = SPHERE_PRECESS_TP2_R;
         inputCoord->d = SPHERE_PRECESS_TP2_D;
@@ -486,15 +560,19 @@
                     "Skipping 2 tests because psSphereRot output is NULL!");
         is_double_tol( outputCoord->r, SPHERE_PRECESS_TP2_EXPECT_R, ERROR_TOL,
-                       "psSpherePrecess:               return correct psSphereRot for valid"
+                       "psSpherePrecess: return correct psSphereRot for valid"
                        " inputs and PS_PRECESS_ROUGH mode. (r)");
         is_double_tol( outputCoord->d, SPHERE_PRECESS_TP2_EXPECT_D, ERROR_TOL,
-                       "psSpherePrecess:               return correct psSphereRot for valid"
+                       "psSpherePrecess: return correct psSphereRot for valid"
                        " inputs and PS_PRECESS_ROUGH mode. (d)");
         skip_end();
         psFree(outputCoord);
         psFree(rot);
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct psSphereRot for valid inputs, mode = ROUGH
     {
+        psMemId id = psMemGetId();
         inputCoord->r = SPHERE_PRECESS_TP3_R;
         inputCoord->d = SPHERE_PRECESS_TP3_D;
@@ -509,40 +587,53 @@
                     "Skipping 2 tests because psSphereRot output is NULL!");
         is_double_tol( outputCoord->r, SPHERE_PRECESS_TP3_EXPECT_R, ERROR_TOL,
-                       "psSpherePrecess:               return correct psSphereRot for valid"
+                       "psSpherePrecess: return correct psSphereRot for valid"
                        " inputs and PS_PRECESS_ROUGH mode. (r)");
         is_double_tol( outputCoord->d, SPHERE_PRECESS_TP3_EXPECT_D, ERROR_TOL,
-                       "psSpherePrecess:               return correct psSphereRot for valid"
+                       "psSpherePrecess: return correct psSphereRot for valid"
                        " inputs and PS_PRECESS_ROUGH mode. (d)");
         skip_end();
         psFree(outputCoord);
         psFree(rot);
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct psSphereRot for valid inputs, mode = COMPLETE_A
     {
+        psMemId id = psMemGetId();
         rot = psSpherePrecess(NULL, toTime, PS_PRECESS_COMPLETE_A);
         outputCoord = psSphereRotApply(NULL, rot, inputCoord);
         ok( outputCoord != NULL && rot != NULL,
-            "psSpherePrecess:               return correct psSphereRot for valid"
+            "psSpherePrecess: return correct psSphereRot for valid"
             " inputs and PS_PRECESS_COMPLETE_A mode.");
         psFree(outputCoord);
         psFree(rot);
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct psSphereRot for valid inputs, mode = COMPLETE_B
     {
+        psMemId id = psMemGetId();
         rot = psSpherePrecess(NULL, toTime, PS_PRECESS_COMPLETE_B);
         outputCoord = psSphereRotApply(NULL, rot, inputCoord);
         ok( outputCoord != NULL && rot != NULL,
-            "psSpherePrecess:               return correct psSphereRot for valid"
+            "psSpherePrecess: return correct psSphereRot for valid"
             " inputs and PS_PRECESS_COMPLETE_B mode.");
         psFree(outputCoord);
         psFree(rot);
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct psSphereRot for valid inputs, mode = IAU2000A
     {
+        psMemId id = psMemGetId();
         rot = psSpherePrecess(NULL, toTime, PS_PRECESS_IAU2000A);
         outputCoord = psSphereRotApply(NULL, rot, inputCoord);
         ok( outputCoord != NULL && rot != NULL,
-            "psSpherePrecess:               return correct psSphereRot for valid"
+            "psSpherePrecess: return correct psSphereRot for valid"
             " inputs and PS_PRECESS_IAU2000A mode.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
 
Index: trunk/psLib/test/astro/tap_psSphereOps_all.c
===================================================================
--- trunk/psLib/test/astro/tap_psSphereOps_all.c	(revision 13614)
+++ trunk/psLib/test/astro/tap_psSphereOps_all.c	(revision 13623)
@@ -13,19 +13,14 @@
  *
  */
-
 #include <pslib.h>
 #include <string.h>
-
 #include "tap.h"
 #include "pstap.h"
 
 #define DEG_INC   30.0
-
 #define MJD_1900  15021.0        // Modified Julian Day 1/1/1900 00:00:00
 #define MJD_2000  51544.0        // Modified Julian Day 1/1/2000 00:00:00
 #define MJD_2100  88069.0        // Modified Julian Day 1/1/2100 00:00:00
-
 #define ERROR_TOL   0.0001
-
 #define ALPHA_P 4*M_PI/3
 #define DELTA_P M_PI/4
@@ -39,21 +34,41 @@
 {
     psLogSetFormat("HLNM");
-    plan_tests(57);
-//    diag("Tests for psSphereOps Functions");
-
+    plan_tests(86);
     testSphereRotCreate();
     testSphereRotConvert();
     testSphereOffsets();
-
-    done();
 }
 
 void testSphereRotCreate(void)
 {
-//    diag("  >>>Test 1:  psSphereRot Creation Functions");
-
-    // Allocate data structure
-    psSphereRot* myST = NULL;
-    myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P);
+    // ----------------------------------------------------------------
+    //Tests for psSphereRotAlloc
+    //Return NULL for NAN input alpha
+    {
+        psMemId id = psMemGetId();
+        psSphereRot *s1 = psSphereRotAlloc(NAN, DELTA_P, PHI_P);
+        ok( s1 == NULL, "psSphereRotAlloc(): return NULL for NAN input alpha");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    //Return NULL for NAN input delta
+    {
+        psMemId id = psMemGetId();
+        psSphereRot *s1 = psSphereRotAlloc(ALPHA_P, NAN, PHI_P);
+        ok( s1 == NULL, "psSphereRotAlloc(): return NULL for NAN input delta");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    //Return NULL for NAN input phi
+    {
+        psMemId id = psMemGetId();
+        psSphereRot *s1 = psSphereRotAlloc(ALPHA_P, DELTA_P, NAN);
+        ok( s1 == NULL, "psSphereRotAlloc(): return NULL for NAN input phi");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     double a0 = (ALPHA_P - PHI_P)/2.0;
     double a1 = (ALPHA_P - PHI_P)/2.0;
@@ -65,69 +80,87 @@
     double q2 = sin(a2)*cos(DELTA_P/2);
     double q3 = cos(a3)*cos(DELTA_P/2);
-
-    //Tests for psSphereRotAlloc
-    //Return NULL for NAN input
-    {
-        psSphereRot *s1 = psSphereRotAlloc(ALPHA_P, NAN, PHI_P);
-        ok( s1 == NULL,
-            "psSphereRotAlloc:               return NULL for NAN input.");
-    }
-    //Return valid psSphereRot (allocated) for valid inputs
-    {
-        ok( myST != NULL && psMemCheckSphereRot(myST),
-            "psSphereRotAlloc:               return allocated SphereRot for valid inputs.");
-        is_double(q0, myST->q0,
-                  "psSphereRotAlloc:               return correct q0 value.");
-        is_double(q1, myST->q1,
-                  "psSphereRotAlloc:               return correct q1 value.");
-        is_double(q2, myST->q2,
-                  "psSphereRotAlloc:               return correct q2 value.");
-        is_double(q3, myST->q3,
-                  "psSphereRotAlloc:               return correct q3 value.");
-    }
+    // Test psSphereRot() for valid inputs
+    {
+        psMemId id = psMemGetId();
+        psSphereRot* myST = NULL;
+        myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P);
+        ok(myST != NULL && psMemCheckSphereRot(myST),
+            "psSphereRotAlloc:  return allocated SphereRot for valid inputs.");
+        is_double(q0, myST->q0, "psSphereRotAlloc: return correct q0 value.");
+        is_double(q1, myST->q1, "psSphereRotAlloc: return correct q1 value.");
+        is_double(q2, myST->q2, "psSphereRotAlloc: return correct q2 value.");
+        is_double(q3, myST->q3, "psSphereRotAlloc: return correct q3 value.");
+        psFree(myST);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // ----------------------------------------------------------------
     //Tests for psMemCheckSphereRot
     //Make sure psMemCheckSphereRot works correctly - return false
-    {
+    //for non-psSphereRot input
+    {
+        psMemId id = psMemGetId();
         int j = 2;
-        ok( !psMemCheckSphereRot(&j),
-            "psMemCheckSphereRot:            return false for non-SphereRot input.");
-    }
+        ok( !psMemCheckSphereRot(&j), "psMemCheckSphereRot: return false for non-SphereRot input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // ----------------------------------------------------------------
     //Tests for psSphereRotQuat
-    //Return NULL for NAN input
-    {
+    //Return NULL for NAN input q0
+    {
+        psMemId id = psMemGetId();
+        psSphereRot *s1 = psSphereRotQuat(NAN, q1, q2, q3);
+        ok( s1 == NULL, "psSphereRotQuat: return NULL for NAN input q0");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    //Return NULL for NAN input q1
+    {
+        psMemId id = psMemGetId();
+        psSphereRot *s1 = psSphereRotQuat(q0, NAN, q2, q3);
+        ok( s1 == NULL, "psSphereRotQuat: return NULL for NAN input q1");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    //Return NULL for NAN input q2
+    {
+        psMemId id = psMemGetId();
+        psSphereRot *s1 = psSphereRotQuat(q0, q1, NAN, q3);
+        ok( s1 == NULL, "psSphereRotQuat: return NULL for NAN input q2");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    //Return NULL for NAN input q3
+    {
+        psMemId id = psMemGetId();
         psSphereRot *s1 = psSphereRotQuat(q0, q1, q2, NAN);
-        ok( s1 == NULL,
-            "psSphereRotQuat:                return NULL for NAN input.");
-    }
+        ok( s1 == NULL, "psSphereRotQuat: return NULL for NAN input q3");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return valid psSphereRot (allocated) for valid inputs
-    psFree(myST);
-    myST = NULL;
-    myST = psSphereRotQuat(q0*2.0, q1*2.0, q2*2.0, q3*2.0);
-    {
+    psSphereRot* myST = psSphereRotQuat(q0*2.0, q1*2.0, q2*2.0, q3*2.0);
+    {
+        psMemId id = psMemGetId();
         ok( myST != NULL && psMemCheckSphereRot(myST),
-            "psSphereRotQuat:                return allocated SphereRot for valid inputs.");
-        is_double(q0, myST->q0,
-                  "psSphereRotQuat:               return correct q0 value.");
-        is_double(q1, myST->q1,
-                  "psSphereRotQuat:               return correct q1 value.");
-        is_double(q2, myST->q2,
-                  "psSphereRotQuat:               return correct q2 value.");
-        is_double(q3, myST->q3,
-                  "psSphereRotQuat:               return correct q3 value.");
-    }
-
-
-    //Check for Memory leaks
-    {
-        psFree(myST);
-        checkMem();
-    }
-
+            "psSphereRotQuat: return allocated SphereRot for valid inputs.");
+        is_double(q0, myST->q0, "psSphereRotQuat: return correct q0 value.");
+        is_double(q1, myST->q1, "psSphereRotQuat: return correct q1 value.");
+        is_double(q2, myST->q2, "psSphereRotQuat: return correct q2 value.");
+        is_double(q3, myST->q3, "psSphereRotQuat: return correct q3 value.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 }
+
 
 void testSphereRotConvert(void)
 {
-//    diag("  >>>Test 2:  psSphereRot Conversion Functions");
-
     // Allocate data structure
     psSphereRot* myST = NULL;
@@ -147,51 +180,66 @@
     icrs->d = DEG_TO_RAD(90.0);
 
+
+    // ---------------------------------------------------------
     //Tests for psSphereRotCombine
     //Return NULL for NULL sphere input
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotCombine(s1, myST, NULL);
-        ok( s1 == NULL,
-            "psSphereRotCombine:            return NULL for NULL input.");
-    }
+        ok( s1 == NULL, "psSphereRotCombine: return NULL for NULL input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for NULL transform input
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotCombine(s1, NULL, myST);
-        ok( s1 == NULL,
-            "psSphereRotCombine:            return NULL for NULL input.");
-    }
+        ok( s1 == NULL, "psSphereRotCombine: return NULL for NULL input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+    // XXX: Must test with legitimate input data.
+
+
+    // ---------------------------------------------------------
     //Tests for psSphereRotApply
     //Return NULL for NULL sphere input
     {
+        psMemId id = psMemGetId();
         out = psSphereRotApply(out, myST, NULL);
-        ok( out == NULL,
-            "psSphereRotApply:              return NULL for NULL sphere input.");
-    }
+        ok( out == NULL, "psSphereRotApply: return NULL for NULL sphere input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for NULL transform input
     {
+        psMemId id = psMemGetId();
         out = psSphereRotApply(out, NULL, sphere);
-        ok( out == NULL,
-            "psSphereRotApply:              return NULL for NULL transform input.");
-    }
-
+        ok( out == NULL, "psSphereRotApply: return NULL for NULL transform input.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // ---------------------------------------------------------
     //Tests for psSphereRotConjugate
     //Return NULL for NULL inputs
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotConjugate(s1, NULL);
-        ok( s1 == NULL,
-            "psSphereRotConjugate:          return NULL SphereRot for NULL inputs.");
+        ok(s1 == NULL, "psSphereRotConjugate: return NULL SphereRot for NULL inputs");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
     //Return correct conjugate for valid inputs
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotConjugate(s1, myST);
-        skip_start(  s1 == NULL, 1,
-                     "Skipping 1 tests because psSphereRot is NULL!");
+        skip_start(s1 == NULL, 1, "Skipping 1 tests because psSphereRot is NULL!");
         out = psSphereRotApply(out, myST, sphere);
-        skip_start(  out == NULL || out->r == 0, 2,
-                     "Skipping 1 tests because psSphereRotApply failed!");
+        skip_start(out == NULL || out->r == 0, 2,
+                  "Skipping 1 tests because psSphereRotApply failed!");
         out2 = psSphereRotApply(out2, s1, out);
-        is_double( out2->r, 0.0,
-                   "psSphereRotConjugate:          return correct SphereRot values.");
-        is_double( out2->d, 0.0,
-                   "psSphereRotConjugate:          return correct SphereRot values.");
+        is_double( out2->r, 0.0, "psSphereRotConjugate: return correct SphereRot values.");
+        is_double( out2->d, 0.0, "psSphereRotConjugate: return correct SphereRot values.");
         skip_end();
         psFree(s1);
@@ -202,69 +250,89 @@
         out2 = NULL;
         skip_end();
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // ---------------------------------------------------------
     //Tests for psSphereRotInvert
     //Return correct inversion for valid inputs
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotInvert(-PHI_P, -DELTA_P, -ALPHA_P);
-        is_double(s1->q0, myST->q0,
-                  "psSphereRotInvert:             return correct q0 value.");
-        is_double(s1->q1, myST->q1,
-                  "psSphereRotInvert:             return correct q1 value.");
-        is_double(s1->q2, myST->q2,
-                  "psSphereRotInvert:             return correct q2 value.");
-        is_double(s1->q3, myST->q3,
-                  "psSphereRotInvert:             return correct q3 value.");
+        is_double(s1->q0, myST->q0, "psSphereRotInvert: return correct q0 value.");
+        is_double(s1->q1, myST->q1, "psSphereRotInvert: return correct q1 value.");
+        is_double(s1->q2, myST->q2, "psSphereRotInvert: return correct q2 value.");
+        is_double(s1->q3, myST->q3, "psSphereRotInvert: return correct q3 value.");
         psFree(s1);
         s1 = NULL;
-    }
-
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // ---------------------------------------------------------
     //Tests for psSphereRotICRSToEcliptic
     //Return NULL for NULL input
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotICRSToEcliptic(NULL);
-        ok( s1 == NULL,
-            "psSphereRotICRSToEcliptic:     return NULL SphereRot for NULL inputs.");
-    }
+        ok( s1 == NULL, "psSphereRotICRSToEcliptic: return NULL SphereRot for NULL inputs.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for Pre-MJD_1900 Date
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotICRSToEcliptic(pre1900);
-        ok( s1 == NULL,
-            "psSphereRotICRSToEcliptic:     return NULL SphereRot for pre-1900 MJD date.");
-    }
+        ok( s1 == NULL, "psSphereRotICRSToEcliptic: return NULL SphereRot for pre-1900 MJD date.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct SphereRot for MJD_2000
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotICRSToEcliptic(mjd2k);
-        skip_start(  s1 == NULL, 2,
-                     "Skipping 2 tests because psSphereRot is NULL!");
+        skip_start(  s1 == NULL, 2, "Skipping 2 tests because psSphereRot is NULL!");
         icrs->r = DEG_TO_RAD(0.0);
         icrs->d = DEG_TO_RAD(90.0);
         psSphere* ecliptic = psSphereRotApply(NULL, s1, icrs);
         is_double_tol(DEG_TO_RAD(90.0), ecliptic->r, 0.00001,
-                      "psSphereRotICRSToEcliptic:     return correct SphereRot for MJD_2000 date.");
+                      "psSphereRotICRSToEcliptic: return correct SphereRot for MJD_2000 date.");
         is_double_tol(DEG_TO_RAD(66.560719), ecliptic->d, 0.00001,
-                      "psSphereRotICRSToEcliptic:     return correct SphereRot for MJD_2000 date.");
+                      "psSphereRotICRSToEcliptic: return correct SphereRot for MJD_2000 date.");
         psFree(ecliptic);
         skip_end();
         psFree(s1);
         s1 = NULL;
-    }
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // --------------------------------------------------------------
     //Tests for psSphereRotEclipticToICRS
     //Return NULL for NULL input
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotEclipticToICRS(NULL);
-        ok( s1 == NULL,
-            "psSphereRotEclipticToICRS:     return NULL SphereRot for NULL inputs.");
-    }
+        ok( s1 == NULL, "psSphereRotEclipticToICRS: return NULL SphereRot for NULL inputs.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for Pre-MJD_1900 Date
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotEclipticToICRS(pre1900);
-        ok( s1 == NULL,
-            "psSphereRotEclipticToICRS:     return NULL SphereRot for pre-1900 MJD date.");
-    }
+        ok( s1 == NULL, "psSphereRotEclipticToICRS: return NULL SphereRot for pre-1900 MJD date.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return correct SphereRot for MJD_2000
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotEclipticToICRS(mjd2k);
-        skip_start(  s1 == NULL, 2,
-                     "Skipping 2 tests because psSphereRot is NULL!");
+        skip_start(  s1 == NULL, 2, "Skipping 2 tests because psSphereRot is NULL!");
         psSphere* ecliptic = psSphereRotApply(NULL, s1, icrs);
         s2 = psSphereRotICRSToEcliptic(mjd2k);
@@ -272,7 +340,7 @@
         //XXX:  Pretty sure the following can be 180 degrees OR 0 degrees. (= the poles)
         is_double_tol(DEG_TO_RAD(180.0), fromEcliptic->r, 0.00001,
-                      "psSphereRotEclipticToICRS:     return correct SphereRot for MJD_2000 date.");
+                      "psSphereRotEclipticToICRS: return correct SphereRot for MJD_2000 date.");
         is_double_tol(DEG_TO_RAD(90.0), fromEcliptic->d, 0.00001,
-                      "psSphereRotEclipticToICRS:     return correct SphereRot for MJD_2000 date.");
+                      "psSphereRotEclipticToICRS: return correct SphereRot for MJD_2000 date.");
         psFree(ecliptic);
         psFree(fromEcliptic);
@@ -282,30 +350,39 @@
         psFree(s2);
         s2 = NULL;
-    }
-
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // --------------------------------------------------------------
     //Tests for psSphereRotICRSToGalactic
     //Return correct transformation
     {
+        psMemId id = psMemGetId();
         s2 = psSphereRotICRSToGalactic();
         galactic = psSphereRotApply(NULL, s2, icrs);
         is_double_tol(DEG_TO_RAD(122.93192), galactic->r, 0.00001,
-                      "psSphereRotICRSToGalactic:     return correct SphereRot.");
+                      "psSphereRotICRSToGalactic: return correct SphereRot.");
         is_double_tol(DEG_TO_RAD(27.12825), galactic->d, 0.00001,
-                      "psSphereRotICRSToGalactic:     return correct SphereRot.");
-    }
+                      "psSphereRotICRSToGalactic: return correct SphereRot.");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // --------------------------------------------------------------
     //Tests for psSphereRotGalacticToICRS
     //Return correct transformation
     {
+        psMemId id = psMemGetId();
         s1 = psSphereRotGalacticToICRS();
         psSphere *test = psSphereRotApply(NULL, s1, galactic);
-        //XXX:  Pretty sure the following can be 180 degrees OR 0 degrees. (= the poles)
+        //XXX: Pretty sure the following can be 180 degrees OR 0 degrees. (= the poles)
         is_double_tol(DEG_TO_RAD(180.0), test->r, 0.00001,
-                      "psSphereRotGalacticToICRS:     return correct SphereRot.");
+                      "psSphereRotGalacticToICRS: return correct SphereRot.");
         is_double_tol(DEG_TO_RAD(90.0), test->d, 0.00001,
-                      "psSphereRotGalacticToICRS:     return correct SphereRot.");
+                      "psSphereRotGalacticToICRS: return correct SphereRot.");
         psFree(test);
-    }
-
-    //Check for Memory leaks
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
     {
         psFree(galactic);
@@ -317,14 +394,11 @@
         psFree(sphere);
         psFree(myST);
-        checkMem();
     }
 
 }
+
 
 void testSphereOffsets(void)
 {
-//    diag("  >>>Test 3:  psSphereGet/SetOffset Functions");
-
-    // Allocate data structure
     psSphereRot* myST = NULL;
     myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P);
@@ -335,24 +409,28 @@
     psSphere *output = NULL;
 
+    // -----------------------------------------------------------
     //Tests for psSphereGetOffset
     //Test Get for NULL position1
     {
         output = psSphereGetOffset(empty, origin, PS_LINEAR, PS_RADIAN);
-        ok( output == NULL,
-            "psSphereGetOffset:             return NULL for NULL position1 input.");
-    }
+        ok( output == NULL, "psSphereGetOffset: return NULL for NULL position1 input.");
+    }
+
+
     //Test Get for NULL position2
     {
         output = psSphereGetOffset(origin, empty, PS_LINEAR, PS_RADIAN);
-        ok( output == NULL,
-            "psSphereGetOffset:             return NULL for NULL position2 input.");
-    }
+        ok( output == NULL, "psSphereGetOffset: return NULL for NULL position2 input.");
+    }
+
+
     //Return NULL for position1 declination > 90 degrees
     {
         origin->d = 100.0;
         output = psSphereGetOffset(origin, offset, PS_LINEAR, PS_RADIAN);
-        ok( output == NULL,
-            "psSphereGetOffset:             return NULL for position1->d > 90 degrees.");
-    }
+        ok( output == NULL, "psSphereGetOffset: return NULL for position1->d > 90 degrees.");
+    }
+
+
     //Return NULL for position1 declination > 90 degrees
     {
@@ -360,19 +438,20 @@
         offset->d = 100.0;
         output = psSphereGetOffset(origin, offset, PS_LINEAR, PS_RADIAN);
-        ok( output == NULL,
-            "psSphereGetOffset:             return NULL for position2->d > 90 degrees.");
-    }
+        ok( output == NULL, "psSphereGetOffset: return NULL for position2->d > 90 degrees.");
+    }
+
+
     //Return NULL for invalid mode specification
     {
         offset->d = 0.0;
         output = psSphereGetOffset(origin, offset, -1, PS_RADIAN);
-        ok( output == NULL,
-            "psSphereGetOffset:             return NULL for invalid mode input.");
-    }
+        ok( output == NULL, "psSphereGetOffset: return NULL for invalid mode input.");
+    }
+
+
     //Return NULL for invalid unit specification
     {
         output = psSphereGetOffset(origin, offset, PS_SPHERICAL, -1);
-        ok( output == NULL,
-            "psSphereGetOffset:             return NULL for invalid unit input.");
+        ok( output == NULL, "psSphereGetOffset: return NULL for invalid unit input.");
     }
     //Return matching sphere offsets regardless of units
@@ -383,7 +462,7 @@
         empty = psSphereGetOffset(origin, offset, PS_SPHERICAL, PS_DEGREE);
         is_double_tol(DEG_TO_RAD(empty->r), MIN_TO_RAD(output->r), 0.0001,
-                      "psSphereGetOffset:             return correct offset for differing units.");
+                      "psSphereGetOffset: return correct offset for differing units.");
         is_double_tol(DEG_TO_RAD(empty->d), MIN_TO_RAD(output->d), 0.0001,
-                      "psSphereGetOffset:             return correct offset for differing units.");
+                      "psSphereGetOffset: return correct offset for differing units.");
         psFree(output);
         psFree(empty);
@@ -396,24 +475,20 @@
     {
         output = psSphereSetOffset(empty, offset, PS_SPHERICAL, PS_DEGREE);
-        ok( output == NULL,
-            "psSphereSetOffset:             return NULL for NULL position input.");
+        ok( output == NULL, "psSphereSetOffset: return NULL for NULL position input.");
     }
     //Return NULL for NULL offset
     {
         output = psSphereSetOffset(offset, empty, PS_SPHERICAL, PS_DEGREE);
-        ok( output == NULL,
-            "psSphereSetOffset:             return NULL for NULL offset input.");
+        ok( output == NULL, "psSphereSetOffset: return NULL for NULL offset input.");
     }
     //Return NULL for invalid mode specification
     {
         output = psSphereSetOffset(origin, offset, -1, PS_RADIAN);
-        ok( output == NULL,
-            "psSphereSetOffset:             return NULL for for invalid mode input.");
+        ok( output == NULL, "psSphereSetOffset: return NULL for for invalid mode input.");
     }
     //Return NULL for invalid unit specification
     {
         output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_RADIAN+1);
-        ok( output == NULL,
-            "psSphereSetOffset:             return NULL for for invalid unit input.");
+        ok( output == NULL, "psSphereSetOffset: return NULL for for invalid unit input.");
     }
     //Test Set using Spherical mode, Degree units
@@ -424,10 +499,7 @@
     {
         output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_DEGREE);
-        skip_start(  output == NULL, 2,
-                     "Skipping 2 tests because Sphere output is NULL!");
-        is_double(output->r, M_PI/4.0,
-                  "psSphereSetOffset:             return correct spherical offset.");
-        is_double(output->d, M_PI/6.0,
-                  "psSphereSetOffset:             return correct spherical offset.");
+        skip_start(output == NULL, 2, "Skipping 2 tests because Sphere output is NULL!");
+        is_double(output->r, M_PI/4.0, "psSphereSetOffset: return correct spherical offset.");
+        is_double(output->d, M_PI/6.0, "psSphereSetOffset: return correct spherical offset.");
         skip_end();
         psFree(output);
@@ -441,10 +513,9 @@
         output = psSphereSetOffset(origin, offset, PS_LINEAR, PS_RADIAN);
         empty = psSphereGetOffset(origin, output, PS_LINEAR, PS_RADIAN);
-        skip_start(  empty == NULL, 2,
-                     "Skipping 2 tests because Sphere output is NULL!");
+        skip_start(empty == NULL, 2, "Skipping 2 tests because Sphere output is NULL!");
         is_double_tol(empty->r, offset->r, 0.00001,
-                      "psSphereGetOffset:             return correct spherical offset.");
+                      "psSphereGetOffset: return correct spherical offset.");
         is_double_tol(empty->d, offset->d, 0.00001,
-                      "psSphereGetOffset:             return correct spherical offset.");
+                      "psSphereGetOffset: return correct spherical offset.");
         skip_end();
         psFree(output);
@@ -462,10 +533,9 @@
         empty->r = SEC_TO_RAD(empty->r);
         empty->d = SEC_TO_RAD(empty->d);
-        skip_start(  empty == NULL, 2,
-                     "Skipping 2 tests because Sphere output is NULL!");
+        skip_start(empty == NULL, 2, "Skipping 2 tests because Sphere output is NULL!");
         is_double_tol(empty->r, (M_PI / 4.0), 0.0001,
-                      "psSphereGetOffset:             return correct spherical offset.");
+                      "psSphereGetOffset: return correct spherical offset.");
         is_double_tol(empty->d, (M_PI / 6.0), 0.0001,
-                      "psSphereGetOffset:             return correct spherical offset.");
+                      "psSphereGetOffset: return correct spherical offset.");
         skip_end();
         psFree(output);
@@ -481,7 +551,7 @@
         empty = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_RADIAN);
         is_double_tol(empty->r, offset->r, 0.0001,
-                      "psSphereSetOffset:             return correct offset for differing units.");
+                      "psSphereSetOffset: return correct offset for differing units.");
         is_double_tol(empty->d, offset->d, 0.0001,
-                      "psSphereSetOffset:             return correct offset for differing units.");
+                      "psSphereSetOffset: return correct offset for differing units.");
         psFree(output);
         psFree(empty);
@@ -496,3 +566,2 @@
     }
 }
-
Index: trunk/psLib/test/astro/tap_psTime_01.c
===================================================================
--- trunk/psLib/test/astro/tap_psTime_01.c	(revision 13614)
+++ trunk/psLib/test/astro/tap_psTime_01.c	(revision 13623)
@@ -23,6 +23,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-06-04 20:25:32 $
+ *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-06-05 01:10:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -709,4 +709,16 @@
 
     // psTimeFromISO()
+    // Convert valid ISO string
+    {
+        psMemId id = psMemGetId();
+        psTime *time = psTimeFromISO(testTime1Str, PS_TIME_TAI);
+        ok(time->type == PS_TIME_TAI, "psTimeFromISO() returned the correct type");
+        is_long(time->sec, testTime1SecondsUTC, "psTimeFromISO()->sec");
+        psFree(time);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeFromISO()
     // Attempt to convert NULL string
     // Following should generate error message for NULL ISO string");
@@ -714,21 +726,5 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromISO(NULL, PS_TIME_TAI);
-
         ok(time == NULL, "psTimeFromISO(NULL, PS_TIME_TAI) returned NULL");
-
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-
-    // psTimeFromISO()
-    // Convert valid ISO string
-    {
-        psMemId id = psMemGetId();
-        psTime *time = psTimeFromISO(testTime1Str, PS_TIME_TAI);
-
-        ok(time->type == PS_TIME_TAI, "psTimeFromISO() returned the correct type");
-        is_long(time->sec, testTime1SecondsUTC, "psTimeFromISO()->sec");
-
-        psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -742,7 +738,5 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromISO("Here I am", PS_TIME_TAI);
-
         ok(time == NULL, "psTimeFromISO() returned NULL for incorrect ISO string");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -757,7 +751,5 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromTimeval(NULL);
-
         ok(time == NULL, "psTimeFromTimeval(NULL) returned NULL");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -773,6 +765,5 @@
         timevalTime->tv_usec = testTime1NanosecondsTAI / 1000;
         psTime *time = psTimeFromTimeval(timevalTime);
-
-        ok(time != NULL, "psTimeFromTimeval() returned NULL for correct timeval structure");
+        ok(time != NULL, "psTimeFromTimeval() returned non-NULL for correct timeval structure");
         skip_start(time == NULL, 3, "Skipping tests because psTimeFromTimeval() returned NULL");
         ok(time->type == PS_TIME_TAI, "psTimeFromTimeval() returned the correct type");
@@ -780,5 +771,4 @@
         is_long(time->nsec, testTime1NanosecondsTAI, "psTimeFromTimeval() returned the correct ->nsec");
         skip_end();
-
         psFree(timevalTime);
         psFree(time);
@@ -794,7 +784,5 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromTM(NULL);
-
         ok(time == NULL, "psTimeFromTM(NULL) returned NULL");
-
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -802,7 +790,7 @@
 
     // psTimeFromTM()
-    {
-        psMemId id = psMemGetId();
-        // Verify convert for valid tm structure
+    // Verify convert for valid tm structure
+    {
+        psMemId id = psMemGetId();
         struct tm *tmTime = (struct tm*)psAlloc(sizeof(struct tm));
         tmTime->tm_year = testTime7TmYear;
@@ -813,5 +801,4 @@
         tmTime->tm_sec  = testTime7TmSec;
         psTime *time = psTimeFromTM(tmTime);
-
         ok(time != NULL, "psTimeFromTM(NULL) returned non-NULL");
         skip_start(time == NULL, 2, "Skipping tests because psTimeFromTM() returned NULL");
@@ -819,5 +806,4 @@
         is_long(time->nsec, testTime7Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
         skip_end();
-
         psFree(tmTime);
         psFree(time);
@@ -838,5 +824,4 @@
         tmTime->tm_sec  = testTime8TmSec;
         psTime *time = psTimeFromTM(tmTime);
-
         // XXX should test all fields here
         ok(time != NULL, "psTimeFromTM(NULL) returned non-NULL");
@@ -845,5 +830,4 @@
         is_long(time->nsec, testTime8Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
         skip_end();
-
         psFree(tmTime);
         psFree(time);
Index: trunk/psLib/test/astro/tap_psTime_02.c
===================================================================
--- trunk/psLib/test/astro/tap_psTime_02.c	(revision 13614)
+++ trunk/psLib/test/astro/tap_psTime_02.c	(revision 13623)
@@ -12,6 +12,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-06-04 20:25:32 $
+ *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-06-05 01:10:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -332,8 +332,6 @@
     {
         psMemId id = psMemGetId();
-
         psTime *time = psTimeFromTT(0,2e9);
         ok(time == NULL, "psTimeFromTT() returned NULL with incorrect time");
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -345,15 +343,12 @@
     {
         psMemId id = psMemGetId();
-
         psTime *time = psTimeFromTT(testTime1SecondsUTC,testTime1NanosecondsUTC);
         ok(time != NULL, "psTimeFromTT() returned non-NULL with valid time");
         skip_start(time == NULL, 2, "Skipping tests because psTimeFromTT() returned NULL");
-
         ok(time->type == PS_TIME_TT, "psTimeFromTT() returned correct type");
         is_long(time->sec, testTime1SecondsUTC, "psTimeFromTT() returned correct ->sec"); 
         is_long(time->nsec, testTime1NanosecondsUTC, "psTimeFromTT() returned correct ->nsec");
-        is_bool(time->leapsecond, false, "psTimeFromUTC() returned the correct leapsecond flag");
+        is_bool(time->leapsecond, false, "psTimeFromTT() returned the correct leapsecond flag");
         skip_end();
-
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -367,8 +362,6 @@
     {
         psMemId id = psMemGetId();
-
         psTime *time = psTimeFromUTC(0, 2e9, true);
         ok(time == NULL, "psTimeFromUTC() returned NULL with incorrect time input");
-
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -376,5 +369,26 @@
 
     // psTimeFromUTC()
-    // Attempt to create psTime with valid non-leapsecond time and leapsecond flag true
+    // Attempt to create psTime with valid leapsecond time but leapsecond
+    // flag false
+    {
+        psMemId id = psMemGetId();
+
+        psTime *time = psTimeFromUTC(testTime3SecondsUTC, testTime3NanosecondsUTC, false);
+        ok(time != NULL, "psTimeFromUTC() returned non-NULL with correct input");
+        skip_start(time == NULL, 5, "Skipping tests because psTimeFromUTC() returned NULL");
+        ok(time->type == PS_TIME_UTC, "psTimeFromUTC() returned the correct type");
+        is_long(time->sec, testTime3SecondsUTC, "psTimeFromUTC() returned the correct ->sec");
+        is_long(time->nsec, testTime3NanosecondsUTC, "psTimeFromUTC() returned the correct ->nsec");
+        is_bool(time->leapsecond, true, "psTimeFromUTC() returned the correct leapsecond flag");
+        psFree(time);
+        skip_end();
+
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeFromUTC()
+    // Attempt to create psTime with valid non-leapsecond time and
+    // leapsecond flag true
     {
         psMemId id = psMemGetId();
@@ -391,22 +405,3 @@
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
-
-
-    // psTimeFromUTC()
-    // Attempt to create psTime with valid leapsecond time but leapsecond flag false
-    {
-        psMemId id = psMemGetId();
-
-        psTime *time = psTimeFromUTC(testTime3SecondsUTC, testTime3NanosecondsUTC, false);
-        ok(time != NULL, "psTimeFromUTC() returned non-NULL with correct input");
-        skip_start(time == NULL, 5, "Skipping tests because psTimeFromUTC() returned NULL");
-        ok(time->type == PS_TIME_UTC, "psTimeFromUTC() returned the correct type");
-        is_long(time->sec, testTime3SecondsUTC, "psTimeFromUTC() returned the correct ->sec");
-        is_long(time->nsec, testTime3NanosecondsUTC, "psTimeFromUTC() returned the correct ->nsec");
-        is_bool(time->leapsecond, true, "psTimeFromUTC() returned the correct leapsecond flag");
-        psFree(time);
-        skip_end();
-
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
 }
Index: trunk/psLib/test/astro/tap_psTime_03.c
===================================================================
--- trunk/psLib/test/astro/tap_psTime_03.c	(revision 13614)
+++ trunk/psLib/test/astro/tap_psTime_03.c	(revision 13623)
@@ -11,6 +11,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-27 22:52:02 $
+ *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-06-05 01:10:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -179,4 +179,5 @@
     psLibInit("pslib.config");
 
+
     // psTimeMath()
     // Attempt to perform math operation on NULL time
@@ -185,7 +186,5 @@
     {
         psMemId id = psMemGetId();
-
         ok(psTimeMath(NULL, -1.1) == NULL, "psTimeMath(NULL, -1.1) returned NULL");
-
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -201,7 +200,5 @@
         time->sec = 0;
         time->nsec = 2e9;
-
         ok(psTimeMath(time, -1.1) == NULL, "psTimeMath() returns NULL for unallowable time input");
-
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -215,5 +212,4 @@
         time->sec = testTime1SecondsUTC;
         time->nsec = testTime1NanosecondsUTC;
-
         psTime *newTime = psTimeMath(time, deltaTime1);
         ok(newTime != NULL, "psTimeMath() returns non-NULL for allowable time input (PS_TIME_UTC)");
@@ -223,5 +219,4 @@
         is_long(newTime->nsec, newTestTime1NanosecondsUTC, "psTimeMath() returns the correct ->nsec");
         skip_end();
-
         psFree(newTime);
         psFree(time);
