Index: /trunk/psLib/test/sysUtils/tst_psError.c
===================================================================
--- /trunk/psLib/test/sysUtils/tst_psError.c	(revision 1866)
+++ /trunk/psLib/test/sysUtils/tst_psError.c	(revision 1867)
@@ -4,12 +4,14 @@
  *
  *  This test driver contains the following test points for psError
- *     1)  Multiple type values in error message
- *     2)  String values in error message
- *     3)  Empty strings in error message
+ *     testError00 - psError()
+ *     testError01 - psErrorMsg(), psErrorStackPrint()
+ *     testError02 - psErrorStackPrintV()
+ *     testError03 - psErrorGet(), psErrorLast()
+ *     testError04 - psErrorClear()
  *
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-09-22 23:47:09 $
+ *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-09-23 21:59:16 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -23,7 +25,28 @@
 
 static int testError00(void);
+static int testError01(void);
+static int testError02(void);
+static int testError03(void);
+static int testError04(void);
+
+// Function used in testError02 to verify the psErrorStackPrintV function
+static void myErrorStackPrint(FILE *fd,
+                              const char *fmt,
+                              ...)
+{
+    va_list ap;
+
+    // Test whether psErrorStackPrintV() accept a va_list for output variables
+    va_start(ap, fmt);
+    psErrorStackPrintV(fd, fmt, ap);
+    va_end(ap);
+}
 
 testDescription tests[] = {
                               {testError00, 0, "psError()", 0, false},
+                              {testError01, 0, "psErrorMsg(),psErrorStackPrint()", 0, false},
+                              {testError02, 0, "psErrorStackPrintV()", 0, false},
+                              {testError03, 0, "psErrorGet(),psErrorLast()", 0, false},
+                              {testError04, 0, "psErrorClear()", 0, false},
                               {NULL}
                           };
@@ -34,4 +57,199 @@
 
     return ( !runTestSuite(stderr, "psError", tests, argc, argv) );
