Changeset 7880 for trunk/psLib/test/sys/tst_psString.c
- Timestamp:
- Jul 12, 2006, 11:25:39 AM (20 years ago)
- Location:
- trunk/psLib/test/sys
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tst_psString.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sys
- Property svn:ignore
-
old new 17 17 core 18 18 core.* 19 tap_psStringSubstitute
-
- Property svn:ignore
-
trunk/psLib/test/sys/tst_psString.c
r7831 r7880 20 20 * @author Eric Van Alst, MHPCC 21 21 * 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 $ 24 24 * 25 25 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 53 53 static psS32 testStrSplit00(void); 54 54 static psS32 testNULLStrings(void); 55 static psS32 testStrSub(void);56 55 57 56 testDescription tests[] = { … … 75 74 {testStrSplit00,15, "Test String Splitting", 0, false}, 76 75 {testNULLStrings,666, "Test NULL String Error Handling", 0, false}, 77 {testStrSub,16, "Test String Substitute", 0, false},78 76 {NULL} 79 77 }; … … 711 709 return 0; 712 710 } 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 key721 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 key729 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 replace737 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 input745 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 string754 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 points763 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 points773 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.
