Index: trunk/psLib/test/astronomy/tst_psTime_03.c
===================================================================
--- trunk/psLib/test/astronomy/tst_psTime_03.c	(revision 2704)
+++ trunk/psLib/test/astronomy/tst_psTime_03.c	(revision 2725)
@@ -12,6 +12,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-12-10 02:50:15 $
+ *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-12-16 18:53:28 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -30,34 +30,29 @@
     // Test A - Add two times
     printPositiveTestHeader(stdout, "psTime", "Test A - Add two times");
-    psTime *time1a   = NULL;
-    psTime *time1b   = NULL;
+    psTime *time1a = NULL;
+    psF64 time1b = 1.111111;
     psTime *timeOut1 = NULL;
-    time1a = psTimeAlloc(PS_TIME_UTC);
-    time1b = psTimeAlloc(PS_TIME_UTC);
+    time1a = psTimeAlloc(PS_TIME_TAI);
     time1a->sec  = 1;
     time1a->usec = 111111;
-    time1b->sec  = 1;
-    time1b->usec = 111111;
-    timeOut1 = psTimeAdd(time1a, time1b);
-    PRINT_TIME("Time 1:",time1a);
-    PRINT_TIME("Time 2:",time1b);
-    PRINT_TIME("Output Time:",timeOut1);
+    timeOut1 = psTimeMath(time1a, time1b);
+    if(timeOut1->sec!=2 && timeOut1->usec!=222222) {
+        printf("ERROR: Incorrect time, %lld:%u. Expected 2:222222\n",timeOut1->sec, timeOut1->usec);
+    }
     printFooter(stdout, "psTime", "Test A - Add two times", true);
+
 
     // Test B - Add two times with overflow in microseconds
     printPositiveTestHeader(stdout, "psTime", "Test B - Add two times with overflow in microseconds");
-    psTime *time2a   = NULL;
-    psTime *time2b   = NULL;
+    psTime *time2a = NULL;
+    psF64 time2b = 5.500001;
     psTime *timeOut2 = NULL;
-    time2a = psTimeAlloc(PS_TIME_UTC);
-    time2b = psTimeAlloc(PS_TIME_UTC);
+    time2a = psTimeAlloc(PS_TIME_TAI);
     time2a->sec  = 6;
     time2a->usec = 600001;
-    time2b->sec  = 5;
-    time2b->usec = 500001;
-    timeOut2 = psTimeAdd(time2a, time2b);
-    PRINT_TIME("Time 1:",time2a);
-    PRINT_TIME("Time 2:",time2b);
-    PRINT_TIME("Output Time:",timeOut2);
+    timeOut2 = psTimeMath(time2a, time2b);
+    if(timeOut2->sec!=12 && timeOut2->usec!=100002) {
+        printf("ERROR: Incorrect time, %lld:%u. Expected 12:100002\n",timeOut2->sec, timeOut2->usec);
+    }
     printFooter(stdout, "psTime", "Test B - Add two times with overflow in microseconds", true);
 
@@ -65,17 +60,14 @@
     // Test C - Subtact two times
     printPositiveTestHeader(stdout, "psTime", "Test C - Subtract two times");
-    psTime *time3a   = NULL;
-    psTime *time3b   = NULL;
+    psTime *time3a = NULL;
+    psF64 time3b = -1.111111;
     psTime *timeOut3 = NULL;
-    time3a = psTimeAlloc(PS_TIME_UTC);
-    time3b = psTimeAlloc(PS_TIME_UTC);
+    time3a = psTimeAlloc(PS_TIME_TAI);
     time3a->sec  = 3;
     time3a->usec = 333333;
-    time3b->sec  = 1;
-    time3b->usec = 111111;
-    timeOut3 = psTimeSubtract(time3a, time3b);
-    PRINT_TIME("Time 1:",time3a);
-    PRINT_TIME("Time 2:",time3b);
-    PRINT_TIME("Output Time:",timeOut3);
+    timeOut3 = psTimeMath(time3a, time3b);
+    if(timeOut3->sec!=2 && timeOut3->usec!=222222) {
+        printf("ERROR: Incorrect time, %lld:%u. Expected 2:222222\n",timeOut3->sec, timeOut3->usec);
+    }
     printFooter(stdout, "psTime", "Test C - Subtract two times", true);
 
@@ -83,55 +75,86 @@
     // Test D - Subtact two times with underflow in microseconds
     printPositiveTestHeader(stdout, "psTime", "Test D - Subtact two times with underflow in microseconds");
