IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12411


Ignore:
Timestamp:
Mar 12, 2007, 1:19:41 PM (19 years ago)
Author:
jhoblitt
Message:

use ok_[type]() macros where appropriate and split-up large logical ORd tests
enable disabled test
remove stale comments
ws
remove potential double frees

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astro/tap_psTime_01.c

    r12395 r12411  
    2323 *  @author  Eric Van Alst, MHPCC
    2424 *
    25  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    26  *  @date  $Date: 2007-03-10 03:25:48 $
     25 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     26 *  @date  $Date: 2007-03-12 23:19:41 $
    2727 *
    2828 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    131131    psLogSetFormat("HLNM");
    132132    psLogSetLevel(PS_LOG_INFO);
    133     plan_tests(116);
     133    plan_tests(178);
    134134    // Initialize library internal structures
    135135    psLibInit("pslib.config");
     
    228228        time->leapsecond = false;
    229229        psF64 ut1Delta = psTimeGetUT1Delta(time, PS_IERS_A);
    230         ok(fabs(ut1Delta - testTime1UT1DeltaBullA) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin A");
    231         //      diag("ERROR: UT1 Delta %lf not as expected %lf test time 1 bulletin A", ut1Delta, testTime1UT1DeltaBullA);
     230
     231        ok_double_tol(ut1Delta, testTime1UT1DeltaBullA, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin A");
     232
    232233        psFree(time);
    233234        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    242243        time->type = PS_TIME_UTC;
    243244        psF64 ut1Delta = psTimeGetUT1Delta(time, PS_IERS_B);
    244         ok(fabs(ut1Delta - testTime1UT1DeltaBullB) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
    245         //      diag("UT1 Delta %lf not as expected %lf test time 1 bulletin B", ut1Delta, testTime1UT1DeltaBullB);
     245
     246        ok_double_tol(ut1Delta, testTime1UT1DeltaBullB, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
     247
    246248        psFree(time);
    247249        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    259261        time->type = PS_TIME_UTC;
    260262        psF64 ut1Delta = psTimeGetUT1Delta(time,PS_IERS_A);
    261         ok(fabs(ut1Delta - testTime2UT1DeltaBullA) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
    262         //      diag("UT1 Delta %lf not as expected %lf test time 2 bulletin A", ut1Delta, testTime2UT1DeltaBullA);
     263
     264        ok_double_tol(ut1Delta, testTime2UT1DeltaBullA, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
     265
    263266        psFree(time);
    264267        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    276279        time->type = PS_TIME_UTC;
    277280        psF64 ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
    278         ok(fabs(ut1Delta - testTime2UT1DeltaBullB) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
    279         //      diag("UT1 Delta %lf not as expected %lf test time 2 bulletin B", ut1Delta, testTime2UT1DeltaBullB);
     281
     282        ok_double_tol(ut1Delta, testTime2UT1DeltaBullB, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
     283
    280284        psFree(time);
    281285        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    293297        time->type = PS_TIME_UTC;
    294298        psF64 ut1Delta = psTimeGetUT1Delta(time,PS_IERS_A);
    295         ok(fabs(ut1Delta - testTime3UT1DeltaBullA) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
    296         //      diag("UT1 Delta %lf not as expected %lf test time 3 bulletin A", ut1Delta, testTime3UT1DeltaBullA);
     299
     300        ok_double_tol(ut1Delta, testTime3UT1DeltaBullA, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
     301
    297302        psFree(time);
    298303        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    309314        time->type = PS_TIME_UTC;
    310315        psF64 ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
    311         ok(fabs(ut1Delta - testTime3UT1DeltaBullB) < ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
    312         //      diag("UT1 Delta %lf not as expected %lf test time 3 bulletin B", ut1Delta, testTime3UT1DeltaBullB);
     316
     317        ok_double_tol(ut1Delta, testTime3UT1DeltaBullB, ERROR_TOL, "psTimeGetUT1Delta() produced the correct result: bulletin B");
     318
    313319        psFree(time);
    314320        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    354360        time->nsec = testTime1NanosecondsUTC;
    355361        psF64 mjd = psTimeToMJD(time);
    356         ok(fabs(mjd - 53207.765929) < ERROR_TOL, "psTimeToMJD() returned correct time after 1/1/1970 epoch");
    357         //      diag("Expected MJD = %lf not as expected %lf", mjd, testTime1MJD);
     362
     363        ok_double_tol(mjd, 53207.765929, ERROR_TOL, "psTimeToMJD() returned correct time after 1/1/1970 epoch");
     364
    358365        psFree(time);
    359366        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    368375        time->nsec = testTime4NanosecondsUTC;
    369376        psF64 mjd = psTimeToMJD(time);
    370         ok(fabs(mjd - testTime4MJD) < ERROR_TOL, "psTimeToMJD() returned correct time before 1/1/1970 epoch");
    371         //      diag("Expected MJD = %lf not as expected %lf", mjd, testTime4MJD);
     377
     378        ok_double_tol(mjd, testTime4MJD, ERROR_TOL, "psTimeToMJD() returned correct time before 1/1/1970 epoch");
     379
    372380        psFree(time);
    373381        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    382390        psMemId id = psMemGetId();
    383391        psF64 jd = psTimeToJD(NULL);
     392
    384393        ok(isnan(jd), "psTimeToJD(NULL) returned NULL");
    385394        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    397406        time->leapsecond = false;
    398407        psF64 jd = psTimeToJD(time);
     408       
    399409        ok(isnan(jd), "psTimeToJD() returned NAN for incorrect time");
     410
    400411        psFree(time);
    401412        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    411422        time->nsec = testTime1NanosecondsUTC;
    412423        psF64 jd = psTimeToJD(time);
    413         ok(fabs(jd - 2453208.265929) < ERROR_TOL, "psTimeToJD() returned the correct time after 1/1/1970 epoch");
     424
     425        ok_double_tol(jd, 2453208.265929, ERROR_TOL, "psTimeToJD() returned the correct time after 1/1/1970 epoch");
     426
    414427        psFree(time);
    415428        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    425438        time->nsec = testTime4NanosecondsUTC;
    426439        psF64 jd = psTimeToJD(time);
    427         ok(fabs(jd - testTime4JD) < ERROR_TOL, "psTimeToJD() returned the correct time before 1/1/1970 epoch");
     440
     441        ok_double_tol(jd, testTime4JD, ERROR_TOL, "psTimeToJD() returned the correct time before 1/1/1970 epoch");
     442
    428443        psFree(time);
    429444        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    438453        psMemId id = psMemGetId();
    439454        char *timeStr = psTimeToISO(NULL);
     455
    440456        ok(timeStr == NULL, "psTimeToISO(NULL) returned NULL");
     457
    441458        psFree(timeStr);
    442459        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    454471        time->nsec = 2e9;
    455472        char *timeStr = psTimeToISO(time);
     473
    456474        ok(timeStr == NULL, "psTimeToISO(time) returned NULL for incorrect time");
     475
    457476        psFree(time);
    458477        psFree(timeStr);
     
    471490        time->nsec = testTime5NanosecondsUTC;
    472491        char *timeStr = psTimeToISO(time);
     492
    473493        ok(timeStr == NULL, "psTimeToISO(time) returned NULL for time prior to year 0000");
     494
    474495        psFree(time);
    475496        psFree(timeStr);
     
    506527        time->nsec = testTime1NanosecondsUTC;
    507528        char *timeStr = psTimeToISO(time);
     529
    508530        ok_str(timeStr, testTime1Str, "psTimeToISO(time) returned correct time (no leapsecond)");
     531
    509532        psFree(timeStr);
    510533        psFree(time);
     
    523546        time->leapsecond = true;
    524547        char *timeStr = psTimeToISO(time);
     548
    525549        ok_str(timeStr, testTime1StrLeap, "psTimeToISO(time) returned correct time (with leapsecond)");
     550
    526551        psFree(timeStr);
    527552        psFree(time);
     
    537562        psMemId id = psMemGetId();
    538563        struct timeval *timevalTime = psTimeToTimeval(NULL);
     564
    539565        ok(timevalTime == NULL, "psTimeToTimeval(NULL) returned NULL");
     566
    540567        psFree(timevalTime);
    541568        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    553580        time->nsec = 2e9;
    554581        struct timeval *timevalTime = psTimeToTimeval(time);
     582
    555583        ok(timevalTime == NULL, "psTimeToTimeval() returned NULL for incorrect time");
     584
    556585        psFree(time);
    557586        psFree(timevalTime);
     
    570599        time->nsec = 0;
    571600        struct timeval *timevalTime = psTimeToTimeval(time);
     601
    572602        ok(timevalTime == NULL, "psTimeToTimeval() returned NULL for incorrect time");
     603
    573604        psFree(time);
    574605        psFree(timevalTime);
     
    586617        time->nsec = testTime1NanosecondsUTC;
    587618        struct timeval *timevalTime = psTimeToTimeval(time);
    588         ok(timevalTime->tv_sec == testTime1TimevalSec, "psTimeToTimeval() returned correct time");
    589         //      diag("Timeval seconds %ld not as expectd %ld", timevalTime->tv_sec, testTime1TimevalSec);
    590         ok(timevalTime->tv_usec == testTime1TimevalUsec, "psTimeToTimeval() returned correct time");
    591         //      diag("Timeval useconds %ld not as expected %ld", timevalTime->tv_usec, testTime1TimevalUsec);
     619
     620        is_long(timevalTime->tv_sec, testTime1TimevalSec, "psTimeToTimeval()->tv_sec");
     621        is_long(timevalTime->tv_usec, testTime1TimevalUsec, "psTimeToTimeval()->tv_usec");
     622
    592623        psFree(time);
    593624        psFree(timevalTime);
     
    601632        psMemId id = psMemGetId();
    602633        psTime *time = psTimeFromMJD(testTime1MJDTAI);
     634
    603635        ok(time->type == PS_TIME_TAI, "psTimeFromMJD() returned the correct type");
    604         ok(time->sec == testTime1SecondsTAI, "psTimeFromMJD() returned the correct ->sec");
     636        is_long(time->sec, testTime1SecondsTAI, "psTimeFromMJD()->sec");
     637
    605638        psFree(time);
    606639        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    613646        psMemId id = psMemGetId();
    614647        psTime *time = psTimeFromMJD(testTime4MJD);
     648
    615649        ok(time->type == PS_TIME_TAI, "psTimeFromMJD() returned the correct type");
    616         ok(time->sec == testTime4SecondsUTC, "psTimeFromMJD() returned the correct ->sec");
     650        is_long(time->sec, testTime4SecondsUTC, "psTimeFromMJD()->sec");
     651
    617652        psFree(time);
    618653        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    622657    // Test psTimeFromJD()
    623658    // Attempt to convert valid time to psTime
    624     // XXX: This fails on the type test.  Should it?
    625659    {
    626660        psMemId id = psMemGetId();
    627661        psTime *time = psTimeFromJD(testTime1JDTAI);
     662
    628663        ok(time->type == PS_TIME_TAI, "psTimeFromJD() returned the correct type");
    629         ok(time->sec == testTime1SecondsTAI, "psTimeFromJD() returned the correct ->sec");
     664        is_long(time->sec, testTime1SecondsTAI, "psTimeFromJD()->sec");
     665
    630666        psFree(time);
    631667        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    635671    // Test psTimeFromJD()
    636672    // Attempt to convert valid time before 1970 epoch
    637     // XXX: This fails on the type test.  Should it?
    638673    {
    639674        psMemId id = psMemGetId();
    640675        psTime *time = psTimeFromJD(testTime4JD);
    641         is_int(time->type, PS_TIME_TAI, "psTimeFromJD() returned the correct type");
    642         is_int(time->sec, testTime4SecondsUTC, "psTimeFromJD() returned the correct ->sec");
     676
     677        ok(time->type == PS_TIME_TAI, "psTimeFromJD() returned the correct type");
     678        is_long(time->sec, testTime4SecondsUTC, "psTimeFromJD() returned the correct ->sec");
     679
    643680        psFree(time);
    644681        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    649686    // Attempt to convert NULL string
    650687    // Following should generate error message for NULL ISO string");
    651     // XXX: We don't test whether the error message is generated
    652688    {
    653689        psMemId id = psMemGetId();
    654690        psTime *time = psTimeFromISO(NULL, PS_TIME_TAI);
     691
    655692        ok(time == NULL, "psTimeFromISO(NULL, PS_TIME_TAI) returned NULL");
     693
    656694        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    657695    }
     
    663701        psMemId id = psMemGetId();
    664702        psTime *time = psTimeFromISO(testTime1Str, PS_TIME_TAI);
     703
    665704        ok(time->type == PS_TIME_TAI, "psTimeFromISO() returned the correct type");
    666         ok(time->sec == testTime1SecondsUTC, "psTimeFromISO() returned the correct ->sec");
     705        is_long(time->sec, testTime1SecondsUTC, "psTimeFromISO()->sec");
     706
    667707        psFree(time);
    668708        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    677717        psMemId id = psMemGetId();
    678718        psTime *time = psTimeFromISO("Here I am", PS_TIME_TAI);
     719
    679720        ok(time == NULL, "psTimeFromISO() returned NULL for incorrect ISO string");
     721
    680722        psFree(time);
    681723        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    690732        psMemId id = psMemGetId();
    691733        psTime *time = psTimeFromTimeval(NULL);
     734
    692735        ok(time == NULL, "psTimeFromTimeval(NULL) returned NULL");
     736
    693737        psFree(time);
    694738        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    704748        timevalTime->tv_usec = testTime1NanosecondsTAI / 1000;
    705749        psTime *time = psTimeFromTimeval(timevalTime);
     750
    706751        ok(time != NULL, "psTimeFromTimeval() returned NULL for correct timeval structure");
    707752        skip_start(time == NULL, 3, "Skipping tests because psTimeFromTimeval() returned NULL");
    708753        ok(time->type == PS_TIME_TAI, "psTimeFromTimeval() returned the correct type");
    709         ok(time->sec == testTime1SecondsTAI, "psTimeFromTimeval() returned the correct ->sec");
    710         ok(time->nsec == testTime1NanosecondsTAI, "psTimeFromTimeval() returned the correct ->nsec");
     754        is_long(time->sec, testTime1SecondsTAI, "psTimeFromTimeval() returned the correct ->sec");
     755        is_long(time->nsec, testTime1NanosecondsTAI, "psTimeFromTimeval() returned the correct ->nsec");
    711756        skip_end();
     757
    712758        psFree(timevalTime);
    713759        psFree(time);
     
    723769        psMemId id = psMemGetId();
    724770        psTime *time = psTimeFromTM(NULL);
     771
    725772        ok(time == NULL, "psTimeFromTM(NULL) returned NULL");
     773
    726774        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    727775    }
     
    740788        tmTime->tm_sec  = testTime7TmSec;
    741789        psTime *time = psTimeFromTM(tmTime);
     790
    742791        ok(time != NULL, "psTimeFromTM(NULL) returned non-NULL");
    743792        skip_start(time == NULL, 2, "Skipping tests because psTimeFromTM() returned NULL");
    744         ok(time->sec == testTime7Seconds, "psTimeFromTM() returned the correct ->sec");
    745         ok(time->nsec == testTime7Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
     793        is_long(time->sec, testTime7Seconds, "psTimeFromTM() returned the correct ->sec");
     794        is_long(time->nsec, testTime7Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
    746795        skip_end();
     796
    747797        psFree(tmTime);
    748798        psFree(time);
     
    763813        tmTime->tm_sec  = testTime8TmSec;
    764814        psTime *time = psTimeFromTM(tmTime);
     815
     816        // XXX should test all fields here
    765817        ok(time != NULL, "psTimeFromTM(NULL) returned non-NULL");
    766818        skip_start(time == NULL, 2, "Skipping tests because psTimeFromTM() returned NULL");
    767         ok(time->sec == testTime8Seconds, "psTimeFromTM() returned the correct ->sec");
    768         ok(time->nsec == testTime8Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
     819        is_long(time->sec, testTime8Seconds, "psTimeFromTM() returned the correct ->sec");
     820        is_long(time->nsec, testTime8Nanoseconds, "psTimeFromTM() returned the correct ->nsec");
     821        skip_end();
     822
    769823        psFree(tmTime);
    770824        psFree(time);
    771         skip_end();
    772825        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    773826    }
     
    781834        psMemId id = psMemGetId();
    782835        psTime *time2 = psTimeConvert(NULL, PS_TIME_TAI);
     836
    783837        ok(time2 == NULL, "psTimeConvert(NULL, PS_TIME_TAI) returned NULL");
    784838        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     839
    785840        psFree(time2);
    786841    }
     
    795850        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
    796851        psTime *time2 = psTimeConvert(time1,-100);
     852
    797853        ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
    798         psFree(time1);
    799         psFree(time2);
     854
     855        psFree(time1);
    800856        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    801857    }
     
    810866        time1->type = PS_TIME_UTC;
    811867        psTime *time2 = psTimeConvert(time1,-100);
     868
    812869        ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
    813         psFree(time1);
    814         psFree(time2);
     870
     871        psFree(time1);
    815872        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    816873    }
     
    825882        time1->type = PS_TIME_TT;
    826883        psTime *time2 = psTimeConvert(time1,-100);
     884
    827885        ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL");
    828         psFree(time1);
    829         psFree(time2);
     886
     887        psFree(time1);
    830888        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    831889    }
     
    840898        time1->type = -100;
    841899        psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
     900
    842901        ok(time2 == NULL, "psTimeConvert(time1, PS_TIME_TAI) returned NULL");
    843         psFree(time1);
    844         psFree(time2);
     902
     903        psFree(time1);
    845904        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    846905    }
     
    851910    // Following should generate an error message for incorrect time
    852911    // XXX: We don't test whether the error message is generated
    853     // XXX: This generates memory errors and aborts, so I if'ed it out
    854     if (0) {
     912    {
    855913        psMemId id = psMemGetId();
    856914        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
    857915        time1->nsec = 2e9;
    858         psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
    859         ok(time2 == time1, "psTimeConvert(time1, PS_TIME_TAI) didn't return time1 for incorrect time");
    860         psFree(time1);
    861         psFree(time2);
     916        psTime *time2 = psTimeConvert(time1, PS_TIME_TAI);
     917
     918        ok(time2 == NULL, "psTimeConvert(time1, PS_TIME_TAI) returns NULL for incorrect psTime object");
     919
     920        psFree(time1);
    862921        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    863922    }
     
    866925    // psTimeConvert()
    867926    //Attempt to convert a time to the same type
    868     // XXX: This generates memory errors and aborts, so I if'ed it out
    869     if (0) {
     927    {
    870928        psMemId id = psMemGetId();
    871929        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     
    874932        time1->type = PS_TIME_TAI;
    875933        time1->leapsecond = false;
    876         psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
    877         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
    878         ok((time2->sec == 1) && (time2->nsec == 2) && (time2->type == PS_TIME_TAI) &&
    879            (time2->leapsecond == false), "There were no time member changes when no change expected");
    880         psFree(time1);
    881         psFree(time2);
     934
     935        psTime *time2 = psTimeConvert(time1, PS_TIME_TAI);
     936        ok(time2 == time1, "psTimeConvert(time, ...) returns time for conversion to same type");
     937        is_long(time2->sec, 1, "time->sec");
     938        is_long(time2->nsec, 2, "time->nsec");
     939        ok(time2->type == PS_TIME_TAI, "time->type");
     940        is_bool(time2->leapsecond, false, "time->leapsecond");
     941
     942        psFree(time1);
    882943        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    883944    }
     
    886947    // psTimeConvert()
    887948    // Attempt to convert a UTC time to a TAI
    888     // XXX: This generates memory errors and aborts, so I if'ed it out
    889     if (0) {
    890         psMemId id = psMemGetId();
    891         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     949    {
     950        psMemId id = psMemGetId();
     951        psTime *time1 = psTimeAlloc(PS_TIME_UTC);
    892952        time1->sec = testTime1SecondsUTC;
    893953        time1->nsec = testTime1NanosecondsUTC;
    894         time1->type = PS_TIME_UTC;
    895954        time1->leapsecond = false;
     955
    896956        psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
    897         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
     957        ok(time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");
     958        is_long(time2->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
     959        is_long(time2->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
    898960        ok(time2->type == PS_TIME_TAI, "psTimeConvert() returned the correct type");
    899         ok(time2->sec == testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
    900         ok(time2->nsec == testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
    901         psFree(time1);
    902         psFree(time2);
     961        is_bool(time2->leapsecond, false, "time->leapsecond");
     962
     963        psFree(time1);
    903964        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    904965    }
     
    907968    // psTimeConvert()
    908969    // Attempt to convert a UTC time to a TT
    909     // XXX: This generates memory errors and aborts, so I if'ed it out
    910     if (0) {
    911         psMemId id = psMemGetId();
    912         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     970    {
     971        psMemId id = psMemGetId();
     972        psTime *time1 = psTimeAlloc(PS_TIME_UTC);
    913973        time1->sec = testTime1SecondsUTC;
    914974        time1->nsec = testTime1NanosecondsUTC;
    915         time1->type = PS_TIME_UTC;
    916975        time1->leapsecond = false;
     976
    917977        psTime *time2 = psTimeConvert(time1,PS_TIME_TT);
    918         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
     978        ok(time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");
     979        is_long(time2->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
     980        is_long(time2->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
    919981        ok(time2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");
    920         ok(time2->sec == testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
    921         ok(time2->nsec == testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
    922         psFree(time1);
    923         psFree(time2);
     982        is_bool(time2->leapsecond, false, "time->leapsecond");
     983
     984        psFree(time1);
    924985        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    925986    }
     
    928989    // psTimeConvert()
    929990    // Attempt to convert a UTC time to UT1
    930     // XXX: This generates memory errors and aborts, so I if'ed it out
    931     if (0) {
    932         psMemId id = psMemGetId();
    933         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     991    {
     992        psMemId id = psMemGetId();
     993        psTime *time1 = psTimeAlloc(PS_TIME_UTC);
    934994        time1->sec = testTime1SecondsUTC;
    935995        time1->nsec = testTime1NanosecondsUTC;
    936         time1->type = PS_TIME_UTC;
    937996        time1->leapsecond = false;
     997
    938998        psTime *time2 = psTimeConvert(time1,PS_TIME_UT1);
    939         ok(time1 == time2, "psTimeConvert() returned time for conversion to same type");
     999        ok(time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");
     1000        is_long(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
     1001        is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    9401002        ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
    941         ok(time2->sec == testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
    942         ok(time2->nsec == testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    943         psFree(time1);
    944         psFree(time2);
     1003        is_bool(time2->leapsecond, false, "time->leapsecond");
     1004
     1005        psFree(time1);
    9451006        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    9461007    }
     
    9481009    // psTimeConvert()
    9491010    // Attempt to convert a TAI time to UTC
    950     // XXX: This generates memory errors and aborts, so I if'ed it out
    951     if (0) {
     1011    {
     1012        psMemId id = psMemGetId();
     1013        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     1014        time1->sec = testTime1SecondsTAI;
     1015        time1->nsec = testTime1NanosecondsTAI;
     1016        time1->leapsecond = false;
     1017
     1018        psTime *time2 = psTimeConvert(time1,PS_TIME_UTC);
     1019        ok(time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");
     1020        is_long(time2->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
     1021        is_long(time2->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
     1022        ok(time2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");
     1023        is_bool(time2->leapsecond, false, "time->leapsecond");
     1024
     1025        psFree(time1);
     1026        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     1027    }
     1028
     1029
     1030    // psTimeConvert()
     1031    // Attempt to convert a TAI time to TT
     1032    {
    9521033        psMemId id = psMemGetId();
    9531034        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     
    9561037        time1->type = PS_TIME_TAI;
    9571038        time1->leapsecond = false;
    958         psTime *time2 = psTimeConvert(time1,PS_TIME_UTC);
     1039
     1040        psTime *time2 = psTimeConvert(time1,PS_TIME_TT);
    9591041        ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
    960         ok(time2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");
    961         ok(time2->sec == testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
    962         ok(time2->nsec == testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
    963         psFree(time1);
    964         psFree(time2);
    965         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    966     }
    967 
    968 
    969     // psTimeConvert()
    970     // Attempt to convert a TAI time to TT
    971     // XXX: This generates memory errors and aborts, so I if'ed it out
    972     if (0) {
     1042        is_long(time2->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
     1043        is_long(time2->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
     1044        ok(time2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");
     1045        is_bool(time2->leapsecond, false, "time->leapsecond");
     1046
     1047        psFree(time1);
     1048        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     1049    }
     1050
     1051
     1052    // psTimeConvert()
     1053    // Attempt to convert a TAI time to UT1
     1054    {
    9731055        psMemId id = psMemGetId();
    9741056        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
    9751057        time1->sec = testTime1SecondsTAI;
    9761058        time1->nsec = testTime1NanosecondsTAI;
    977         time1->type = PS_TIME_TAI;
    9781059        time1->leapsecond = false;
    979         psTime *time2 = psTimeConvert(time1,PS_TIME_TT);
    980         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
    981         ok(time2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");
    982         ok(time2->sec == testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
    983         ok(time2->nsec == testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
    984         psFree(time1);
    985         psFree(time2);
    986         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    987     }
    988 
    989 
    990     // psTimeConvert()
    991     // Attempt to convert a TAI time to UT1
    992     // XXX: This generates memory errors and aborts, so I if'ed it out
    993     if (0) {
    994         psMemId id = psMemGetId();
    995         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
    996         time1->sec = testTime1SecondsTAI;
    997         time1->nsec = testTime1NanosecondsTAI;
    998         time1->type = PS_TIME_TAI;
    999         time1->leapsecond = false;
     1060
    10001061        psTime *time2 = psTimeConvert(time1,PS_TIME_UT1);
    10011062        ok(time1 == time2, "psTimeConvert() returned time for conversion to same type");
     1063        is_long(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
     1064        is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    10021065        ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
    1003         ok(time2->sec == testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
    1004         ok(time2->nsec == testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    1005         psFree(time1);
    1006         psFree(time2);
     1066        is_bool(time2->leapsecond, false, "time->leapsecond");
     1067
     1068        psFree(time1);
    10071069        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    10081070    }
     
    10111073    // psTimeConvert()
    10121074    // Attempt to convert a TT time to UTC
    1013     // XXX: This generates memory errors and aborts, so I if'ed it out
    1014     if (0) {
    1015         psMemId id = psMemGetId();
    1016         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     1075    {
     1076        psMemId id = psMemGetId();
     1077        psTime *time1 = psTimeAlloc(PS_TIME_TT);
    10171078        time1->sec = testTime1SecondsTT;
    10181079        time1->nsec = testTime1NanosecondsTT;
    1019         time1->type = PS_TIME_TT;
    10201080        time1->leapsecond = false;
     1081
    10211082        psTime *time2 = psTimeConvert(time1,PS_TIME_UTC);
    10221083        ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
     1084        is_long(time2->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
     1085        is_long(time2->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
    10231086        ok(time2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");
    1024         ok(time2->sec == testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
    1025         ok(time2->nsec == testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
    1026         psFree(time1);
    1027         psFree(time2);
     1087        is_bool(time2->leapsecond, false, "time->leapsecond");
     1088
     1089        psFree(time1);
    10281090        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    10291091    }
     
    10321094    // psTimeConvert()
    10331095    // Attempt to convert a TT time to TAI
    1034     // XXX: This generates memory errors and aborts, so I if'ed it out
    1035     if (0) {
    1036         psMemId id = psMemGetId();
    1037         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     1096    {
     1097        psMemId id = psMemGetId();
     1098        psTime *time1 = psTimeAlloc(PS_TIME_TT);
    10381099        time1->sec = testTime1SecondsTT;
    10391100        time1->nsec = testTime1NanosecondsTT;
    1040         time1->type = PS_TIME_TT;
    10411101        time1->leapsecond = false;
     1102
    10421103        psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
    10431104        ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
     1105        is_long(time2->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
     1106        is_long(time2->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
    10441107        ok(time2->type == PS_TIME_TAI, "psTimeConvert() returned the correct type");
    1045         ok(time2->sec == testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
    1046         ok(time2->nsec == testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
    1047         psFree(time1);
    1048         psFree(time2);
     1108        is_bool(time2->leapsecond, false, "time->leapsecond");
     1109
     1110        psFree(time1);
    10491111        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    10501112    }
     
    10531115    // psTimeConvert()
    10541116    // Attempt to convert a TT time to UT1
    1055     // XXX: This generates memory errors and aborts, so I if'ed it out
    1056     if (0) {
    1057         psMemId id = psMemGetId();
    1058         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     1117    {
     1118        psMemId id = psMemGetId();
     1119        psTime *time1 = psTimeAlloc(PS_TIME_TT);
    10591120        time1->sec = testTime1SecondsTT;
    10601121        time1->nsec = testTime1NanosecondsTT;
    1061         time1->type = PS_TIME_TT;
    10621122        time1->leapsecond = false;
     1123
    10631124        psTime *time2 = psTimeConvert(time1,PS_TIME_UT1);
    10641125        ok(time1 == time2, "psTimeConvert() returned time for conversion to same type");
     1126        is_long(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
     1127        is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    10651128        ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
    1066         ok(time2->sec == testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
    1067         ok(time2->nsec == testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    1068         psFree(time1);
    1069         psFree(time2);
     1129        is_bool(time2->leapsecond, false, "time->leapsecond");
     1130
     1131        psFree(time1);
    10701132        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    10711133    }
     
    10771139    {
    10781140        psMemId id = psMemGetId();
    1079         psTime *time1 = psTimeAlloc(PS_TIME_TAI);
     1141        psTime *time1 = psTimeAlloc(PS_TIME_UT1);
    10801142        time1->sec = 1;
    10811143        time1->nsec = 2;
    1082         time1->type = PS_TIME_UT1;
    10831144        time1->leapsecond = false;
     1145
    10841146        psTime *time2 = psTimeConvert(time1, PS_TIME_UTC);
    10851147        ok(time2 == NULL, "psTimeConvert() returned NULL for conversion from UT1");
Note: See TracChangeset for help on using the changeset viewer.