Changeset 7831 for trunk/psLib/test/sys
- Timestamp:
- Jul 6, 2006, 12:26:13 PM (20 years ago)
- Location:
- trunk/psLib/test/sys
- Files:
-
- 2 edited
-
tst_psString.c (modified) (4 diffs)
-
verified/tst_psString.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sys/tst_psString.c
r7418 r7831 20 20 * @author Eric Van Alst, MHPCC 21 21 * 22 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $23 * @date $Date: 2006-0 6-08 01:06:36$22 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 23 * @date $Date: 2006-07-06 22:26:13 $ 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); 55 56 56 57 testDescription tests[] = { … … 74 75 {testStrSplit00,15, "Test String Splitting", 0, false}, 75 76 {testNULLStrings,666, "Test NULL String Error Handling", 0, false}, 77 {testStrSub,16, "Test String Substitute", 0, false}, 76 78 {NULL} 77 79 }; … … 710 712 } 711 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 } -
trunk/psLib/test/sys/verified/tst_psString.stderr
r7418 r7831 175 175 ---> TESTPOINT PASSED (psString{Test NULL String Error Handling} | tst_psString.c) 176 176 177 /***************************** TESTPOINT ******************************************\ 178 * TestFile: tst_psString.c * 179 * TestPoint: psString{Test String Substitute} * 180 * TestType: Positive * 181 \**********************************************************************************/ 182 183 <DATE><TIME>|<HOST>|I|testStrSub 184 Following should generate error message 185 <DATE><TIME>|<HOST>|E|psStringSubstitute (FILE:LINENO) 186 Invalid string in psStringSubstitute. Input cannot be NULL or empty. 187 <DATE><TIME>|<HOST>|I|testStrSub 188 Following should generate error message 189 <DATE><TIME>|<HOST>|E|psStringSubstitute (FILE:LINENO) 190 Invalid string in psStringSubstitute. Input cannot be NULL or empty. 191 192 ---> TESTPOINT PASSED (psString{Test String Substitute} | tst_psString.c) 193
Note:
See TracChangeset
for help on using the changeset viewer.
