Changeset 543 for trunk/psLib/test/sysUtils/tst_psString.c
- Timestamp:
- Apr 28, 2004, 12:00:02 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sysUtils/tst_psString.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sysUtils/tst_psString.c
r532 r543 11 11 * 5) Copy string to larger string - psStringNCopy 12 12 * 6) Copy string with negative size - psStringNCopy 13 13 * 14 14 * Return: Number of test points which failed 15 15 * 16 16 * @author Eric Van Alst, MHPCC 17 17 * 18 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $19 * @date $Date: 2004-04-2 7 22:57:09$18 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2004-04-28 22:00:02 $ 20 20 * 21 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 #include "psTest.h" 28 28 29 int main(void) 29 int main( int argc, 30 char * argv[] ) 30 31 { 31 32 bool tpResult = false; … … 38 39 int increaseSize = 5; 39 40 int negativeSize = -5; 41 int result = 0; 42 int result1 = 0; 40 43 41 44 // Test point #1 Verify string copy - psStringCopy 42 45 printPositiveTestHeader(stderr,"psStringCopy","Verify string copy"); 43 46 strResult = psStringCopy(stringval); 44 if ( strcmp(strResult, stringval) != 0 ) { 47 // Perform string compare 48 result = strcmp(strResult, stringval); 49 if ( result != 0 ) { 50 fprintf(stderr, "Failed test point #1 strcmp result = %d expected 0\n",result); 45 51 tpResult = false; 46 52 tpFails++; … … 53 59 printPositiveTestHeader(stderr,"psStringCopy","Verify empty string copy"); 54 60 strResult = psStringCopy(emptyval); 55 if ( strcmp(strResult, emptyval) != 0 ) { 61 // Perform string compare 62 result = strcmp(strResult, emptyval); 63 if ( result != 0 ) { 64 fprintf(stderr,"Failed test point #2 strcmp result = %d expected 0\n",result); 56 65 tpResult = false; 57 66 tpFails++; … … 64 73 printPositiveTestHeader(stderr,"psStringNCopy","Verify string copy with length"); 65 74 strResult = psStringNCopy(stringval, substringlen); 66 if ( strcmp(strResult, substringval) != 0 ) { 75 // Perform string compare and get string length 76 result = strcmp(strResult, substringval); 77 result1 = strlen(strResult); 78 if ( ( result != 0 ) || 79 ( result1 != substringlen ) ) { 80 fprintf(stderr,"Failed test point #3 strcmp result = %d expected 0\n",result); 81 fprintf(stderr," strlen result = %d expected %d\n", 82 result1, substringlen); 67 83 tpResult = false; 68 84 tpFails++; … … 75 91 printPositiveTestHeader(stderr,"psStringNCopy", "Verify empty string copy with length"); 76 92 strResult = psStringNCopy(stringval, 0); 77 if ( (strcmp(strResult, emptyval) != 0 ) || 78 (strlen(strResult) != strlen(emptyval) ) ) { 93 // Perform string compare and get sting length 94 result = strcmp(strResult, emptyval); 95 result1 = strlen(strResult); 96 if ( ( result != 0 ) || 97 ( result1 != strlen(emptyval) ) ) { 98 fprintf(stderr,"Failed test point #4 strcmp result = %d expected %d\n",result,0); 99 fprintf(stderr," strlen result = %d expected %d\n",result1, 100 (int)strlen(emptyval)); 79 101 tpResult = false; 80 102 tpFails++; … … 87 109 printPositiveTestHeader(stderr,"psStringNCopy", "Copy string to larger string"); 88 110 strResult = psStringNCopy(stringval, (strlen(stringval) + increaseSize)); 111 // Perform string compare and get string length 112 result = strcmp(strResult, stringval); 113 result1 = strlen(strResult); 89 114 // The strings should still compare 90 if ( ( strcmp(strResult, stringval) != 0 ) || 91 ( strlen(strResult) != strlen(stringval) ) ) { 115 if ( ( result != 0 ) || 116 ( result1 != strlen(stringval) ) ) { 117 fprintf(stderr,"Failed test point #5 strcmp result = %d expected %d\n",result,0); 118 fprintf(stderr," strlne result = %d expected %d\n",result1, 119 (int)strlen(stringval)); 92 120 tpResult = false; 93 121 tpFails++; … … 101 129 strResult = psStringNCopy(stringval, negativeSize); 102 130 if ( strResult != NULL ) { 131 fprintf(stderr,"Failed test point #6 return value = %ld expected NULL\n", 132 (unsigned long)strResult); 103 133 tpResult = false; 104 134 tpFails++; … … 108 138 printFooter(stderr, "psStringNCopy", "Copy string with negative size", tpResult); 109 139 140 // Display test driver fail message if tpFail not zero 141 if ( tpFails != 0 ) { 142 fprintf(stderr,"Failed test driver testpoint fail = %d expected %d\n", 143 tpFails, 0); 144 } 145 110 146 // Return number of test points which failed 111 147 return tpFails;
Note:
See TracChangeset
for help on using the changeset viewer.