-    psTime *time4a   = NULL;
-    psTime *time4b   = NULL;
+    psTime *time4a = NULL;
+    psF64 time4b = -2.000003;
     psTime *timeOut4 = NULL;
-    time4a = psTimeAlloc(PS_TIME_UTC);
-    time4b = psTimeAlloc(PS_TIME_UTC);
+    time4a = psTimeAlloc(PS_TIME_TAI);
     time4a->sec  = 5;
     time4a->usec = 1;
-    time4b->sec  = 2;
-    time4b->usec = 3;
-    timeOut4 = psTimeSubtract(time4a, time4b);
-    PRINT_TIME("Time 1:",time4a);
-    PRINT_TIME("Time 2:",time4b);
-    PRINT_TIME("Output Time:",timeOut4);
+    timeOut4 = psTimeMath(time4a, time4b);
+    if(timeOut4->sec!=2 && timeOut4->usec!=999997) {
+        printf("ERROR: Incorrect time, %lld:%u. Expected 2:999997\n",timeOut4->sec, timeOut4->usec);
+    }
     printFooter(stdout, "psTime", "Test D - Subtact two times with underflow in microseconds", true);
+
 
     // Test E - Delta two times
     printPositiveTestHeader(stdout, "psTime", "Test E - Delta two times");
-    psTime *time5a   = NULL;
-    psTime *time5b   = NULL;
-    psTime *timeOut5 = NULL;
-    time5a = psTimeAlloc(PS_TIME_UTC);
-    time5b = psTimeAlloc(PS_TIME_UTC);
-    time5a->sec  = 2;
-    time5a->usec = 1;
-    time5b->sec  = 5;
-    time5b->usec = 3;
+    psTime *time5a = NULL;
+    psTime *time5b = NULL;
+    psF64 timeOut5 = 0.0;
+    time5a = psTimeAlloc(PS_TIME_TAI);
+    time5b = psTimeAlloc(PS_TIME_TAI);
+    time5a->sec  = 8;
+    time5a->usec = 8;
+    time5b->sec  = 7;
+    time5b->usec = 7;
     timeOut5 = psTimeDelta(time5a, time5b);
-    PRINT_TIME("Time 1:",time5a);
-    PRINT_TIME("Time 2:",time5b);
-    PRINT_TIME("Output Time:",timeOut5);
+    if(fabs(timeOut5-1.000001) > FLT_EPSILON) {
+        printf("ERROR: Incorrect delta, %lf. Expected -1.000001\n", timeOut5);
+    }
     printFooter(stdout, "psTime", "Test E - Delta two times", true);
 
 
-    // Test D - Free data
-    printPositiveTestHeader(stdout, "psTime", "Test D - Free data");
+    // Test F - Delta two times with underflow in microseconds
+    printPositiveTestHeader(stdout, "psTime", "Test F - Delta two times with underflow in microseconds");
+    psTime *time6a = NULL;
+    psTime *time6b = NULL;
+    psF64 timeOut6 = 0.0;
+    time6a = psTimeAlloc(PS_TIME_TAI);
+    time6b = psTimeAlloc(PS_TIME_TAI);
+    time6a->sec  = 8;
+    time6a->usec = 1;
+    time6b->sec  = 7;
+    time6b->usec = 7;
+    timeOut6 = psTimeDelta(time6a, time6b);
+    if(fabs(timeOut6-0.999994) > FLT_EPSILON) {
+        printf("ERROR: Incorrect delta, %lf. Expected 0.999994\n", timeOut6);
+    }
+    printFooter(stdout, "psTime", "Test F - Delta two times with underflow in microseconds", true);
+
+
+    // Test G - Add two times across leapsecond boundary
+    printPositiveTestHeader(stdout, "psTime", "Test G - Add two times across leapsecond boundary");
+    psF64 time7b = 30.0;
+    char *out7 = NULL;
+    psTime *time7a = NULL;
+    psTime *timeOut7 = NULL;
+    time7a = psTimeFromISOTime("1998-12-31T23:59:45.00");
+    time7a->type = PS_TIME_UTC;
+    timeOut7 = psTimeMath(time7a, time7b);
+    out7 = psTimeToISOTime(timeOut7);
+    printf("%s\n", out7);
+    printFooter(stdout, "psTime", "Test G - Add two times across leapsecond boundary", true);
+
+
+    // Test G - Free data
+    printPositiveTestHeader(stdout, "psTime", "Test G - Free data");
+    psLibFinalize();
     psFree(time1a);
-    psFree(time1b);
     psFree(timeOut1);
     psFree(time2a);