+}
+
+static int testError04(void)
+{
+    psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+    psErr *last = NULL;
+    psErr *lastAfterClear = NULL;
+
+    // Generate three error messages
+    if (psErrorMsg("test3A", code, true, "Error code = %d", code) !=  code) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
+        return 30;
+    }
+    if (psErrorMsg("test3A", (code+1), false, "Error code = %d", (code+1)) != (code+1)) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
+        return 31;
+    }
+    if (psErrorMsg("test3A", (code+2), false, "Error code = %d", (code+2)) != (code+2)) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
+        return 32;
+    }
+
+    // Get the last error message and verify it has the expected code
+    last = psErrorLast();
+    if(last->code != (code+2)) {
+        psLogMsg("tst_psError04", PS_LOG_ERROR, "psErrorLast did not return expected.");
+        return 33;
+    }
+    psFree(last);
+
+    // Clear the error stack
+    psErrorClear();
+
+    // Get the last error message after clear and verify is has PS_ERR_NONE code
+    lastAfterClear = psErrorLast();
+    if(last->code != PS_ERR_NONE) {
+        psLogMsg("tst_psError05", PS_LOG_ERROR, "psErrorLaster did not return expected.");
+        return 34;
+    }
+    psFree(lastAfterClear);
+
+    return 0;
+}
+
+static int testError03(void)
+{
+    psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+    psErr *last = NULL;
+    psErr *get
+    = NULL;
+
+    // Attempt to get last error message with an empty stack verify psErr with code PS_ERR_NONE
+    last = psErrorLast();
+    if(last->code != PS_ERR_NONE) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorLast did return PS_ERR_NONE for empty stack");
+        return 20;
+    }
+    psFree(last);
+
+    // Attempt to get specific error message with empty stack verify psErr with code PS_ERR_NONE
+    get
+        = psErrorGet(2);
+    if(get
+            ->code != PS_ERR_NONE) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet did not return PS_ERR_NONE  for empty stack");
+        return 21;
+    }
+    psFree(get
+          );
+
+    // Attempt to get error message with invalid index and an empty stack
+    get
+        = psErrorGet(-1);
+    if(get
+            ->code != PS_ERR_NONE) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet with invalid index/empty stack");
+        return 22;
+    }
+    psFree(get
+          );
+
+    // Generate three error messages
+    if (psErrorMsg("test3A", code, true, "Error code = %d", code) !=  code) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
+        return 23;
+    }
+    if (psErrorMsg("test3A", (code+1), false, "Error code = %d", (code+1)) != (code+1)) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
+        return 24;
+    }
+    if (psErrorMsg("test3A", (code+2), false, "Error code = %d", (code+2)) != (code+2)) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
+        return 25;
+    }
+
+    last = psErrorLast();
+    get
+        = psErrorGet(0);
+
+    // Check that last and get with 0 index are equal
+    if(last != get
+          ) {
+            psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet(0) not equal to psErrorLast");
+            return 26;
+        }
+    psFree(last);
+
+    // Verify the last error message was returned
+    if ( last->code != (code+2) ) {
+        psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorLast() did not retrieve last error");
+        return 27;
+    }
+    psFree(get
+          );
+
+    // Verify the middle error message can be retrieved
+    get
+        = psErrorGet(1);
+    if ( get
+                ->code != (code+1)) {
+            psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet() did not retrieve proper error");
+            return 28;
+        }
+    psFree(get
+          );
+
+    // Verify the psErrorGet returns NULL if an invalid index is given
+    get
+        = psErrorGet(-1);
+    if ( get
+                ->code != PS_ERR_NONE ) {
+            psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet() did not return PS_ERR_NONE w/ invalid arg");
+            return 29;
+        }
+    psFree(get
+          );
+
+    return 0;
+}
+
+static int testError02(void)
+{
+    psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+
+    // Generate error message and verify return value
+    if (psErrorMsg("test2A", code, true, "Error code = %d", code) != code ) {
+        psLogMsg("tst_psError02", PS_LOG_ERROR, "Failed return value verify.");
+        return 10;
+    }
+    myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2);
+
+    return 0;
+}
+
+static int testError01(void)
+{
+    psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE;
+
+    // Verify the return value of psErrorMsg is the psErrorCode passed
+    if ( psErrorMsg("test1A", code, true, "Error code = %d", code) != code) {
+        psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return value verify.");
+        return 1;
+    }
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A");
+
+    // test1B empty string in for name argument
+    if ( psErrorMsg("", code+1, true, "Error code = %d", code+1) != code+1) {
+        psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with empty string.");
+        return 2;
+    }
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B");
+
+    // test1C null pointer in  for name argument
+    if ( psErrorMsg(NULL, code+2, true, "Error code = %d", code+2) != code+2) {
+        psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with null name arg.");
+        return 3;
+    }
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1C");
+
+    // test1D undefined code
+    if ( psErrorMsg("test1D", -1, true, "Error code = %d", -1) != -1) {
+        psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with undefined code.");
+        return 4;
+    }
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D");
+
+    // test1E set psErrorMsg argument to false
+    if( psErrorMsg("test1E", code, false, "Error code = %d", code) != code) {
+        psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with false new arg.");
+        return 5;
+    }
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E");
+
+    // Call psErrorMsg with
+    return 0;
 }
 
@@ -46,21 +264,15 @@
 
     // Test point #1 Multiple type values placed in the error string
-    printPositiveTestHeader(stderr,"psError","Multiple type values in error message");
     psError(__func__,
             "ALL TYPES intval = %d longval = %ld floatval = %f charval = %c strval = %s",
             intval,longval,floatval,charval,stringval);
-    printFooter(stderr, "psError","Multiple type values in error message",true);
 
     // Test point #2 String values in error message
-    printPositiveTestHeader(stderr, "psError","String values in error message");
     psError(PS_STRING(__LINE__),"NO VALUES");
-    printFooter(stderr, "psError","String values in error message",true);
 
     // Test point #3 Empty strings in error message
-    printPositiveTestHeader(stderr, "psError","Empty strings in error message");
     psError("","");
-    printFooter(stderr, "psError","Empty strings in error message",true);
-
-    return 0;
-}
-
+
+    return 0;
+}
+
Index: /trunk/psLib/test/sysUtils/verified/tst_psError.stderr
===================================================================
--- /trunk/psLib/test/sysUtils/verified/tst_psError.stderr	(revision 1866)
+++ /trunk/psLib/test/sysUtils/verified/tst_psError.stderr	(revision 1867)
@@ -5,37 +5,84 @@
 \**********************************************************************************/
 
