Index: /trunk/psLib/test/dataIO/tst_psDB.c
===================================================================
--- /trunk/psLib/test/dataIO/tst_psDB.c	(revision 4291)
+++ /trunk/psLib/test/dataIO/tst_psDB.c	(revision 4292)
@@ -9,6 +9,6 @@
  *  @author Aaron Culliney, MHPCC
  *
- *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-16 01:49:23 $
+ *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-16 23:35:07 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -87,5 +87,5 @@
                               {TPDBDropTable,      844,  "dbDropTable",       0, false},
                               {TPDBSelectColumn,   845,  "dbSelectColumn",    0, false},
-                              {TPDBSelectColumnNum, -6,  "dbSelectColumnNum", 0, false},
+                              {TPDBSelectColumnNum,846,  "dbSelectColumnNum", 0, false},
                               {TPDBSelectRows,      -7,  "dbSelectRows",      0, false},
                               {TPDBInsertOneRow,    -8,  "dbInsertOneRow",    0, false},
@@ -651,11 +651,4 @@
     }
 
-    // Attempt to select NULL column from valid database object and valid table
-    //    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL column");
-    //    if(psDBSelectColumn(dbh,table,NULL,10) != NULL) {
-    //        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return for NULL column");
-    //        return 18;
-    //    }
-
     // Clean up table and memory
     psDBDropTable(dbh, table);
@@ -666,5 +659,5 @@
 }
 
-// Testpoint #XXX, TPDBSelectColumnNum shall write/select a column from a test table ...
+// Testpoint #846, TPDBSelectColumnNum shall write/select a column from a test table ...
 psS32 TPDBSelectColumnNum( void )
 {
@@ -673,63 +666,163 @@
     const char* table = "table4";
     psVector *vec = NULL;
+
+    // Create table definition metadata
     psMetadata *row=NULL, *md = _get_CreateTableMetadata();
 
+    // Initialize database connection
     dbh = _init_psDB();
     if (dbh == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expected NULL return to initialize database");
         return 1;
     }
 
-    psLogMsg( __func__, PS_LOG_INFO, "psDBSelectColumnNum shall select data from a test table.\n" );
-
-    failed = ! psDBCreateTable(dbh, table, md);
-    if (!failed) {
-
-        row = _get_const_row1();
-        psDBInsertOneRow(dbh, table, row);
-        psFree(row);
-
-        row = _get_const_row2();
-        psDBInsertOneRow(dbh, table, row);
-        psFree(row);
-
-        row = _get_row();
-        psDBInsertOneRow(dbh, table, row);
-        psFree(row);
-
-        vec = psDBSelectColumnNum(dbh, table, "key_s32", PS_TYPE_S32, 0);
-        if (vec == NULL) {
-            failed = 1;
-        } else {
-            psLogMsg( __func__, PS_LOG_INFO, "str=[%d]\n", (vec->data.S32)[2] );
-            psLogMsg( __func__, PS_LOG_INFO, "str=[%d]\n", (vec->data.S32)[1] );
-            psLogMsg( __func__, PS_LOG_INFO, "str=[%d]\n", (vec->data.S32)[0] );
-            if ((vec->data.S32)[0] != S32_1) {
-                psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected S32 output!\n" );
-                failed = 1;
-            } else {
-                psLogMsg( __func__, PS_LOG_INFO, "found expected S32 output.\n" );
-            }
-            psFree(vec);
-        }
-
-        vec = psDBSelectColumnNum(dbh, table, "key_bool", PS_TYPE_BOOL, 0);
-        if (vec == NULL) {
-            failed = 1;
-        } else {
-            psLogMsg( __func__, PS_LOG_INFO, "bool=[%d]\n", (vec->data.U8)[2] );
-            psLogMsg( __func__, PS_LOG_INFO, "bool=[%d]\n", (vec->data.U8)[1] );
-            psLogMsg( __func__, PS_LOG_INFO, "bool=[%d]\n", (vec->data.U8)[0] );
-            if ((vec->data.U8)[0] != B_1) {
-                psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected bool output!\n" );
-                failed = 1;
-            } else {
-                psLogMsg( __func__, PS_LOG_INFO, "found expected bool output.\n" );
-            }
-            psFree(vec);
-        }
-
-        psDBDropTable(dbh, table);
-    }
-
+    // Create database table for test
+    if(!psDBCreateTable(dbh, table, md)) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return false for create table");
+        return 2;
+    }
+
+    // Initialize database table with known rows
+    row = _get_const_row1();
+    psDBInsertOneRow(dbh, table, row);
+    psFree(row);
+
+    row = _get_const_row2();
+    psDBInsertOneRow(dbh, table, row);
+    psFree(row);
+
+    row = _get_row();
+    psDBInsertOneRow(dbh, table, row);
+    psFree(row);
+
+    // Use valid arguments to select column with numeric values to return vector
+    vec = psDBSelectColumnNum(dbh, table, "key_s32", PS_TYPE_S32, 0);
+
+    // Verify vector returned
+    if (vec == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return with valid arguments");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 3;
+    }
+    // Verify vector values
+    if(vec->n != 3) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return vector size not equal to 3");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 30;
+    }
+    if(vec->type.type != PS_TYPE_S32) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return vector type not equal to PS_TYPE_S32");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 31;
+    }
+    if ((vec->data.S32)[0] != S32_1) {
+        psError(PS_ERR_UNKNOWN,true,"vector value[%d] = %d not as expected %d",
+                0,vec->data.S32[0], S32_1);
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 4;
+    }
+    if ((vec->data.S32)[1] != CONST_ROW_2_S32) {
+        psError(PS_ERR_UNKNOWN,true,"vector value[%d] = %d not as expected %d",
+                1,vec->data.S32[1], CONST_ROW_2_S32);
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 5;
+    }
+    if ((vec->data.S32)[2] != CONST_ROW_1_S32) {
+        psError(PS_ERR_UNKNOWN,true,"vector value[%d] = %d not as expected %d",
+                2,vec->data.S32[2], CONST_ROW_1_S32);
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 6;
+    }
+    psFree(vec);
+
+    // Use valid arguments to select column with numeric values to return vector
+    vec = psDBSelectColumnNum(dbh, table, "key_bool", PS_TYPE_BOOL, 0);
+
+    // Verify vector returned
+    if (vec == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return with valid arguments");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 7;
+    }
+    // Verify vector values
+    if(vec->n != 3) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return vector size not equal to 3");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 8;
+    }
+    if(vec->type.type != PS_TYPE_BOOL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return vector type not equal to PS_TYPE_BOOL");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 9;
+    }
+    if ((vec->data.U8)[0] != B_1) {
+        psError(PS_ERR_UNKNOWN,true,"vector value[%d] = %d not as expected %d",
+                0,vec->data.U8[0],B_1);
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 10;
+    }
+    if ((vec->data.U8)[1] != CONST_ROW_2_BOOL) {
+        psError(PS_ERR_UNKNOWN,true,"vector value[%d] = %d not as expected %d",
+                0,vec->data.U8[0],CONST_ROW_2_BOOL);
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 11;
+    }
+    if ((vec->data.U8)[2] != CONST_ROW_1_BOOL) {
+        psError(PS_ERR_UNKNOWN,true,"vector value[%d] = %d not as expected %d",
+                0,vec->data.U8[0],CONST_ROW_1_BOOL);
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 12;
+    }
+    psFree(vec);
+
+    // Attempt to select columns from NULL database
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error for NULL database object");
+    if(psDBSelectColumnNum(NULL,table,"key_bool",PS_TYPE_BOOL,10) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return with NULL database object");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 13;
+    }
+
+    // Attempt to select columns from NULL table
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error for NULL table");
+    if(psDBSelectColumnNum(dbh,NULL,"key_bool",PS_TYPE_BOOL,10) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return with NULL table");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 14;
+    }
+
+    // Attempt to select columns from invalid column
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error for invalid column");
+    if(psDBSelectColumnNum(dbh,table,"key_999",PS_TYPE_BOOL,10) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return with NULL column");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 15;
+    }
+
+    // Attempt to select columns from invalid column
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error for invalid type");
+    if(psDBSelectColumnNum(dbh,table,"key_string",0,10) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return with invalid type");
+        psDBDropTable(dbh,table);
+        psDBCleanup(dbh);
+        return 16;
+    }
+
+    psDBDropTable(dbh, table);
     psFree(md);
     psDBCleanup(dbh);
