Index: trunk/psLib/test/astro/tap_psTime_01.c
===================================================================
--- trunk/psLib/test/astro/tap_psTime_01.c	(revision 12410)
+++ trunk/psLib/test/astro/tap_psTime_01.c	(revision 12411)
@@ -23,6 +23,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-10 03:25:48 $
+ *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-03-12 23:19:41 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -131,5 +131,5 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(116);
+    plan_tests(178);
     // Initialize library internal structures
     psLibInit("pslib.config");
@@ -228,6 +228,7 @@
         time->leapsecond = false;
         psF64 ut1Delta = psTimeGetUT1Delta(time, PS_IERS_A);
-        ok(fabs(ut1Delta - testTime1UT1DeltaBullA) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin A");
-        //      diag("ERROR: UT1 Delta %lf not as expected %lf test time 1 bulletin A", ut1Delta, testTime1UT1DeltaBullA);
+
+        ok_double_tol(ut1Delta, testTime1UT1DeltaBullA, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin A");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -242,6 +243,7 @@
         time->type = PS_TIME_UTC;
         psF64 ut1Delta = psTimeGetUT1Delta(time, PS_IERS_B);
-        ok(fabs(ut1Delta - testTime1UT1DeltaBullB) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
-        //      diag("UT1 Delta %lf not as expected %lf test time 1 bulletin B", ut1Delta, testTime1UT1DeltaBullB);
+
+        ok_double_tol(ut1Delta, testTime1UT1DeltaBullB, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -259,6 +261,7 @@
         time->type = PS_TIME_UTC;
         psF64 ut1Delta = psTimeGetUT1Delta(time,PS_IERS_A);
-        ok(fabs(ut1Delta - testTime2UT1DeltaBullA) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
-        //      diag("UT1 Delta %lf not as expected %lf test time 2 bulletin A", ut1Delta, testTime2UT1DeltaBullA);
+
+        ok_double_tol(ut1Delta, testTime2UT1DeltaBullA, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -276,6 +279,7 @@
         time->type = PS_TIME_UTC;
         psF64 ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
-        ok(fabs(ut1Delta - testTime2UT1DeltaBullB) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
-        //      diag("UT1 Delta %lf not as expected %lf test time 2 bulletin B", ut1Delta, testTime2UT1DeltaBullB);
+
+        ok_double_tol(ut1Delta, testTime2UT1DeltaBullB, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -293,6 +297,7 @@
         time->type = PS_TIME_UTC;
         psF64 ut1Delta = psTimeGetUT1Delta(time,PS_IERS_A);
-        ok(fabs(ut1Delta - testTime3UT1DeltaBullA) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
-        //      diag("UT1 Delta %lf not as expected %lf test time 3 bulletin A", ut1Delta, testTime3UT1DeltaBullA);
+
+        ok_double_tol(ut1Delta, testTime3UT1DeltaBullA, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -309,6 +314,7 @@
         time->type = PS_TIME_UTC;
         psF64 ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
-        ok(fabs(ut1Delta - testTime3UT1DeltaBullB) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
-        //      diag("UT1 Delta %lf not as expected %lf test time 3 bulletin B", ut1Delta, testTime3UT1DeltaBullB);
+
+        ok_double_tol(ut1Delta, testTime3UT1DeltaBullB, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -354,6 +360,7 @@
         time->nsec = testTime1NanosecondsUTC;
         psF64 mjd = psTimeToMJD(time);
-        ok(fabs(mjd - 53207.765929) < ERROR_TOL, "psTimeToMJD() returned correct time after 1/1/1970 epoch");
-        //      diag("Expected MJD = %lf not as expected %lf", mjd, testTime1MJD);
+
+        ok_double_tol(mjd, 53207.765929, ERROR_TOL, "psTimeToMJD() returned correct time after 1/1/1970 epoch");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -368,6 +375,7 @@
         time->nsec = testTime4NanosecondsUTC;
         psF64 mjd = psTimeToMJD(time);
-        ok(fabs(mjd - testTime4MJD) < ERROR_TOL, "psTimeToMJD() returned correct time before 1/1/1970 epoch");
-        //      diag("Expected MJD = %lf not as expected %lf", mjd, testTime4MJD);
+
+        ok_double_tol(mjd, testTime4MJD, ERROR_TOL, "psTimeToMJD() returned correct time before 1/1/1970 epoch");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -382,4 +390,5 @@
         psMemId id = psMemGetId();
         psF64 jd = psTimeToJD(NULL);
+
         ok(isnan(jd), "psTimeToJD(NULL) returned NULL");
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -397,5 +406,7 @@
         time->leapsecond = false;
         psF64 jd = psTimeToJD(time);
+        
         ok(isnan(jd), "psTimeToJD() returned NAN for incorrect time");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -411,5 +422,7 @@
         time->nsec = testTime1NanosecondsUTC;
         psF64 jd = psTimeToJD(time);
-        ok(fabs(jd - 2453208.265929) < ERROR_TOL, "psTimeToJD() returned the correct time after 1/1/1970 epoch");
+
+        ok_double_tol(jd, 2453208.265929, ERROR_TOL, "psTimeToJD() returned the correct time after 1/1/1970 epoch");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -425,5 +438,7 @@
         time->nsec = testTime4NanosecondsUTC;
         psF64 jd = psTimeToJD(time);
-        ok(fabs(jd - testTime4JD) < ERROR_TOL, "psTimeToJD() returned the correct time before 1/1/1970 epoch");
+
+        ok_double_tol(jd, testTime4JD, ERROR_TOL, "psTimeToJD() returned the correct time before 1/1/1970 epoch");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -438,5 +453,7 @@
         psMemId id = psMemGetId();
         char *timeStr = psTimeToISO(NULL);
+
         ok(timeStr == NULL, "psTimeToISO(NULL) returned NULL");
+
         psFree(timeStr);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -454,5 +471,7 @@
         time->nsec = 2e9;
         char *timeStr = psTimeToISO(time);
+
         ok(timeStr == NULL, "psTimeToISO(time) returned NULL for incorrect time");
+
         psFree(time);
         psFree(timeStr);
@@ -471,5 +490,7 @@
         time->nsec = testTime5NanosecondsUTC;
         char *timeStr = psTimeToISO(time);
+
         ok(timeStr == NULL, "psTimeToISO(time) returned NULL for time prior to year 0000");
+
         psFree(time);
         psFree(timeStr);
@@ -506,5 +527,7 @@
         time->nsec = testTime1NanosecondsUTC;
         char *timeStr = psTimeToISO(time);
+
         ok_str(timeStr, testTime1Str, "psTimeToISO(time) returned correct time (no leapsecond)");
+
         psFree(timeStr);
         psFree(time);
@@ -523,5 +546,7 @@
         time->leapsecond = true;
         char *timeStr = psTimeToISO(time);
+
         ok_str(timeStr, testTime1StrLeap, "psTimeToISO(time) returned correct time (with leapsecond)");
+
         psFree(timeStr);
         psFree(time);
@@ -537,5 +562,7 @@
         psMemId id = psMemGetId();
         struct timeval *timevalTime = psTimeToTimeval(NULL);
+
         ok(timevalTime == NULL, "psTimeToTimeval(NULL) returned NULL");
+
         psFree(timevalTime);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -553,5 +580,7 @@
         time->nsec = 2e9;
         struct timeval *timevalTime = psTimeToTimeval(time);
+
         ok(timevalTime == NULL, "psTimeToTimeval() returned NULL for incorrect time");
+
         psFree(time);
         psFree(timevalTime);
@@ -570,5 +599,7 @@
         time->nsec = 0;
         struct timeval *timevalTime = psTimeToTimeval(time);
+
         ok(timevalTime == NULL, "psTimeToTimeval() returned NULL for incorrect time");
+
         psFree(time);
         psFree(timevalTime);
@@ -586,8 +617,8 @@
         time->nsec = testTime1NanosecondsUTC;
         struct timeval *timevalTime = psTimeToTimeval(time);
-        ok(timevalTime->tv_sec == testTime1TimevalSec, "psTimeToTimeval() returned correct time");
-        //      diag("Timeval seconds %ld not as expectd %ld", timevalTime->tv_sec, testTime1TimevalSec);
-        ok(timevalTime->tv_usec == testTime1TimevalUsec, "psTimeToTimeval() returned correct time");
-        //      diag("Timeval useconds %ld not as expected %ld", timevalTime->tv_usec, testTime1TimevalUsec);
+
+        is_long(timevalTime->tv_sec, testTime1TimevalSec, "psTimeToTimeval()->tv_sec");
+        is_long(timevalTime->tv_usec, testTime1TimevalUsec, "psTimeToTimeval()->tv_usec");
+
         psFree(time);
         psFree(timevalTime);
@@ -601,6 +632,8 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromMJD(testTime1MJDTAI);
+
         ok(time->type == PS_TIME_TAI, "psTimeFromMJD() returned the correct type");
-        ok(time->sec == testTime1SecondsTAI, "psTimeFromMJD() returned the correct ->sec");
+        is_long(time->sec, testTime1SecondsTAI, "psTimeFromMJD()->sec");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -613,6 +646,8 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromMJD(testTime4MJD);
+
         ok(time->type == PS_TIME_TAI, "psTimeFromMJD() returned the correct type");
-        ok(time->sec == testTime4SecondsUTC, "psTimeFromMJD() returned the correct ->sec");
+        is_long(time->sec, testTime4SecondsUTC, "psTimeFromMJD()->sec");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -622,10 +657,11 @@
     // Test psTimeFromJD()
     // Attempt to convert valid time to psTime
-    // XXX: This fails on the type test.  Should it?
     {
         psMemId id = psMemGetId();
         psTime *time = psTimeFromJD(testTime1JDTAI);
+
         ok(time->type == PS_TIME_TAI, "psTimeFromJD() returned the correct type");
-        ok(time->sec == testTime1SecondsTAI, "psTimeFromJD() returned the correct ->sec");
+        is_long(time->sec, testTime1SecondsTAI, "psTimeFromJD()->sec");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -635,10 +671,11 @@
     // Test psTimeFromJD()
     // Attempt to convert valid time before 1970 epoch
-    // XXX: This fails on the type test.  Should it?
     {
         psMemId id = psMemGetId();
         psTime *time = psTimeFromJD(testTime4JD);
-        is_int(time->type, PS_TIME_TAI, "psTimeFromJD() returned the correct type");
-        is_int(time->sec, testTime4SecondsUTC, "psTimeFromJD() returned the correct ->sec");
+
+        ok(time->type == PS_TIME_TAI, "psTimeFromJD() returned the correct type");
+        is_long(time->sec, testTime4SecondsUTC, "psTimeFromJD() returned the correct ->sec");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -649,9 +686,10 @@
     // Attempt to convert NULL string
     // Following should generate error message for NULL ISO string");
-    // XXX: We don't test whether the error message is generated
     {
         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");
     }
@@ -663,6 +701,8 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromISO(testTime1Str, PS_TIME_TAI);
+
         ok(time->type == PS_TIME_TAI, "psTimeFromISO() returned the correct type");
-        ok(time->sec == testTime1SecondsUTC, "psTimeFromISO() returned the correct ->sec");
+        is_long(time->sec, testTime1SecondsUTC, "psTimeFromISO()->sec");
+
         psFree(time);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -677,5 +717,7 @@
         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");
@@ -690,5 +732,7 @@
         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");
@@ -704,10 +748,12 @@
         timevalTime->tv_usec = testTime1NanosecondsTAI / 1000;
         psTime *time = psTimeFromTimeval(timevalTime);
+
         ok(time != NULL, "psTimeFromTimeval() returned 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");
-        ok(time->sec == testTime1SecondsTAI, "psTimeFromTimeval() returned the correct ->sec");
-        ok(time->nsec == testTime1NanosecondsTAI, "psTimeFromTimeval() returned the correct ->nsec");
+        is_long(time->sec, testTime1SecondsTAI, "psTimeFromTimeval() returned the correct ->sec");
+        is_long(time->nsec, testTime1NanosecondsTAI, "psTimeFromTimeval() returned the correct ->nsec");
         skip_end();
+
         psFree(timevalTime);
         psFree(time);
@@ -723,5 +769,7 @@
         psMemId id = psMemGetId();
         psTime *time = psTimeFromTM(NULL);
+
         ok(time == NULL, "psTimeFromTM(NULL) returned NULL");
+
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -740,9 +788,11 @@
         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");
-        ok(time->sec == testTime7Seconds, "psTimeFromTM() returned the correct ->sec");
-        ok(time->nsec == testTime7Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
+        is_long(time->sec, testTime7Seconds, "psTimeFromTM() returned the correct ->sec");
+        is_long(time->nsec, testTime7Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
         skip_end();
+
         psFree(tmTime);
         psFree(time);
@@ -763,11 +813,14 @@
         tmTime->tm_sec  = testTime8TmSec;
         psTime *time = psTimeFromTM(tmTime);
+
+        // XXX should test all fields here
         ok(time != NULL, "psTimeFromTM(NULL) returned non-NULL");
         skip_start(time == NULL, 2, "Skipping tests because psTimeFromTM() returned NULL");
-        ok(time->sec == testTime8Seconds, "psTimeFromTM() returned the correct ->sec");
-        ok(time->nsec == testTime8Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
+        is_long(time->sec, testTime8Seconds, "psTimeFromTM() returned the correct ->sec");
+        is_long(time->nsec, testTime8Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
+        skip_end();
+
         psFree(tmTime);
         psFree(time);
-        skip_end();
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -781,6 +834,8 @@
         psMemId id = psMemGetId();
         psTime *time2 = psTimeConvert(NULL, PS_TIME_TAI);
+
         ok(time2 == NULL, "psTimeConvert(NULL, PS_TIME_TAI) returned NULL");
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+
         psFree(time2);
     }
@@ -795,7 +850,8 @@
         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
         psTime *time2 = psTimeConvert(time1,-100);
+
         ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
-        psFree(time1);
-        psFree(time2);
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -810,7 +866,8 @@
         time1->type = PS_TIME_UTC;
         psTime *time2 = psTimeConvert(time1,-100);
+
         ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
-        psFree(time1);
-        psFree(time2);
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -825,7 +882,8 @@
         time1->type = PS_TIME_TT;
         psTime *time2 = psTimeConvert(time1,-100);
+
         ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
-        psFree(time1);
-        psFree(time2);
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -840,7 +898,8 @@
         time1->type = -100;
         psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
+
         ok(time2 == NULL, "psTimeConvert(time1, PS_TIME_TAI) returned NULL");
-        psFree(time1);
-        psFree(time2);
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -851,13 +910,13 @@
     // Following should generate an error message for incorrect time
     // XXX: We don't test whether the error message is generated
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
+    {
         psMemId id = psMemGetId();
         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
         time1->nsec = 2e9;
-        psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
-        ok(time2 == time1, "psTimeConvert(time1, PS_TIME_TAI) didn't return time1 for incorrect time");
-        psFree(time1);
-        psFree(time2);
+        psTime *time2 = psTimeConvert(time1, PS_TIME_TAI);
+
+        ok(time2 == NULL, "psTimeConvert(time1, PS_TIME_TAI) returns NULL for incorrect psTime object");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -866,6 +925,5 @@
     // psTimeConvert()
     //Attempt to convert a time to the same type
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
+    {
         psMemId id = psMemGetId();
         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
@@ -874,10 +932,13 @@
         time1->type = PS_TIME_TAI;
         time1->leapsecond = false;
-        psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
-        ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
-        ok((time2->sec == 1) && (time2->nsec == 2) && (time2->type == PS_TIME_TAI) &&
-           (time2->leapsecond == false), "There were no time member changes when no change expected");
-        psFree(time1);
-        psFree(time2);
+
+        psTime *time2 = psTimeConvert(time1, PS_TIME_TAI);
+        ok(time2 == time1, "psTimeConvert(time, ...) returns time for conversion to same type");
+        is_long(time2->sec, 1, "time->sec");
+        is_long(time2->nsec, 2, "time->nsec");
+        ok(time2->type == PS_TIME_TAI, "time->type");
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -886,19 +947,19 @@
     // psTimeConvert()
     // Attempt to convert a UTC time to a TAI
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_UTC);
         time1->sec = testTime1SecondsUTC;
         time1->nsec = testTime1NanosecondsUTC;
-        time1->type = PS_TIME_UTC;
         time1->leapsecond = false;
+
         psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
-        ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
+        ok(time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");
+        is_long(time2->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
         ok(time2->type == PS_TIME_TAI, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -907,19 +968,19 @@
     // psTimeConvert()
     // Attempt to convert a UTC time to a TT
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_UTC);
         time1->sec = testTime1SecondsUTC;
         time1->nsec = testTime1NanosecondsUTC;
-        time1->type = PS_TIME_UTC;
         time1->leapsecond = false;
+
         psTime *time2 = psTimeConvert(time1,PS_TIME_TT);
-        ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
+        ok(time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");
+        is_long(time2->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
         ok(time2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -928,19 +989,19 @@
     // psTimeConvert()
     // Attempt to convert a UTC time to UT1
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_UTC);
         time1->sec = testTime1SecondsUTC;
         time1->nsec = testTime1NanosecondsUTC;
-        time1->type = PS_TIME_UTC;
         time1->leapsecond = false;
+
         psTime *time2 = psTimeConvert(time1,PS_TIME_UT1);
-        ok(time1 == time2, "psTimeConvert() returned time for conversion to same type");
+        ok(time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");
+        is_long(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
         ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -948,6 +1009,26 @@
     // psTimeConvert()
     // Attempt to convert a TAI time to UTC
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
+        time1->sec = testTime1SecondsTAI;
+        time1->nsec = testTime1NanosecondsTAI;
+        time1->leapsecond = false;
+
+        psTime *time2 = psTimeConvert(time1,PS_TIME_UTC);
+        ok(time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");
+        is_long(time2->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
+        ok(time2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeConvert()
+    // Attempt to convert a TAI time to TT
+    {
         psMemId id = psMemGetId();
         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
@@ -956,53 +1037,34 @@
         time1->type = PS_TIME_TAI;
         time1->leapsecond = false;
-        psTime *time2 = psTimeConvert(time1,PS_TIME_UTC);
+
+        psTime *time2 = psTimeConvert(time1,PS_TIME_TT);
         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
-        ok(time2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-
-    // psTimeConvert()
-    // Attempt to convert a TAI time to TT
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
+        is_long(time2->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
+        ok(time2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psTimeConvert()
+    // Attempt to convert a TAI time to UT1
+    {
         psMemId id = psMemGetId();
         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
         time1->sec = testTime1SecondsTAI;
         time1->nsec = testTime1NanosecondsTAI;
-        time1->type = PS_TIME_TAI;
         time1->leapsecond = false;
-        psTime *time2 = psTimeConvert(time1,PS_TIME_TT);
-        ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
-        ok(time2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
-        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
-    }
-
-
-    // psTimeConvert()
-    // Attempt to convert a TAI time to UT1
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
-        time1->sec = testTime1SecondsTAI;
-        time1->nsec = testTime1NanosecondsTAI;
-        time1->type = PS_TIME_TAI;
-        time1->leapsecond = false;
+
         psTime *time2 = psTimeConvert(time1,PS_TIME_UT1);
         ok(time1 == time2, "psTimeConvert() returned time for conversion to same type");
+        is_long(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
         ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -1011,19 +1073,19 @@
     // psTimeConvert()
     // Attempt to convert a TT time to UTC
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_TT);
         time1->sec = testTime1SecondsTT;
         time1->nsec = testTime1NanosecondsTT;
-        time1->type = PS_TIME_TT;
         time1->leapsecond = false;
+
         psTime *time2 = psTimeConvert(time1,PS_TIME_UTC);
         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
+        is_long(time2->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
         ok(time2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -1032,19 +1094,19 @@
     // psTimeConvert()
     // Attempt to convert a TT time to TAI
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_TT);
         time1->sec = testTime1SecondsTT;
         time1->nsec = testTime1NanosecondsTT;
-        time1->type = PS_TIME_TT;
         time1->leapsecond = false;
+
         psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
+        is_long(time2->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
         ok(time2->type == PS_TIME_TAI, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -1053,19 +1115,19 @@
     // psTimeConvert()
     // Attempt to convert a TT time to UT1
-    // XXX: This generates memory errors and aborts, so I if'ed it out
-    if (0) {
-        psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
+    {
+        psMemId id = psMemGetId();
+        psTime *time1 = psTimeAlloc(PS_TIME_TT);
         time1->sec = testTime1SecondsTT;
         time1->nsec = testTime1NanosecondsTT;
-        time1->type = PS_TIME_TT;
         time1->leapsecond = false;
+
         psTime *time2 = psTimeConvert(time1,PS_TIME_UT1);
         ok(time1 == time2, "psTimeConvert() returned time for conversion to same type");
+        is_long(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
+        is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
         ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
-        ok(time2->sec == testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
-        ok(time2->nsec == testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
-        psFree(time1);
-        psFree(time2);
+        is_bool(time2->leapsecond, false, "time->leapsecond");
+
+        psFree(time1);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
@@ -1077,9 +1139,9 @@
     {
         psMemId id = psMemGetId();
-        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
+        psTime *time1 = psTimeAlloc(PS_TIME_UT1);
         time1->sec = 1;
         time1->nsec = 2;
-        time1->type = PS_TIME_UT1;
         time1->leapsecond = false;
+
         psTime *time2 = psTimeConvert(time1, PS_TIME_UTC);
         ok(time2 == NULL, "psTimeConvert() returned NULL for conversion from UT1");
