Index: trunk/psLib/test/types/table.dat
===================================================================
--- trunk/psLib/test/types/table.dat	(revision 9714)
+++ trunk/psLib/test/types/table.dat	(revision 9714)
@@ -0,0 +1,9 @@
+#  Table with valid types and index-values
+#
+#psF32     psU16    psU32     psU64    psS8    psS16    psS32    psS64    psU8   psF64
+-10.05    2        4         8        0       -2       -4       -8       5      -1.5
+ 1.009     4        8         16       -1      -4       -8       -16      0      -1.0
+23.45     6        12        24       -2      -6       -12      -24      5      -0.25
+3500.67   8        16        32       -3      -8       -16      -32      75     1.75
+   
+#
Index: trunk/psLib/test/types/table2.dat
===================================================================
--- trunk/psLib/test/types/table2.dat	(revision 9714)
+++ trunk/psLib/test/types/table2.dat	(revision 9714)
@@ -0,0 +1,9 @@
+#  Table with valid types and index-values
+#
+#psF32     psU16    psU32     psU64    psS8    psS16    psS32    psS64    psU8   psF64
+-10.05    2        4         8        0       -2        1       -8       5      -1.5
+ 1e-20     4        8         16       -1      -4       1       -16      0      -1.0
+2e-20     6        12        24       -2      -6        1       -24      5      -0.25
+3500.67   8        16        32       -3      -8        1      -32      75     1.75
+
+#
Index: trunk/psLib/test/types/tableF32.dat
===================================================================
--- trunk/psLib/test/types/tableF32.dat	(revision 9672)
+++ 	(revision )
@@ -1,9 +1,0 @@
-#  Table with valid types and index-values
-#
-#psF32     psU16    psU32     psU64    psS8    psS16    psS32    psS64    psU8   psF64
--10.05    2        4         8        0       -2       -4       -8       5      -1.5
- 1.009     4        8         16       -1      -4       -8       -16      0      -1.0
-23.45     6        12        24       -2      -6       -12      -24      5      -0.25
-3500.67   8        16        32       -3      -8       -16      -32      75     1.75
-   
-#
Index: trunk/psLib/test/types/tableF32_err.dat
===================================================================
--- trunk/psLib/test/types/tableF32_err.dat	(revision 9714)
+++ trunk/psLib/test/types/tableF32_err.dat	(revision 9714)
@@ -0,0 +1,9 @@
+#  Table with valid types and index-values
+#
+#psF32     psU16    psU32     psU64    psS8    psS16    psS32    psS64    psU8   psF64
+-10.05    2        4         8        0       -2       -4       -8       5      -1.5
+ k.009     4        8         16       -1      -4       -8       -16      0      -1.0
+23.45     6        12        24       -2      -6       -12      -24      5      -0.25
+3500.67   8        16        32       -3      -8       -16      -32      75     1.75
+   
+#
Index: trunk/psLib/test/types/tableF64_err.dat
===================================================================
--- trunk/psLib/test/types/tableF64_err.dat	(revision 9714)
+++ trunk/psLib/test/types/tableF64_err.dat	(revision 9714)
@@ -0,0 +1,9 @@
+#  Table with valid types and index-values
+#
+#psF32     psU16    psU32     psU64    psS8    psS16    psS32    psS64    psU8   psF64
+-10.05    2        4         8        0       -2       -4       -8       5      -1.5  #
+ 1.009     4        8         16       -1      -4       -8       -16      0      -1.k
+23.45     6        12        24       -2      -6       -12      -24      5      -0.25
+3500.67   8        16        32       -3      -8       -16      -32      75     1.75
+
+#
Index: trunk/psLib/test/types/tableS32_err.dat
===================================================================
--- trunk/psLib/test/types/tableS32_err.dat	(revision 9714)
+++ trunk/psLib/test/types/tableS32_err.dat	(revision 9714)
@@ -0,0 +1,9 @@
+#  Table with valid types and index-values
+#
+#psF32     psU16    psU32     psU64    psS8    psS16    psS32    psS64    psU8   psF64
+-10.05    2        4         8        0       -2       -4       -8       5      -1.5
+ 1.009     4        8         16       -1      -4       -k8       -16      0      -1.0
+23.45     6        12        24       -2      -6       -12      -24      5      -0.25
+3500.67   8        16        32       -3      -8       -16      -32      75     1.75
+
+#
Index: trunk/psLib/test/types/tableS64_err.dat
===================================================================
--- trunk/psLib/test/types/tableS64_err.dat	(revision 9714)
+++ trunk/psLib/test/types/tableS64_err.dat	(revision 9714)
@@ -0,0 +1,9 @@
+#  Table with valid types and index-values
+#
+#psF32     psU16    psU32     psU64    psS8    psS16    psS32    psS64    psU8   psF64
+-10.05    2        4         8        0       -2       -4       -8       5      -1.5
+ 1.009     4        8         16       -1      -4       -8       -k6      0      -1.0
+23.45     6        12        24       -2      -6       -12      -24      5      -0.25
+3500.67   8        16        32       -3      -8       -16      -32      75     1.75
+
+#
Index: trunk/psLib/test/types/tap_psLookupTable_all.c
===================================================================
--- trunk/psLib/test/types/tap_psLookupTable_all.c	(revision 9672)
+++ trunk/psLib/test/types/tap_psLookupTable_all.c	(revision 9714)
@@ -24,5 +24,5 @@
 int main(void)
 {
-    plan_tests(13);
+    plan_tests(27);
 
     diag("Tests for psLookupTable Functions");
@@ -46,17 +46,17 @@
         lt = psLookupTableAlloc(NULL, "\%f \%lf \%d \%ld", 10);
         ok( lt == NULL,
-            "psLookupTableAlloc:            return NULL for NULL filename input.");
+            "psLookupTableAlloc:               return NULL for NULL filename input.");
     }
     //Return NULL for NULL format input
     {
-        lt = psLookupTableAlloc("tableF32.dat", NULL, 10);
+        lt = psLookupTableAlloc("table.dat", NULL, 10);
         ok( lt == NULL,
-            "psLookupTableAlloc:            return NULL for NULL format input.");
+            "psLookupTableAlloc:               return NULL for NULL format input.");
     }
     //Return properly allocated lookupTable for valid inputs
     {
-        lt = psLookupTableAlloc("tableF32.dat", "\%f \%lf \%d \%ld", 10);
+        lt = psLookupTableAlloc("table.dat", "\%f \%lf \%d \%ld", 10);
         ok( lt != NULL && psMemCheckLookupTable(lt),
-            "psLookupTableAlloc:            "
+            "psLookupTableAlloc:               "
             "return properly allocated lookupTable for valid inputs.");
     }
