IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 13, 2004, 12:32:02 PM (22 years ago)
Author:
harman
Message:

Added more tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataIO/tst_psLookupTable_01.c

    r2392 r2706  
    44*
    55*  This test driver contains the following tests for psMetadata:
    6 *     Test A - Read 1st hdr from simple FITS file
    7 *     Test B - Read 2nd hdr from complex FITS file
    8 *     Test C - Read named hdr from complex FITS file
    9 *     Test D - Remove items with same name from all metadata
    10 *     Test E - Attempt to use null file descriptor
    11 *     Test F - Attempt to open nonexistant file
    12 *     Test G - Attempt to use two null inputs
    13 *     Test H - Attempt to use bad extNum
    14 *     Test I - Attempt to use bad extNameTest
    15 *     Test J - Free psMetadataData
     6*     Test A - Read table and interpolate value
     7*     Test B - Read table and interpolate all values
     8*     Test C - Read beyond lower table bound
     9*     Test D - Read beyond upper table bound
     10*     Test E - Free data
    1611*
    1712*  @author  Ross Harman, MHPCC
    1813*
    19 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
    20 *  @date  $Date: 2004-11-22 21:10:52 $
     14*  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
     15*  @date  $Date: 2004-12-13 22:32:02 $
    2116*
    2217*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3227int main(int argc, char* argv[])
    3328{
     29
     30
     31    // Test A - Read table and interpolate value
     32    printPositiveTestHeader(stdout, "psMetadata", "Test A - Read table and interpolate value");
    3433    psLookupStatusType status1 = 0;
    3534    psF64 index1 = 2450905.0;
     
    3736    psLookupTable* table1 = NULL;
    3837
    39     table1 = psLookupTableAlloc("../../data/tai_utc.dat", 0, 0);
     38    table1 = psLookupTableAlloc("../../data/tai_utc.dat", 0, 2451179.6);
    4039    table1 = psLookupTableRead(table1);
    4140    out1 = psLookupTableInterpolate(table1, index1, 0, &status1);
    42     printf("%lf\n", out1);
     41    if(fabs(out1-31.5)>FLT_EPSILON) {
     42        printf("ERROR: Incorrect value, %lf. Expected 31.5\n", out1);
     43    } else if(status1 != PS_LOOKUP_SUCCESS) {
     44        printf("ERROR: Bad return status, %d\n", status1);
     45    }
     46    printFooter(stdout, "psMetadata", "Test A - Read table and interpolate value", true);
    4347
    4448
    45     // Test  - Free psMetadata
    46     printPositiveTestHeader(stdout, "psMetadata", "Test J - Free psMetadata");
     49    // Test B - Read table and interpolate all values
     50    printPositiveTestHeader(stdout, "psMetadata", "Test B - Read table and interpolate all values");
     51    psU64 i = 0;
     52    psF64 index2 = 2450905.0;
     53    psVector *out2 = NULL;
     54    psLookupTable* table2 = NULL;
     55    psVector *stats2 = NULL;
     56    psF64 truthData2[] = {31.5, 41317, 0};
     57
     58    table2 = psLookupTableAlloc("../../data/tai_utc.dat", 0, 2451179.6);
     59    table2 = psLookupTableRead(table2);
     60    stats2 = psVectorAlloc(table2->numCols, PS_TYPE_U32);
     61    out2 = psLookupTableInterpolateAll(table2, index2, stats2);
     62
     63    for(i=0; i<table2->numCols; i++) {
     64        if(fabs(out2->data.F64[i]-truthData2[i])>FLT_EPSILON) {
     65            printf("ERROR: Incorrect value, %lf. Expected %lf\n", out2->data.F64[i], truthData2[i]);
     66        } else if(status1 != PS_LOOKUP_SUCCESS) {
     67            printf("ERROR: Bad return status, %d for column %lld\n", stats2->data.U32[i], i);
     68        }
     69    }
     70    printFooter(stdout, "psMetadata", "Test B - Read table and interpolate all values", true);
     71
     72
     73    // Test C - Read beyond lower table bound
     74    printPositiveTestHeader(stdout, "psMetadata", "Test C - Read beyond lower table bound");
     75    psLookupStatusType status3 = 0;
     76    psF64 index3 = 2451179.7;
     77    psF64 out3 = 0.0;
     78    psLookupTable* table3 = NULL;
     79
     80    table3 = psLookupTableAlloc("../../data/tai_utc.dat", 0, 2451179.6);
     81    table3 = psLookupTableRead(table3);
     82    out3 = psLookupTableInterpolate(table3, index3, 0, &status3);
     83    if(status3 != PS_LOOKUP_PAST_BOTTOM) {
     84        printf("ERROR: Bad return status, %d\n", status3);
     85    }
     86    printFooter(stdout, "psMetadata", "Test C - Read beyond lower table bound", true);
     87
     88    // Test D - Read beyond upper table bound
     89    printPositiveTestHeader(stdout, "psMetadata", "Test D - Read beyond upper table bound");
     90    psLookupStatusType status4 = 0;
     91    psF64 index4 = 0.0;
     92    psF64 out4 = 0.0;
     93    psLookupTable* table4 = NULL;
     94
     95    table4 = psLookupTableAlloc("../../data/tai_utc.dat", 0, 2451179.6);
     96    table4 = psLookupTableRead(table4);
     97    out4 = psLookupTableInterpolate(table4, index4, 0, &status4);
     98    if(status4 != PS_LOOKUP_PAST_TOP) {
     99        printf("ERROR: Bad return status, %d\n", status4);
     100    }
     101    printFooter(stdout, "psMetadata", "Test D - Read beyond upper table bound", true);
     102
     103
     104    // Test E - Free data
     105    printPositiveTestHeader(stdout, "psMetadata", "Test E - Free data");
    47106    psFree(table1);
    48     if ( psMemCheckLeaks(0, NULL, stdout, false) ) {
     107    psFree(table2);
     108    psFree(table3);
     109    psFree(table4);
     110    psFree(out2);
     111    psFree(stats2);
     112    if (psMemCheckLeaks(0, NULL, stdout, false)) {
    49113        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected");
    50114        return 10;
     
    55119        printf("ERROR: Found %d bad memory blocks\n", nBad);
    56120    }
    57     printFooter(stdout, "psMetadata", "Test J - Free psMetadata", true);
    58 
    59 
    60     psU64 i = 0;
    61     psF64 index2 = 2450905.0;
    62     psVector *out2 = NULL;
    63     psLookupTable* table2 = NULL;
    64     psVector *stats2 = NULL;
    65 
    66 
    67     table2 = psLookupTableAlloc("../../data/tai_utc.dat", 0, 0);
    68     table2 = psLookupTableRead(table2);
    69     stats2 = psVectorAlloc(table2->numCols, PS_TYPE_MASK);
    70     out2 = psLookupTableInterpolateAll(table2, index2, stats2);
    71 
    72     for(i=0; i<table2->numCols; i++) {
    73         printf("%lf\n", out2->data.F64[i]);
    74         printf("%d\n", stats2->data.U8[i]);
    75     }
     121    printFooter(stdout, "psMetadata", "Test E - Free data", true);
    76122
    77123
Note: See TracChangeset for help on using the changeset viewer.