+<DATE><TIME>|<HOST>|E|testError00
+    ALL TYPES intval = 1 longval = 2 floatval = 3.010000 charval = E strval = E R R O R
+<DATE><TIME>|<HOST>|E|__LINE__
+    NO VALUES
+<DATE><TIME>|<HOST>|E|
+
+---> TESTPOINT PASSED (psError{psError()} | tst_psError.c)
+
 /***************************** TESTPOINT ******************************************\
 *             TestFile: tst_psError.c                                              *
-*            TestPoint: psError{Multiple type values in error message}             *
+*            TestPoint: psError{psErrorMsg(),psErrorStackPrint()}                  *
 *             TestType: Positive                                                   *
 \**********************************************************************************/
 
-<DATE><TIME>|<HOST>|E|testError00
-    ALL TYPES intval = 1 longval = 2 floatval = 3.010000 charval = E strval = E R R O R
+<DATE><TIME>|<HOST>|E|test1A
+    Error code = 262
+ERROR STACK PRINT Test1A -> test1A: parameter is out-of-range
+     Error code = 262
+<DATE><TIME>|<HOST>|E|
+    Error code = 263
+ERROR STACK PRINT Test1B -> : parameter is of unsupported type
+     Error code = 263
+<DATE><TIME>|<HOST>|E|
+    Error code = 264
+ERROR STACK PRINT Test1C -> : parameter is null
+     Error code = 264
+<DATE><TIME>|<HOST>|E|test1D
+    Error code = -1
+ERROR STACK PRINT Test1D -> test1D: (null)
+     Error code = -1
+<DATE><TIME>|<HOST>|E|test1E
+    Error code = 262
+ERROR STACK PRINT Test1E -> test1D: (null)
+     Error code = -1
+ -> test1E: parameter is out-of-range
+     Error code = 262
 
----> TESTPOINT PASSED (psError{Multiple type values in error message} | tst_psError.c)
+---> TESTPOINT PASSED (psError{psErrorMsg(),psErrorStackPrint()} | tst_psError.c)
 
 /***************************** TESTPOINT ******************************************\
 *             TestFile: tst_psError.c                                              *
-*            TestPoint: psError{String values in error message}                    *
+*            TestPoint: psError{psErrorStackPrintV()}                              *
 *             TestType: Positive                                                   *
 \**********************************************************************************/
 
-<DATE><TIME>|<HOST>|E|__LINE__
-    NO VALUES
+<DATE><TIME>|<HOST>|E|test2A
+    Error code = 262
+ERROR STACK PRINT Test2A -> test2A: parameter is out-of-range
+     Error code = 262
 
----> TESTPOINT PASSED (psError{String values in error message} | tst_psError.c)
+---> TESTPOINT PASSED (psError{psErrorStackPrintV()} | tst_psError.c)
 
 /***************************** TESTPOINT ******************************************\
 *             TestFile: tst_psError.c                                              *
-*            TestPoint: psError{Empty strings in error message}                    *
+*            TestPoint: psError{psErrorGet(),psErrorLast()}                        *
 *             TestType: Positive                                                   *
 \**********************************************************************************/
 
-<DATE><TIME>|<HOST>|E|
+<DATE><TIME>|<HOST>|E|test3A
+    Error code = 262
+<DATE><TIME>|<HOST>|E|test3A
+    Error code = 263
+<DATE><TIME>|<HOST>|E|test3A
+    Error code = 264
 
----> TESTPOINT PASSED (psError{Empty strings in error message} | tst_psError.c)
+---> TESTPOINT PASSED (psError{psErrorGet(),psErrorLast()} | tst_psError.c)
 
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psError.c                                              *
+*            TestPoint: psError{psErrorClear()}                                    *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
 
----> TESTPOINT PASSED (psError{psError()} | tst_psError.c)
+<DATE><TIME>|<HOST>|E|test3A
+    Error code = 262
+<DATE><TIME>|<HOST>|E|test3A
+    Error code = 263
+<DATE><TIME>|<HOST>|E|test3A
+    Error code = 264
 
+---> TESTPOINT PASSED (psError{psErrorClear()} | tst_psError.c)
+