@@ -67,5 +67,5 @@
         int j = 2;
         ok( !psMemCheckLookupTable(&j),
-            "psMemCheckLookupTable:         return false for non-LookupTable input.");
+            "psMemCheckLookupTable:            return false for non-LookupTable input.");
     }
 
@@ -82,8 +82,8 @@
     diag("  >>>Test 2:  psVectorsReadFromFile, psLookupTableImport, psLookupTableRead Fxns");
     psArray *outVec = NULL;
+    psArray *vectors = NULL;
     psLookupTable*  table1  = NULL;
+    psLookupTable*  tableOut  = NULL;
     long           numRows = 0;
-    char filename[30];
-    strcpy(filename, "tableF32.dat");
 
     //Tests for psVectorReadFromFile
@@ -93,11 +93,11 @@
                                        "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
         ok( outVec == NULL,
-            "psVectorsReadFromFile:         return NULL for NULL filename input.");
+            "psVectorsReadFromFile:            return NULL for NULL filename input.");
     }
     // Attempt to read from NULL format input
     {
-        outVec = psVectorsReadFromFile(filename, NULL);
-        ok( outVec == NULL,
-            "psVectorsReadFromFile:         return NULL for NULL format input.");
+        outVec = psVectorsReadFromFile("table.dat", NULL);
+        ok( outVec == NULL,
+            "psVectorsReadFromFile:            return NULL for NULL format input.");
     }
     // Attempt to read from invalid filename input
