Index: trunk/psLib/test/sys/tst_psString.c
===================================================================
--- trunk/psLib/test/sys/tst_psString.c	(revision 7418)
+++ trunk/psLib/test/sys/tst_psString.c	(revision 7831)
@@ -20,6 +20,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2006-06-08 01:06:36 $
+ *  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2006-07-06 22:26:13 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -53,4 +53,5 @@
 static psS32 testStrSplit00(void);
 static psS32 testNULLStrings(void);
+static psS32 testStrSub(void);
 
 testDescription tests[] = {
@@ -74,4 +75,5 @@
                               {testStrSplit00,15, "Test String Splitting", 0, false},
                               {testNULLStrings,666, "Test NULL String Error Handling", 0, false},
+                              {testStrSub,16, "Test String Substitute", 0, false},
                               {NULL}
                           };
@@ -710,2 +712,82 @@
 }
 
+static psS32 testStrSub(void)
+{
+    psString input = NULL;
+    char str[35];
+    strncpy(str, "This is, a, test case, to check.", 35);
+
+    //Return str for NULL key
+    input = psStringSubstitute(str, ",", NULL);
+    if (input != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "psStringSubstitute failed to return unchanged str for NULL key.\n");
+        psFree(input);
+        return 1;
+    }
+    //Return NULL for empty key
+    input = psStringSubstitute(str, ",", "");
+    if (input != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "psStringSubstitute failed to return unchanged str for empty key.\n");
+        psFree(input);
+        return 2;
+    }
+    //Return NULL for NULL replace
+    input = psStringSubstitute(str, NULL, ",");
+    if (input != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "psStringSubstitute failed to return unchanged str for NULL replace.\n");
+        psFree(input);
+        return 3;
+    }
+    //Return NULL for NULL input
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    input = psStringSubstitute(NULL, "", ",");
+    if (input != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "psStringSubstitute failed to return NULL for NULL input.\n");
+        psFree(input);
+        return 4;
+    }
+    //Return empty string for empty input string
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    input = psStringSubstitute("", "", ",");
+    if (input != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "psStringSubstitute failed to return empty string for empty input string.\n");
+        psFree(input);
+        return 5;
+    }
+    //Check valid test case, changing commas to exclamation points
+    input = psStringSubstitute(str, "!", ",");
+    if (strcmp(input, "This is! a! test case! to check.") != 0 ) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "psStringSubstitute failed to return the correct output string.\n");
+        psFree(input);
+        return 7;
+    }
+    psFree(input);
+    input = NULL;
+    //Check valid test case, remove exclamation points
+    input = psStringSubstitute(str, "", ",");
+    if (strcmp(input, "This is a test case to check.") != 0 ) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "psStringSubstitute failed to return the correct output string.\n");
+        psFree(input);
+        return 8;
+    }
+    psFree(input);
+    input = NULL;
+    //Check case where replacement is long.  Should still work now.
+    input = psStringSubstitute(str, "; This string is too long to fit in str(35 chars)", ".");
+    if (strcmp(input,"This is, a, test case, to check; This string is too long to fit in str(35 chars)") != 0 ) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "psStringSubstitute failed to return the correct output string.\n");
+        psFree(input);
+        return 9;
+    }
+    psFree(input);
+
+    return 0;
+}
