IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9672


Ignore:
Timestamp:
Oct 19, 2006, 4:36:51 PM (20 years ago)
Author:
drobbin
Message:

Removed unreachable spots in psLookupTable. Added tests to tap_psLookupTable. Added input file for that test.

Location:
trunk/psLib
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psLookupTable.c

    r9538 r9672  
    77*  @author Ross Harman, MHPCC
    88*
    9 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-10-13 21:13:48 $
     9*  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-10-20 02:36:51 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    156156    if(*end != '\0' && !isspace(*end)) {
    157157        *status = PS_PARSE_ERROR_VALUE;
    158     } else if(inString==end) {
    159         *status = PS_PARSE_ERROR_VALUE;
    160     }
    161 
     158    }
     159    /*    else if(inString==end) {
     160            *status = PS_PARSE_ERROR_VALUE;
     161        }
     162    */
    162163    return value;
    163164}
     
    173174    if(*end != '\0' && !isspace(*end)) {
    174175        *status = PS_PARSE_ERROR_VALUE;
    175     } else if(inString==end) {
    176         *status = PS_PARSE_ERROR_VALUE;
    177     }
    178 
     176    }
     177    /*    else if(inString==end) {
     178            *status = PS_PARSE_ERROR_VALUE;
     179        }
     180    */
    179181    return value;
    180182}
     
    190192    if(*end != '\0' && !isspace(*end)) {
    191193        *status = PS_PARSE_ERROR_VALUE;
    192     } else if(inString==end) {
    193         *status = PS_PARSE_ERROR_VALUE;
    194     }
    195 
     194    }
     195    /*    else if(inString==end) {
     196            *status = PS_PARSE_ERROR_VALUE;
     197        }
     198    */
    196199    return value;
    197200}
     
    207210    if(*end != '\0' && !isspace(*end)) {
    208211        *status = PS_PARSE_ERROR_VALUE;
    209     } else if(inString==end) {
    210         *status = PS_PARSE_ERROR_VALUE;
    211     }
    212 
     212    }
     213    /*    else if(inString==end) {
     214            *status = PS_PARSE_ERROR_VALUE;
     215        }
     216    */
    213217    return value;
    214218}
     
    224228
    225229
    226     if(vec == NULL) {
    227         *status = 1;
    228         return;
    229     }
    230 
     230    /*    if(vec == NULL) {
     231            *status = 1;
     232            return;
     233        }
     234    */
    231235    type = vec->type.type;
    232236
     
    242246        break;
    243247    case PS_TYPE_F64:
     248    default:
    244249        vec->data.F64[index] = parseF64(strValue, status);
    245250        break;
    246     default:
    247         *status = PS_PARSE_ERROR_TYPE;
     251        //    default:
     252        //        *status = PS_PARSE_ERROR_TYPE;
    248253    }
    249254
  • trunk/psLib/test/types/tap_psLookupTable_all.c

    r9144 r9672  
    2424int main(void)
    2525{
    26     plan_tests(5);
     26    plan_tests(13);
    2727
    2828    diag("Tests for psLookupTable Functions");
     
    4646        lt = psLookupTableAlloc(NULL, "\%f \%lf \%d \%ld", 10);
    4747        ok( lt == NULL,
    48             "psLookupTableAlloc:     return NULL for NULL filename input.");
     48            "psLookupTableAlloc:            return NULL for NULL filename input.");
    4949    }
    5050    //Return NULL for NULL format input
     
    5252        lt = psLookupTableAlloc("tableF32.dat", NULL, 10);
    5353        ok( lt == NULL,
    54             "psLookupTableAlloc:     return NULL for NULL format input.");
     54            "psLookupTableAlloc:            return NULL for NULL format input.");
    5555    }
    5656    //Return properly allocated lookupTable for valid inputs
     
    5858        lt = psLookupTableAlloc("tableF32.dat", "\%f \%lf \%d \%ld", 10);
    5959        ok( lt != NULL && psMemCheckLookupTable(lt),
    60             "psLookupTableAlloc:     return properly allocated lookupTable for valid inputs.");
     60            "psLookupTableAlloc:            "
     61            "return properly allocated lookupTable for valid inputs.");
    6162    }
    6263
     
    6667        int j = 2;
    6768        ok( !psMemCheckLookupTable(&j),
    68             "psMemCheckLookupTable:  return false for non-LookupTable input.");
     69            "psMemCheckLookupTable:         return false for non-LookupTable input.");
    6970    }
    7071
     
    8081{
    8182    diag("  >>>Test 2:  psVectorsReadFromFile, psLookupTableImport, psLookupTableRead Fxns");
    82 
    83 
     83    psArray *outVec = NULL;
     84    psLookupTable*  table1  = NULL;
     85    long           numRows = 0;
     86    char filename[30];
     87    strcpy(filename, "tableF32.dat");
     88
     89    //Tests for psVectorReadFromFile
     90    // Attempt to read from NULL filename input
     91    {
     92        outVec = psVectorsReadFromFile(NULL,
     93                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
     94        ok( outVec == NULL,
     95            "psVectorsReadFromFile:         return NULL for NULL filename input.");
     96    }
     97    // Attempt to read from NULL format input
     98    {
     99        outVec = psVectorsReadFromFile(filename, NULL);
     100        ok( outVec == NULL,
     101            "psVectorsReadFromFile:         return NULL for NULL format input.");
     102    }
     103    // Attempt to read from invalid filename input
     104    {
     105        outVec = psVectorsReadFromFile("tableS32.dat",
     106                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
     107        ok( outVec == NULL,
     108            "psVectorsReadFromFile:         return NULL for invalid filename input.");
     109    }
     110    // Attempt to read from invalid format input
     111    {
     112        outVec = psVectorsReadFromFile(filename, "\%s");
     113        ok( outVec == NULL,
     114            "psVectorsReadFromFile:         return NULL for invalid format input.");
     115    }
     116
     117    // Attempt to read from table containing missing entry
     118    {
     119        outVec = psVectorsReadFromFile("tableF32_err.dat",
     120                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
     121        ok( outVec == NULL,
     122            "psVectorsReadFromFile:         return NULL for table containing invalid entry.");
     123    }
     124    // Attempt to read from table containing missing entry
     125    {
     126        outVec = psVectorsReadFromFile("tableF32_2.dat",
     127                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
     128        ok( outVec == NULL,
     129            "psVectorsReadFromFile:         return NULL for table containing invalid entry.");
     130    }
     131
     132    //Attempt to read with valid inputs
     133    {
     134        outVec = psVectorsReadFromFile("tableF32.dat",
     135                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
     136        ok( outVec != NULL,
     137            "psVectorsReadFromFile:        return non-NULL array for valid format input.");
     138    }
    84139
    85140    //Tests for psListToArray
     141    //    psLookupTable *lt = NULL;
     142
     143
     144    // Attempt to read table with NULL input table specified
     145    numRows = psLookupTableRead(table1);
     146    {
     147        ok( numRows == 0,
     148            "psLookupTableRead:            return NULL for NULL filename input.");
     149    }
     150    /*
     151    psS32 testLookupTableRead(void)
     152    {
     153
     154    // Set up valid table to read
     155        table1 = psLookupTableAlloc(tableF32_filename,tableF32_format,tableF32_indexCol);
     156    // Read table
     157        numRows = psLookupTableRead(table1);
     158    // Verify return value equals number of lines read
     159        if(numRows != tableF32_size) {
     160            psError(PS_ERR_UNKNOWN,true,"Return value %d not as expected %d",
     161                    numRows,tableF32_size);
     162            return 1;
     163        }
     164    // Verify the members and values in table
     165        if(fabs(table1->validFrom - tableF32_validFrom) > errorTol_psF64) {
     166            psError(PS_ERR_UNKNOWN,true,"Member validFrom = %f not as expected %f",
     167                    table1->validFrom,tableF32_validFrom);
     168            return 2;
     169        }
     170        if(fabs(table1->validTo - tableF32_validTo) > errorTol_psF64) {
     171            psError(PS_ERR_UNKNOWN,true,"Member validTo = %f not as expected %f",
     172                    table1->validTo,tableF32_validTo);
     173            return 3;
     174        }
     175        if(strcmp(table1->filename,tableF32_filename) != 0) {
     176            psError(PS_ERR_UNKNOWN,true,"Member filename %s not as expected %s",
     177                    table1->filename,tableF32_filename);
     178            return 4;
     179        }
     180        if(strcmp(table1->format,tableF32_format) != 0) {
     181            psError(PS_ERR_UNKNOWN,true,"Member format %s not as expected %s",
     182                    table1->format,tableF32_format);
     183            return 5;
     184        }
     185        if(table1->indexCol != tableF32_indexCol) {
     186            psError(PS_ERR_UNKNOWN,true,"Member indexCol %d not as expected %d",
     187                    table1->indexCol,tableF32_indexCol);
     188            return 6;
     189        }
     190        for(psS32 i = 0; i < table1->index->n; i++) {
     191            if(fabs(table1->index->data.F32[i]-tableF32_index[i]) > errorTol_psF64) {
     192                psError(PS_ERR_UNKNOWN,true,"Index column[%d] = %f not as expected %f",
     193                        i,table1->index->data.F32[i],tableF32_index[i]);
     194                return i*7;
     195            }
     196        }
     197        psVector* tempVector = table1->values->data[1];
     198        for(psS32 i = 0; i < tempVector->n; i++) {
     199            if(tempVector->data.S32[i] != tableF32_col1[i]) {
     200                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
     201                        i,tempVector->data.S32[i],tableF32_col1[i]);
     202                return i*8;
     203            }
     204        }
     205        tempVector = table1->values->data[2];
     206        for(psS32 i = 0; i < tempVector->n; i++) {
     207            if(tempVector->data.S32[i] != tableF32_col2[i]) {
     208                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
     209                        i,tempVector->data.S32[i],tableF32_col2[i]);
     210                return i*9;
     211            }
     212        }
     213        tempVector = table1->values->data[3];
     214        for(psS32 i = 0; i < tempVector->n; i++) {
     215            if(tempVector->data.S64[i] != tableF32_col3[i]) {
     216                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %ld not as expected %ld",
     217                        i,tempVector->data.S64[i],tableF32_col3[i]);
     218                return i*10;
     219            }
     220        }
     221        tempVector = table1->values->data[4];
     222        for(psS32 i = 0; i < tempVector->n; i++) {
     223            if(tempVector->data.S32[i] != tableF32_col4[i]) {
     224                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
     225                        i,tempVector->data.S32[i],tableF32_col4[i]);
     226                return i*11;
     227            }
     228        }
     229        tempVector = table1->values->data[5];
     230        for(psS32 i = 0; i < tempVector->n; i++) {
     231            if(tempVector->data.S32[i] != tableF32_col5[i]) {
     232                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
     233                        i,tempVector->data.S32[i],tableF32_col5[i]);
     234                return i*12;
     235            }
     236        }
     237        tempVector = table1->values->data[6];
     238        for(psS32 i = 0; i < tempVector->n; i++) {
     239            if(tempVector->data.S32[i] != tableF32_col6[i]) {
     240                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
     241                        i,tempVector->data.S32[i],tableF32_col6[i]);
     242                return i*13;
     243            }
     244        }
     245        tempVector = table1->values->data[7];
     246        for(psS32 i = 0; i < tempVector->n; i++) {
     247            if(tempVector->data.S64[i] != tableF32_col7[i]) {
     248                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %ld not as expected %ld",
     249                        i,tempVector->data.S64[i],tableF32_col7[i]);
     250                return i*14;
     251            }
     252        }
     253        psFree(table1);
     254
     255    // Set up invalid table to read
     256        table1 = psLookupTableAlloc(tableF32_filename,tableF32_format,tableF32_indexCol);
     257        table1->indexCol = -1;
     258    // Read invalid table
     259        psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message invalid table indexCol");
     260        numRows = psLookupTableRead(table1);
     261    // Verify the num of rows read is zero
     262        if(numRows != 0) {
     263            psError(PS_ERR_UNKNOWN,true,"Did not return 0 for line read for invalid table");
     264            return 15;
     265        }
     266        psFree(table1);
     267
     268        return 0;
     269    }
     270    */
     271
    86272
    87273    //Check for Memory leaks
    88274    {
    89 
     275        psFree(outVec);
     276        psFree(table1);
    90277        checkMem();
    91278    }
Note: See TracChangeset for help on using the changeset viewer.