Changeset 2725 for trunk/psLib/test/astronomy/tst_psTime_03.c
- Timestamp:
- Dec 16, 2004, 8:53:35 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/astronomy/tst_psTime_03.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astronomy/tst_psTime_03.c
r2681 r2725 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-12-1 0 02:50:15$14 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-12-16 18:53:28 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 30 30 // Test A - Add two times 31 31 printPositiveTestHeader(stdout, "psTime", "Test A - Add two times"); 32 psTime *time1a = NULL;33 ps Time *time1b = NULL;32 psTime *time1a = NULL; 33 psF64 time1b = 1.111111; 34 34 psTime *timeOut1 = NULL; 35 time1a = psTimeAlloc(PS_TIME_UTC); 36 time1b = psTimeAlloc(PS_TIME_UTC); 35 time1a = psTimeAlloc(PS_TIME_TAI); 37 36 time1a->sec = 1; 38 37 time1a->usec = 111111; 39 time1b->sec = 1; 40 time1b->usec = 111111; 41 timeOut1 = psTimeAdd(time1a, time1b); 42 PRINT_TIME("Time 1:",time1a); 43 PRINT_TIME("Time 2:",time1b); 44 PRINT_TIME("Output Time:",timeOut1); 38 timeOut1 = psTimeMath(time1a, time1b); 39 if(timeOut1->sec!=2 && timeOut1->usec!=222222) { 40 printf("ERROR: Incorrect time, %lld:%u. Expected 2:222222\n",timeOut1->sec, timeOut1->usec); 41 } 45 42 printFooter(stdout, "psTime", "Test A - Add two times", true); 43 46 44 47 45 // Test B - Add two times with overflow in microseconds 48 46 printPositiveTestHeader(stdout, "psTime", "Test B - Add two times with overflow in microseconds"); 49 psTime *time2a = NULL;50 ps Time *time2b = NULL;47 psTime *time2a = NULL; 48 psF64 time2b = 5.500001; 51 49 psTime *timeOut2 = NULL; 52 time2a = psTimeAlloc(PS_TIME_UTC); 53 time2b = psTimeAlloc(PS_TIME_UTC); 50 time2a = psTimeAlloc(PS_TIME_TAI); 54 51 time2a->sec = 6; 55 52 time2a->usec = 600001; 56 time2b->sec = 5; 57 time2b->usec = 500001; 58 timeOut2 = psTimeAdd(time2a, time2b); 59 PRINT_TIME("Time 1:",time2a); 60 PRINT_TIME("Time 2:",time2b); 61 PRINT_TIME("Output Time:",timeOut2); 53 timeOut2 = psTimeMath(time2a, time2b); 54 if(timeOut2->sec!=12 && timeOut2->usec!=100002) { 55 printf("ERROR: Incorrect time, %lld:%u. Expected 12:100002\n",timeOut2->sec, timeOut2->usec); 56 } 62 57 printFooter(stdout, "psTime", "Test B - Add two times with overflow in microseconds", true); 63 58 … … 65 60 // Test C - Subtact two times 66 61 printPositiveTestHeader(stdout, "psTime", "Test C - Subtract two times"); 67 psTime *time3a = NULL;68 ps Time *time3b = NULL;62 psTime *time3a = NULL; 63 psF64 time3b = -1.111111; 69 64 psTime *timeOut3 = NULL; 70 time3a = psTimeAlloc(PS_TIME_UTC); 71 time3b = psTimeAlloc(PS_TIME_UTC); 65 time3a = psTimeAlloc(PS_TIME_TAI); 72 66 time3a->sec = 3; 73 67 time3a->usec = 333333; 74 time3b->sec = 1; 75 time3b->usec = 111111; 76 timeOut3 = psTimeSubtract(time3a, time3b); 77 PRINT_TIME("Time 1:",time3a); 78 PRINT_TIME("Time 2:",time3b); 79 PRINT_TIME("Output Time:",timeOut3); 68 timeOut3 = psTimeMath(time3a, time3b); 69 if(timeOut3->sec!=2 && timeOut3->usec!=222222) { 70 printf("ERROR: Incorrect time, %lld:%u. Expected 2:222222\n",timeOut3->sec, timeOut3->usec); 71 } 80 72 printFooter(stdout, "psTime", "Test C - Subtract two times", true); 81 73 … … 83 75 // Test D - Subtact two times with underflow in microseconds 84 76 printPositiveTestHeader(stdout, "psTime", "Test D - Subtact two times with underflow in microseconds"); 85 psTime *time4a = NULL;86 ps Time *time4b = NULL;77 psTime *time4a = NULL; 78 psF64 time4b = -2.000003; 87 79 psTime *timeOut4 = NULL; 88 time4a = psTimeAlloc(PS_TIME_UTC); 89 time4b = psTimeAlloc(PS_TIME_UTC); 80 time4a = psTimeAlloc(PS_TIME_TAI); 90 81 time4a->sec = 5; 91 82 time4a->usec = 1; 92 time4b->sec = 2; 93 time4b->usec = 3; 94 timeOut4 = psTimeSubtract(time4a, time4b); 95 PRINT_TIME("Time 1:",time4a); 96 PRINT_TIME("Time 2:",time4b); 97 PRINT_TIME("Output Time:",timeOut4); 83 timeOut4 = psTimeMath(time4a, time4b); 84 if(timeOut4->sec!=2 && timeOut4->usec!=999997) { 85 printf("ERROR: Incorrect time, %lld:%u. Expected 2:999997\n",timeOut4->sec, timeOut4->usec); 86 } 98 87 printFooter(stdout, "psTime", "Test D - Subtact two times with underflow in microseconds", true); 88 99 89 100 90 // Test E - Delta two times 101 91 printPositiveTestHeader(stdout, "psTime", "Test E - Delta two times"); 102 psTime *time5a = NULL;103 psTime *time5b = NULL;104 ps Time *timeOut5 = NULL;105 time5a = psTimeAlloc(PS_TIME_ UTC);106 time5b = psTimeAlloc(PS_TIME_ UTC);107 time5a->sec = 2;108 time5a->usec = 1;109 time5b->sec = 5;110 time5b->usec = 3;92 psTime *time5a = NULL; 93 psTime *time5b = NULL; 94 psF64 timeOut5 = 0.0; 95 time5a = psTimeAlloc(PS_TIME_TAI); 96 time5b = psTimeAlloc(PS_TIME_TAI); 97 time5a->sec = 8; 98 time5a->usec = 8; 99 time5b->sec = 7; 100 time5b->usec = 7; 111 101 timeOut5 = psTimeDelta(time5a, time5b); 112 PRINT_TIME("Time 1:",time5a);113 PRINT_TIME("Time 2:",time5b);114 PRINT_TIME("Output Time:",timeOut5);102 if(fabs(timeOut5-1.000001) > FLT_EPSILON) { 103 printf("ERROR: Incorrect delta, %lf. Expected -1.000001\n", timeOut5); 104 } 115 105 printFooter(stdout, "psTime", "Test E - Delta two times", true); 116 106 117 107 118 // Test D - Free data 119 printPositiveTestHeader(stdout, "psTime", "Test D - Free data"); 108 // Test F - Delta two times with underflow in microseconds 109 printPositiveTestHeader(stdout, "psTime", "Test F - Delta two times with underflow in microseconds"); 110 psTime *time6a = NULL; 111 psTime *time6b = NULL; 112 psF64 timeOut6 = 0.0; 113 time6a = psTimeAlloc(PS_TIME_TAI); 114 time6b = psTimeAlloc(PS_TIME_TAI); 115 time6a->sec = 8; 116 time6a->usec = 1; 117 time6b->sec = 7; 118 time6b->usec = 7; 119 timeOut6 = psTimeDelta(time6a, time6b); 120 if(fabs(timeOut6-0.999994) > FLT_EPSILON) { 121 printf("ERROR: Incorrect delta, %lf. Expected 0.999994\n", timeOut6); 122 } 123 printFooter(stdout, "psTime", "Test F - Delta two times with underflow in microseconds", true); 124 125 126 // Test G - Add two times across leapsecond boundary 127 printPositiveTestHeader(stdout, "psTime", "Test G - Add two times across leapsecond boundary"); 128 psF64 time7b = 30.0; 129 char *out7 = NULL; 130 psTime *time7a = NULL; 131 psTime *timeOut7 = NULL; 132 time7a = psTimeFromISOTime("1998-12-31T23:59:45.00"); 133 time7a->type = PS_TIME_UTC; 134 timeOut7 = psTimeMath(time7a, time7b); 135 out7 = psTimeToISOTime(timeOut7); 136 printf("%s\n", out7); 137 printFooter(stdout, "psTime", "Test G - Add two times across leapsecond boundary", true); 138 139 140 // Test G - Free data 141 printPositiveTestHeader(stdout, "psTime", "Test G - Free data"); 142 psLibFinalize(); 120 143 psFree(time1a); 121 psFree(time1b);122 144 psFree(timeOut1); 123 145 psFree(time2a); 124 psFree(time2b);125 146 psFree(timeOut2); 126 147 psFree(time3a); 127 psFree(time3b);128 148 psFree(timeOut3); 129 149 psFree(time4a); 130 psFree(time4b);131 150 psFree(timeOut4); 132 151 psFree(time5a); 133 152 psFree(time5b); 134 psFree(timeOut5); 135 if ( psMemCheckLeaks(0, NULL, stdout,false) ) { 153 psFree(time6a); 154 psFree(time6b); 155 psFree(out7); 156 psFree(time7a); 157 psFree(timeOut7); 158 if (psMemCheckLeaks(0, NULL, stdout,false)) { 136 159 psError(PS_ERR_UNKNOWN,true,"Memory leaks detected."); 137 160 return 10; … … 142 165 printf("ERROR: Found %d bad memory blocks\n", nBad); 143 166 } 144 printFooter(stdout, "psTime", "Test D- Free data", true);167 printFooter(stdout, "psTime", "Test G - Free data", true); 145 168 return 0; 146 169 }
Note:
See TracChangeset
for help on using the changeset viewer.
