IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 12, 2006, 11:25:39 AM (20 years ago)
Author:
Paul Price
Message:

Moving psStringSubstitute tests to libtap; resetting stderr output for tst_psString.

Location:
trunk/psLib/test/sys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/sys

    • Property svn:ignore
      •  

        old new  
        1717core
        1818core.*
         19tap_psStringSubstitute
  • trunk/psLib/test/sys/tst_psString.c

    r7831 r7880  
    2020 *  @author  Eric Van Alst, MHPCC
    2121 *
    22  *  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
    23  *  @date  $Date: 2006-07-06 22:26:13 $
     22 *  @version $Revision: 1.10 $  $Name: not supported by cvs2svn $
     23 *  @date  $Date: 2006-07-12 21:25:39 $
    2424 *
    2525 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5353static psS32 testStrSplit00(void);
    5454static psS32 testNULLStrings(void);
    55 static psS32 testStrSub(void);
    5655
    5756testDescription tests[] = {
     
    7574                              {testStrSplit00,15, "Test String Splitting", 0, false},
    7675                              {testNULLStrings,666, "Test NULL String Error Handling", 0, false},
    77                               {testStrSub,16, "Test String Substitute", 0, false},
    7876                              {NULL}
    7977                          };
     
    711709    return 0;
    712710}
    713 
    714 static psS32 testStrSub(void)
    715 {
    716     psString input = NULL;
    717     char str[35];
    718     strncpy(str, "This is, a, test case, to check.", 35);
    719 
    720     //Return str for NULL key
    721     input = psStringSubstitute(str, ",", NULL);
    722     if (input != NULL) {
    723         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    724                 "psStringSubstitute failed to return unchanged str for NULL key.\n");
    725         psFree(input);
    726         return 1;
    727     }
    728     //Return NULL for empty key
    729     input = psStringSubstitute(str, ",", "");
    730     if (input != NULL) {
    731         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    732                 "psStringSubstitute failed to return unchanged str for empty key.\n");
    733         psFree(input);
    734         return 2;
    735     }
    736     //Return NULL for NULL replace
    737     input = psStringSubstitute(str, NULL, ",");
    738     if (input != NULL) {
    739         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    740                 "psStringSubstitute failed to return unchanged str for NULL replace.\n");
    741         psFree(input);
    742         return 3;
    743     }
    744     //Return NULL for NULL input
    745     psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    746     input = psStringSubstitute(NULL, "", ",");
    747     if (input != NULL) {
    748         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    749                 "psStringSubstitute failed to return NULL for NULL input.\n");
    750         psFree(input);
    751         return 4;
    752     }
    753     //Return empty string for empty input string
    754     psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    755     input = psStringSubstitute("", "", ",");
    756     if (input != NULL) {
    757         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    758                 "psStringSubstitute failed to return empty string for empty input string.\n");
    759         psFree(input);
    760         return 5;
    761     }
    762     //Check valid test case, changing commas to exclamation points
    763     input = psStringSubstitute(str, "!", ",");
    764     if (strcmp(input, "This is! a! test case! to check.") != 0 ) {
    765         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    766                 "psStringSubstitute failed to return the correct output string.\n");
    767         psFree(input);
    768         return 7;
    769     }
    770     psFree(input);
    771     input = NULL;
    772     //Check valid test case, remove exclamation points
    773     input = psStringSubstitute(str, "", ",");
    774     if (strcmp(input, "This is a test case to check.") != 0 ) {
    775         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    776                 "psStringSubstitute failed to return the correct output string.\n");
    777         psFree(input);
    778         return 8;
    779     }
    780     psFree(input);
    781     input = NULL;
    782     //Check case where replacement is long.  Should still work now.
    783     input = psStringSubstitute(str, "; This string is too long to fit in str(35 chars)", ".");
    784     if (strcmp(input,"This is, a, test case, to check; This string is too long to fit in str(35 chars)") != 0 ) {
    785         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    786                 "psStringSubstitute failed to return the correct output string.\n");
    787         psFree(input);
    788         return 9;
    789     }
    790     psFree(input);
    791 
    792     return 0;
    793 }
Note: See TracChangeset for help on using the changeset viewer.