@@ -106,171 +106,111 @@
                                        "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
         ok( outVec == NULL,
-            "psVectorsReadFromFile:         return NULL for invalid filename input.");
+            "psVectorsReadFromFile:            return NULL for invalid filename input.");
     }
     // Attempt to read from invalid format input
     {
-        outVec = psVectorsReadFromFile(filename, "\%s");
-        ok( outVec == NULL,
-            "psVectorsReadFromFile:         return NULL for invalid format input.");
-    }
-
-    // Attempt to read from table containing missing entry
+        outVec = psVectorsReadFromFile("table.dat", "\%s");
+        ok( outVec == NULL,
+            "psVectorsReadFromFile:            return NULL for invalid format input.");
+    }
+    // Attempt to read from table containing invalid entry - F32
     {
         outVec = psVectorsReadFromFile("tableF32_err.dat",
                                        "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
         ok( outVec == NULL,
-            "psVectorsReadFromFile:         return NULL for table containing invalid entry.");
-    }
-    // Attempt to read from table containing missing entry
+            "psVectorsReadFromFile:            return NULL for table containing invalid entry.");
+    }
+    // Attempt to read from table containing invalid entry - F64
+    {
+        outVec = psVectorsReadFromFile("tableF64_err.dat",
+                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
+        ok( outVec == NULL,
+            "psVectorsReadFromFile:           return NULL for table containing invalid entry.");
+    }
+    // Attempt to read from table containing invalid entry - S32
+    {
+        outVec = psVectorsReadFromFile("tableS32_err.dat",
+                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
+        ok( outVec == NULL,
+            "psVectorsReadFromFile:           return NULL for table containing invalid entry.");
+    }
+    // Attempt to read from table containing invalid entry - S64
+    {
+        outVec = psVectorsReadFromFile("tableS64_err.dat",
+                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
+        ok( outVec == NULL,
+            "psVectorsReadFromFile:           return NULL for table containing invalid entry.");
+    }
+    // Attempt to read from empty table
     {
         outVec = psVectorsReadFromFile("tableF32_2.dat",
                                        "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
         ok( outVec == NULL,
-            "psVectorsReadFromFile:         return NULL for table containing invalid entry.");
-    }
-
+            "psVectorsReadFromFile:           return NULL for empty table.");
+    }
     //Attempt to read with valid inputs
     {
-        outVec = psVectorsReadFromFile("tableF32.dat",
-                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
-        ok( outVec != NULL,
-            "psVectorsReadFromFile:        return non-NULL array for valid format input.");
-    }
-
-    //Tests for psListToArray
-    //    psLookupTable *lt = NULL;
-
-
+        outVec = psVectorsReadFromFile("table.dat",
+                                       "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf");
+        ok( outVec != NULL &&  outVec->n == 9 &&
+            ((psVector*)(outVec->data[6]))->data.S32[1] == -8,
+            "psVectorsReadFromFile:           return correct array for valid format input.");
+    }
+
+    //Tests for psLookupTableRead
     // Attempt to read table with NULL input table specified
     numRows = psLookupTableRead(table1);
     {
         ok( numRows == 0,
-            "psLookupTableRead:            return NULL for NULL filename input.");
-    }
-    /*
-    psS32 testLookupTableRead(void)
-    {
-
-    // Set up valid table to read
-        table1 = psLookupTableAlloc(tableF32_filename,tableF32_format,tableF32_indexCol);
-    // Read table
-        numRows = psLookupTableRead(table1);
-    // Verify return value equals number of lines read
-        if(numRows != tableF32_size) {
-            psError(PS_ERR_UNKNOWN,true,"Return value %d not as expected %d",
-                    numRows,tableF32_size);
-            return 1;
-        }
-    // Verify the members and values in table
-        if(fabs(table1->validFrom - tableF32_validFrom) > errorTol_psF64) {
-            psError(PS_ERR_UNKNOWN,true,"Member validFrom = %f not as expected %f",
-                    table1->validFrom,tableF32_validFrom);
-            return 2;
-        }
-        if(fabs(table1->validTo - tableF32_validTo) > errorTol_psF64) {
-            psError(PS_ERR_UNKNOWN,true,"Member validTo = %f not as expected %f",
-                    table1->validTo,tableF32_validTo);
-            return 3;
-        }
-        if(strcmp(table1->filename,tableF32_filename) != 0) {
-            psError(PS_ERR_UNKNOWN,true,"Member filename %s not as expected %s",
-                    table1->filename,tableF32_filename);
-            return 4;
-        }
-        if(strcmp(table1->format,tableF32_format) != 0) {
-            psError(PS_ERR_UNKNOWN,true,"Member format %s not as expected %s",
-                    table1->format,tableF32_format);
-            return 5;
-        }
-        if(table1->indexCol != tableF32_indexCol) {
-            psError(PS_ERR_UNKNOWN,true,"Member indexCol %d not as expected %d",
-                    table1->indexCol,tableF32_indexCol);
-            return 6;
-        }
-        for(psS32 i = 0; i < table1->index->n; i++) {
-            if(fabs(table1->index->data.F32[i]-tableF32_index[i]) > errorTol_psF64) {
-                psError(PS_ERR_UNKNOWN,true,"Index column[%d] = %f not as expected %f",
-                        i,table1->index->data.F32[i],tableF32_index[i]);
-                return i*7;
-            }
-        }
-        psVector* tempVector = table1->values->data[1];
-        for(psS32 i = 0; i < tempVector->n; i++) {
-            if(tempVector->data.S32[i] != tableF32_col1[i]) {
-                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
-                        i,tempVector->data.S32[i],tableF32_col1[i]);
-                return i*8;
-            }
-        }
-        tempVector = table1->values->data[2];
-        for(psS32 i = 0; i < tempVector->n; i++) {
-            if(tempVector->data.S32[i] != tableF32_col2[i]) {
-                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
-                        i,tempVector->data.S32[i],tableF32_col2[i]);
-                return i*9;
-            }
-        }
-        tempVector = table1->values->data[3];
-        for(psS32 i = 0; i < tempVector->n; i++) {
-            if(tempVector->data.S64[i] != tableF32_col3[i]) {
-                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %ld not as expected %ld",
-                        i,tempVector->data.S64[i],tableF32_col3[i]);
-                return i*10;
-            }
-        }
-        tempVector = table1->values->data[4];
-        for(psS32 i = 0; i < tempVector->n; i++) {
-            if(tempVector->data.S32[i] != tableF32_col4[i]) {
-                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
-                        i,tempVector->data.S32[i],tableF32_col4[i]);
-                return i*11;
-            }
-        }
-        tempVector = table1->values->data[5];
-        for(psS32 i = 0; i < tempVector->n; i++) {
-            if(tempVector->data.S32[i] != tableF32_col5[i]) {
-                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
-                        i,tempVector->data.S32[i],tableF32_col5[i]);
-                return i*12;
-            }
-        }
-        tempVector = table1->values->data[6];
-        for(psS32 i = 0; i < tempVector->n; i++) {
-            if(tempVector->data.S32[i] != tableF32_col6[i]) {
-                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %d not as expected %d",
-                        i,tempVector->data.S32[i],tableF32_col6[i]);
-                return i*13;
-            }
-        }
-        tempVector = table1->values->data[7];
-        for(psS32 i = 0; i < tempVector->n; i++) {
-            if(tempVector->data.S64[i] != tableF32_col7[i]) {
-                psError(PS_ERR_UNKNOWN,true,"Value column[%d] = %ld not as expected %ld",
-                        i,tempVector->data.S64[i],tableF32_col7[i]);
-                return i*14;
-            }
-        }
-        psFree(table1);
-
-    // Set up invalid table to read
-        table1 = psLookupTableAlloc(tableF32_filename,tableF32_format,tableF32_indexCol);
-        table1->indexCol = -1;
-    // Read invalid table
-        psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message invalid table indexCol");
-        numRows = psLookupTableRead(table1);
-    // Verify the num of rows read is zero
-        if(numRows != 0) {
-            psError(PS_ERR_UNKNOWN,true,"Did not return 0 for line read for invalid table");
-            return 15;
-        }
-        psFree(table1);
-
-        return 0;
-    }
-    */
-
+            "psLookupTableRead:               return NULL for NULL filename input.");
+    }
+    // Attempt to read table with bad filename specified
+    table1 = psLookupTableAlloc("psTable.dat", "\%f \%lf \%d \%ld", 10);
+    numRows = psLookupTableRead(table1);
+    {
+        ok( numRows == 0,
+            "psLookupTableRead:               return NULL for table with invalid filename.");
+    }
+
+    // Attempt to read valid table with wrong indexCol
+    psFree(table1);
+    table1 = psLookupTableAlloc("table.dat",
+                                "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf", 10);
+    numRows = psLookupTableRead(table1);
+    {
+        ok( numRows == 0,
+            "psLookupTableRead:               return correct number of rows for valid inputs.");
+    }
+    // Attempt to read valid table
+    psFree(table1);
+    table1 = psLookupTableAlloc("table.dat",
+                                "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf", 0);
+    numRows = psLookupTableRead(table1);
+    {
+        ok( numRows == 4,
+            "psLookupTableRead:               return correct number of rows for valid inputs.");
+    }
+
+    //Tests for psLookupTableImport (remaining cases)
+    // Attempt to import table with negative indexCol
+    vectors = psVectorsReadFromFile(table1->filename, table1->format);
+    tableOut = psLookupTableImport(table1, vectors, -1 );
+    {
+        ok( tableOut == NULL,
+            "psLookupTableImport:             return NULL for negative indexCol input.");
+    }
+    //Attempt to import table with unsorted array column
+    psFree(table1);
+    table1 = psLookupTableAlloc("table.dat",
+                                "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf", 0);
+    tableOut = psLookupTableImport(table1, vectors, 7 );
+    {
+        ok( tableOut != NULL,
+            "psLookupTableImport:             return correct table for array with unsorted column");
+    }
 
     //Check for Memory leaks
     {
+        psFree(vectors);
         psFree(outVec);
         psFree(table1);
@@ -283,34 +223,72 @@
 {
     diag("  >>>Test 3:  psLookupTableInterpolate & psLookupTableInterpolateAll Fxns");
-
-
-
-    //Tests for psListToArray
+    psLookupTable *table1 = NULL;
+    psVector *vec = NULL;
+    table1 = psLookupTableAlloc("table.dat",
+                                "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf", 0);
+    psLookupTable *table2 = NULL;
+    table2 = psLookupTableAlloc("table.dat",
+                                "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf", 0);
+    psLookupTableRead(table2);
+
+    //Tests for psLookupTableInterpolateAll
+    //Return NULL for NULL table input
+    {
+        vec = psLookupTableInterpolateAll(NULL, 0);
+        ok( vec == NULL,
+            "psLookupTableInterpolateAll:     return NULL for NULL table input.");
+    }
+    //Return NULL for NULL table values
+    {
+        vec = psLookupTableInterpolateAll(table1, 0);
+        ok( vec == NULL,
+            "psLookupTableInterpolateAll:     return NULL for NULL table values.");
+    }
+    //Return NULL for table with table->values->n == 0
+    {
+        long n = table2->values->n;
+        table2->values->n = 0;
+        vec = psLookupTableInterpolateAll(table2, 0);
+        ok( vec == NULL,
+            "psLookupTableInterpolateAll:     return NULL for table with no columns.");
+        table2->values->n = n;
+    }
+    //Return NULL for invalid index input
+    {
+        vec = psLookupTableInterpolateAll(table2, -10.5);
+        ok( vec == NULL,
+            "psLookupTableInterpolateAll:     return NULL for invalid index input.");
+    }
+    //Return correct vector output for valid inputs
+    {
+        vec = psLookupTableInterpolateAll(table2, 1);
+        skip_start(  vec == NULL, 1,
+                     "Skipping 1 tests because psLookupTableInterpolateAll failed");
+        ok_double(vec->data.F64[0], 1.0,
+                  "psLookupTableInterpolateAll:     return correct output vector for valid inputs.");
+        skip_end();
+    }
+
+    //Remaining tests for psLookupTableInterpolate
+    //Return NAN for invalid index - divide by zero error
+    psLookupTable *table3 = NULL;
+    table3 = psLookupTableAlloc("table2.dat",
+                                "\%f \%d \%d \%ld \%d \%d \%d \%ld \%*d \%lf", 0);
+    psLookupTableRead(table3);
+    {
+        double retVal;
+        retVal = psLookupTableInterpolate(table3, 1.5e-20, 0);
+        ok( isnan(retVal),
+            "psLookupTableInterpolateAll:     return NAN for invalid index input.");
+    }
 
     //Check for Memory leaks
     {
-
+        psFree(table3);
+        psFree(vec);
+        psFree(table2);
+        psFree(table1);
         checkMem();
     }
 
 }
-
-
-
-/*
-    //Return NULL for NULL list input
-{
-    array = psListToArray(NULL);
-    ok( array == NULL,
-        "psListToArray:          return NULL for NULL list input.");
-    skip_start(  !psArraySet(a, 0, s32) || !psArraySet(a, 1, s32), 1,
-                  "Skipping 1 tests because psArraySet failed");
-    a = psArrayRealloc(a, 1);
-    *s32_2 = *((psS32*)(a->data[0]));
-    ok( a->n == 1 && a->nalloc == 1 && *s32_2 == 1,
-        "psArrayRealloc:         return properly reallocated psArray.");
-    skip_end();
-}
-*/
-
-
