Changeset 2385
- Timestamp:
- Nov 18, 2004, 2:34:22 PM (22 years ago)
- Location:
- trunk/psLib/test/collections
- Files:
-
- 2 edited
-
tst_psArray.c (modified) (4 diffs)
-
verified/tst_psArray.stdout (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/collections/tst_psArray.c
r2354 r2385 8 8 * C) Reallocate void pointer array bigger 9 9 * D) Reallocate void pointer array smaller 10 * E) Free void pointer array 10 * E) Reallocate with null pointer 11 * F) Remove item from array 12 * G) Remove invalid item from array 13 * H) Remove item from null array 14 * I) Free void pointer array 11 15 * 12 16 * @author Ross Harman, MHPCC 13 17 * 14 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-11-1 2 22:28:16$18 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2004-11-19 00:34:22 $ 16 20 * 17 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 138 142 printFooter(stdout, "psArray", "Reallocate integer void pointer smaller", true); 139 143 140 // Test D1- Reallocate with a null144 // Test E - Reallocate with a null 141 145 printNegativeTestHeader(stdout,"psArray","Reallocate with a null array", 142 146 "Error message generator", 0 ); … … 148 152 printFooter(stdout,"psArray","Reallocate with a null array",true); 149 153 150 // Test E - Free void pointer array 154 155 // Test F - Remove item from array 156 printPositiveTestHeader(stdout, "psArray", "Remove valid item"); 157 if( !psArrayRemove(psArr,mySt[0]) ) { 158 psError(PS_ERR_UNKNOWN,true,"Unable to remove valid item"); 159 return 100; 160 } 161 printf("Array size after removal = %d\n",psArr->n); 162 if ( psArr->n != 2 ) { 163 psError(PS_ERR_UNKNOWN, true, "Items in array not decremented after removal"); 164 return 101; 165 } 166 for(psS32 i = 0; i < psArr->n; i++) { 167 testStruct *ts = (testStruct*)psArr->data[i]; 168 printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y); 169 if(fabsf(ts->x - 10*(i+1)) > 0.01f || fabsf(ts->y - 10.1*(i+1)) > 0.01f) { 170 psError(PS_ERR_UNKNOWN, true, "Elements not as expected after remove."); 171 return 102; 172 } 173 } 174 psFree(mySt[0]); 175 printFooter(stdout,"psArray","Remove valid item", true); 176 177 // Test G - Remove invalid item from array 178 printPositiveTestHeader(stdout, "psArray", "Remove invalid item from array"); 179 if( psArrayRemove(psArr,mySt[9]) ) { 180 psError(PS_ERR_UNKNOWN,true,"Removed invalid item from array"); 181 return 103; 182 } 183 printFooter(stdout,"psArray","Remove invalid item from array",true); 184 185 // Test H - Remove item from null array 186 printPositiveTestHeader(stdout, "psArray", "Remove item from null array"); 187 if ( psArrayRemove(NULL,mySt[1]) ) { 188 psError(PS_ERR_UNKNOWN,true,"Removed valid item from null array"); 189 return 104; 190 } 191 192 // Test I - Free void pointer array 151 193 printPositiveTestHeader(stdout, "psArray", "Free void pointer array"); 152 194 psFree(psArr); … … 154 196 psFree(mySt[i]); 155 197 } 156 psMemCheckLeaks(0, NULL, stdout); 198 if( psMemCheckLeaks(0, NULL, stdout) != 0) { 199 psError(PS_ERR_UNKNOWN,true,"Memory leaks detected."); 200 return 110; 201 } 157 202 psS32 nBad = psMemCheckCorruption(0); 158 203 if(nBad) { 159 204 printf("ERROR: Found %d bad memory blocks\n", nBad); 205 return 111; 160 206 } 161 207 printFooter(stdout, "psArray" ,"Free void pointer array", true); -
trunk/psLib/test/collections/verified/tst_psArray.stdout
r2354 r2385 73 73 /***************************** TESTPOINT ******************************************\ 74 74 * TestFile: tst_psArray.c * 75 * TestPoint: psArray{Remove valid item} * 76 * TestType: Positive * 77 \**********************************************************************************/ 78 79 Array size after removal = 2 80 ts[0].x = 10 ts[0].y = 10.10 81 ts[1].x = 20 ts[1].y = 20.20 82 83 ---> TESTPOINT PASSED (psArray{Remove valid item} | tst_psArray.c) 84 85 /***************************** TESTPOINT ******************************************\ 86 * TestFile: tst_psArray.c * 87 * TestPoint: psArray{Remove invalid item from array} * 88 * TestType: Positive * 89 \**********************************************************************************/ 90 91 92 ---> TESTPOINT PASSED (psArray{Remove invalid item from array} | tst_psArray.c) 93 94 /***************************** TESTPOINT ******************************************\ 95 * TestFile: tst_psArray.c * 96 * TestPoint: psArray{Remove item from null array} * 97 * TestType: Positive * 98 \**********************************************************************************/ 99 100 /***************************** TESTPOINT ******************************************\ 101 * TestFile: tst_psArray.c * 75 102 * TestPoint: psArray{Free void pointer array} * 76 103 * TestType: Positive *
Note:
See TracChangeset
for help on using the changeset viewer.