Index: /trunk/psLib/test/dataIO/verified/tst_psDB.stderr
===================================================================
--- /trunk/psLib/test/dataIO/verified/tst_psDB.stderr	(revision 4291)
+++ /trunk/psLib/test/dataIO/verified/tst_psDB.stderr	(revision 4292)
@@ -125,21 +125,25 @@
 
 <DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    psDBSelectColumnNum shall select data from a test table.
+    Following should generate an error for NULL database object
+<DATE><TIME>|<HOST>|E|p_psDBRunQuery (FILE:LINENO)
+    Invalid psDB has been specified.
+<DATE><TIME>|<HOST>|E|psDBSelectColumn (FILE:LINENO)
+    Failed to select column.
 <DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    str=[12345]
+    Following should generate an error for NULL table
+<DATE><TIME>|<HOST>|E|p_psDBRunQuery (FILE:LINENO)
+    Failed to execute SQL query.  Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null) LIMIT 10' at line 1
+<DATE><TIME>|<HOST>|E|psDBSelectColumn (FILE:LINENO)
+    Failed to select column.
 <DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    str=[2345]
+    Following should generate an error for invalid column
+<DATE><TIME>|<HOST>|E|p_psDBRunQuery (FILE:LINENO)
+    Failed to execute SQL query.  Error: Unknown column 'key_999' in 'field list'
+<DATE><TIME>|<HOST>|E|psDBSelectColumn (FILE:LINENO)
+    Failed to select column.
 <DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    str=[1974]
-<DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    found expected S32 output.
-<DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    bool=[1]
-<DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    bool=[0]
-<DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    bool=[1]
-<DATE><TIME>|<HOST>|I|TPDBSelectColumnNum
-    found expected bool output.
+    Following should generate an error for invalid type
+<DATE><TIME>|<HOST>|E|psVectorAlloc (FILE:LINENO)
+    Input psVector is an unsupported type (0x0).
 
 ---> TESTPOINT PASSED (psDB{dbSelectColumnNum} | tst_psDB.c)