-    psFree(time2b);
     psFree(timeOut2);
     psFree(time3a);
-    psFree(time3b);
     psFree(timeOut3);
     psFree(time4a);
-    psFree(time4b);
     psFree(timeOut4);
     psFree(time5a);
     psFree(time5b);
-    psFree(timeOut5);
-    if ( psMemCheckLeaks(0, NULL, stdout,false) ) {
+    psFree(time6a);
+    psFree(time6b);
+    psFree(out7);
+    psFree(time7a);
+    psFree(timeOut7);
+    if (psMemCheckLeaks(0, NULL, stdout,false)) {
         psError(PS_ERR_UNKNOWN,true,"Memory leaks detected.");
         return 10;
@@ -142,5 +165,5 @@
         printf("ERROR: Found %d bad memory blocks\n", nBad);
     }
-    printFooter(stdout, "psTime", "Test D - Free data", true);
+    printFooter(stdout, "psTime", "Test G - Free data", true);
     return 0;
 }
Index: trunk/psLib/test/astronomy/tst_psTime_04.c
===================================================================
--- trunk/psLib/test/astronomy/tst_psTime_04.c	(revision 2704)
+++ trunk/psLib/test/astronomy/tst_psTime_04.c	(revision 2725)
@@ -14,6 +14,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-11-22 20:52:45 $
+ *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-12-16 18:53:35 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -29,7 +29,6 @@
     // Test A - Initialize time
     printPositiveTestHeader(stdout, "psTime", "Test A - Initialize time");
-    bool status = true;
-    status = psTimeInit("../../config/psTime.config");
-    psTimeFinalize();
+    psLibInit(true, "../../config/psTime.config");
+    psLibFinalize();
     printFooter(stdout, "psTime", "Test A - Initialize time", true);
 
@@ -38,5 +37,5 @@
     printNegativeTestHeader(stdout,"psTime", "Test B - Attempt to open non-existant time config file",
                             "Failed to open file 'zzz'.  Check if it exists and it has the proper permissions.", 0);
-    status = psTimeInit("zzz");
+    psLibInit(true, "zzz");
     printFooter(stdout, "psTime", "Test B - Attempt to open non-existant time config file", true);
 
@@ -45,6 +44,6 @@
     printNegativeTestHeader(stdout,"psTime", "Test C - Attempt to open non-existant time data files",
                             "Failed to open file 'zzz'.  Check if it exists and it has the proper permissions.", 0);
-    status = psTimeInit("./test.psTime.config1");
-    psTimeFinalize();
+    psLibInit(true, "./test.psTime.config1");
+    psLibFinalize();
     printFooter(stdout, "psTime", "Test C - Attempt to open non-existant time data files", true);
 
@@ -53,6 +52,6 @@
     printNegativeTestHeader(stdout,"psTime", "Test D - Attempt to read incorrect number of files",
                             "Incorrect number of table files entered. Found: 3. Expected: 4.", 0);
-    status = psTimeInit("./test.psTime.config2");
-    psTimeFinalize();
+    psLibInit(true, "./test.psTime.config2");
+    psLibFinalize();
     printFooter(stdout, "psTime", "Test D - Attempt to read incorrect number of files", true);
 
@@ -61,6 +60,6 @@
     printNegativeTestHeader(stdout,"psTime", "Test E - Attempt to read incorrect number of from values",
                             "Incorrect vector size. Size: 3, Expected 4.", 0);
-    status = psTimeInit("./test.psTime.config3");
-    psTimeFinalize();
+    psLibInit(true, "./test.psTime.config3");
+    psLibFinalize();
     printFooter(stdout, "psTime", "Test E - Attempt to read incorrect number of from values", true);
 
@@ -69,6 +68,6 @@
     printNegativeTestHeader(stdout,"psTime", "Test F - Attempt to read data file with typo in number",
                             "Unable to parse string, number on line 16.", 0);
-    status = psTimeInit("./test.psTime.config4");
-    psTimeFinalize();
+    psLibInit(true, "./test.psTime.config4");
+    psLibFinalize();
     printFooter(stdout, "psTime", "Test F - Attempt to read data file with typo in number", true);
 
@@ -76,5 +75,5 @@
     // Test G - Free data
     printPositiveTestHeader(stdout, "psTime", "Test G - Free data");
-    psTimeFinalize();
+    psLibFinalize();
     if( psMemCheckLeaks(0, NULL, stdout,false) != 0 ) {
         psError(PS_ERR_UNKNOWN,true,"Memory leak detected.");
