Changeset 3291
- Timestamp:
- Feb 18, 2005, 2:43:32 PM (21 years ago)
- Location:
- trunk/psLib/test/dataManip
- Files:
-
- 2 edited
-
tst_psMatrix07.c (modified) (12 diffs)
-
verified/tst_psMatrix07.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix07.c
r3264 r3291 16 16 * @author Ross Harman, MHPCC 17 17 * 18 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $19 * @date $Date: 2005-02-1 7 19:26:25$18 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2005-02-19 00:43:32 $ 20 20 * 21 21 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 39 39 } else if(IMAGE->type.type == PS_TYPE_F32){ \ 40 40 if(fabs(IMAGE->data.F32[i][j]-TRUTH[i][j]) > TOLERANCE) { \ 41 printf("Matrix values at element %d, %d don't agree %f vs % lf\n", i, j, \41 printf("Matrix values at element %d, %d don't agree %f vs %f\n", i, j, \ 42 42 IMAGE->data.F32[i][j], TRUTH[i][j]); \ 43 43 } \ … … 54 54 } \ 55 55 } else if(VECTOR->type.type == PS_TYPE_F32){ \ 56 if(fabs(VECTOR->data.F32[i]-truthVector [i]) > TOLERANCE) { \56 if(fabs(VECTOR->data.F32[i]-truthVector_32[i]) > TOLERANCE) { \ 57 57 printf("Vector values at element %d don't agree %f vs %lf\n", i, \ 58 58 VECTOR->data.F32[i], truthVector[i]); \ … … 65 65 { 66 66 psVector *v1 = NULL; 67 psVector *v1_32 = NULL; 67 68 psVector *tempVector = NULL; 69 psVector *tempVector_32 = NULL; 68 70 psImage *tempImage = NULL; 71 psImage *tempImage_32 = NULL; 69 72 psImage *m1 = NULL; 73 psImage *m1_32 = NULL; 70 74 psVector *v2 = NULL; 75 psVector *v2_32 = NULL; 71 76 psVector *v3 = NULL; 77 psVector *v3_32 = NULL; 72 78 psImage *m2 = NULL; 79 psImage *m2_32 = NULL; 73 80 psImage *m3 = NULL; 81 psImage *m3_32 = NULL; 74 82 psImage *m4 = NULL; 83 psImage *m4_32 = NULL; 75 84 psImage *badImage = NULL; 76 77 double truthVector[3] = {0.0, 1.0, 2.0}; 78 double truthMatrix[3][1] = {{0.0}, {1.0}, {2.0}}; 85 psImage *badImage_32 = NULL; 86 87 psF64 truthVector[3] = {0.0, 1.0, 2.0}; 88 psF32 truthVector_32[3] = {0.0, 1.0, 2.0}; 89 psF64 truthMatrix[3][1] = {{0.0}, {1.0}, {2.0}}; 90 psF32 truthMatrix_32[3][1] = {{0.0}, {1.0}, {2.0}}; 79 91 80 92 // Test A - Create input and output images 81 93 printPositiveTestHeader(stdout, "psMatrix", "Create input and output images and vectors"); 82 94 v1 = (psVector*)psVectorAlloc(3, PS_TYPE_F64); 95 v1_32 = (psVector*)psVectorAlloc(3, PS_TYPE_F32); 83 96 m1 = (psImage*)psImageAlloc(1, 3, PS_TYPE_F64); 97 m1_32 = (psImage*)psImageAlloc(1,3,PS_TYPE_F32); 84 98 v2 = (psVector*)psVectorAlloc(3, PS_TYPE_F64); 99 v2_32 = (psVector*)psVectorAlloc(3,PS_TYPE_F32); 85 100 m2 = (psImage*)psImageAlloc(1, 3, PS_TYPE_F64); 101 m2_32 = (psImage*)psImageAlloc(1,3,PS_TYPE_F32); 86 102 m3 = (psImage*)psImageAlloc(3, 1, PS_TYPE_F64); 103 m3_32 = (psImage*)psImageAlloc(3,1,PS_TYPE_F32); 87 104 m4 = (psImage*)psImageAlloc(3, 1, PS_TYPE_F64); 105 m4_32 = (psImage*)psImageAlloc(3,1,PS_TYPE_F32); 88 106 badImage = (psImage*)psImageAlloc(2, 2, PS_TYPE_F64); 107 badImage_32 = (psImage*)psImageAlloc(2,2,PS_TYPE_F32); 89 108 m1->data.F64[0][0] = 0.0; 90 109 m1->data.F64[1][0] = 1.0; 91 110 m1->data.F64[2][0] = 2.0; 111 m1_32->data.F32[0][0] = 0.0; 112 m1_32->data.F32[1][0] = 1.0; 113 m1_32->data.F32[2][0] = 2.0; 92 114 v2->data.F64[0] = 0.0; 93 115 v2->data.F64[1] = 1.0; 94 116 v2->data.F64[2] = 2.0; 95 117 v2->n = 3; 118 v2_32->data.F32[0] = 0.0; 119 v2_32->data.F32[1] = 1.0; 120 v2_32->data.F32[2] = 2.0; 121 v2_32->n = 3; 96 122 m4->data.F64[0][0] = 0.0; 97 123 m4->data.F64[0][1] = 1.0; 98 124 m4->data.F64[0][2] = 2.0; 125 m4_32->data.F32[0][0] = 0.0; 126 m4_32->data.F32[0][1] = 1.0; 127 m4_32->data.F32[0][2] = 2.0; 99 128 printFooter(stdout, "psMatrix", "Create input and output images and vectors", true); 100 101 129 102 130 // Test B - Convert matrix to PS_DIMEN_VECTOR vector … … 106 134 CHECK_VECTOR(v1); 107 135 if(v1->type.dimen != PS_DIMEN_VECTOR) { 108 printf("Error: Resulting image is not PS_DIMEN_VECTOR\n"); 136 psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_VECTOR"); 137 return 1; 109 138 } else if(v1 != tempVector) { 110 printf("Error: Return pointer not equal to output argument pointer\n"); 139 psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer"); 140 return 2; 141 } 142 tempVector_32 = v1_32; 143 v1_32 = psMatrixToVector(v1_32, m1_32); 144 CHECK_VECTOR(v1_32); 145 if(v1_32->type.dimen != PS_DIMEN_VECTOR) { 146 psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_VECTOR"); 147 return 1; 148 } else if(v1_32 != tempVector_32) { 149 psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer"); 150 return 2; 111 151 } 112 152 printFooter(stdout, "psMatrix", "Convert matrix to PS_DIMEN_VECTOR vector", true); … … 116 156 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null image input argument", 117 157 "Invalid operation: inImage or its data is NULL.", 0); 158 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error."); 118 159 v1 = psMatrixToVector(v1, NULL); 160 if(v1 != NULL) { 161 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with NULL input"); 162 return 3; 163 } 164 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error."); 165 v1_32 = psMatrixToVector(v1_32, NULL); 166 if(v1_32 != NULL) { 167 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with NULL input"); 168 return 3; 169 } 119 170 printFooter(stdout, "psMatrix", "Attempt to use null image input argument", true); 120 171 … … 123 174 printPositiveTestHeader(stdout, "psMatrix", "Convert matrix to PS_DIMEN_TRANSV vector"); 124 175 v3 = psVectorAlloc(3, PS_TYPE_F64); 176 tempVector = v3; 125 177 v3->type.dimen = PS_DIMEN_TRANSV; 126 178 psMatrixToVector(v3, m4); 127 179 CHECK_VECTOR(v3); 128 180 if(v3->type.dimen != PS_DIMEN_TRANSV) { 129 printf("Error: Resulting image is not PS_DIMEN_TRANSV\n"); 181 psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_TRANSV"); 182 return 4; 130 183 } else if(v3 != tempVector) { 131 printf("Error: Return pointer not equal to output argument pointer\n"); 184 psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer"); 185 return 5; 186 } 187 v3_32 = psVectorAlloc(3, PS_TYPE_F32); 188 tempVector_32 = v3_32; 189 v3_32->type.dimen = PS_DIMEN_TRANSV; 190 psMatrixToVector(v3_32, m4_32); 191 CHECK_VECTOR(v3_32); 192 if(v3_32->type.dimen != PS_DIMEN_TRANSV) { 193 psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_TRANSV"); 194 return 6; 195 } else if(v3_32 != tempVector_32) { 196 psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer"); 197 return 7; 132 198 } 133 199 printFooter(stdout, "psMatrix", "Convert matrix to PS_DIMEN_TRANSV vector", true); … … 137 203 printNegativeTestHeader(stdout,"psMatrix", "Improper image size", 138 204 "Image does not have dim with 1 col or 1 row: (2 x 2).", 0); 139 psMatrixToVector(v1, badImage); 205 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 206 if(psMatrixToVector(v1, badImage) != NULL ) { 207 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with improper sizes"); 208 return 8; 209 } 210 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 211 if(psMatrixToVector(v1_32, badImage_32) != NULL ) { 212 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with improper sizes"); 213 return 9; 214 } 140 215 printFooter(stdout, "psMatrix", "Improper image size", true); 141 216 … … 147 222 CHECK_MATRIX(m2,truthMatrix); 148 223 if(m2->type.dimen != PS_DIMEN_IMAGE) { 149 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 224 psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_IMAGE"); 225 return 10; 150 226 } else if(m2 != tempImage) { 151 printf("Error: Return pointer not equal to output argument pointer\n"); 227 psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer"); 228 return 11; 229 } 230 tempImage_32 = m2_32; 231 m2_32 = psVectorToMatrix(m2_32, v2_32); 232 CHECK_MATRIX(m2_32,truthMatrix_32); 233 if(m2_32->type.dimen != PS_DIMEN_IMAGE) { 234 psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_IMAGE"); 235 return 10; 236 } else if(m2_32 != tempImage_32) { 237 psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer"); 238 return 11; 152 239 } 153 240 printFooter(stdout, "psMatrix", "Convert PS_DIMEN_VECTOR vector to matrix", true); … … 157 244 printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null input vector argument", 158 245 "Invalid operation: inVector or its data is NULL.", 0); 159 psVectorToMatrix(m2, NULL); 246 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 247 if(psVectorToMatrix(m2, NULL) != m2) { 248 psError(PS_ERR_UNKNOWN,true,"Did not return output image"); 249 return 12; 250 } 251 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 252 if(psVectorToMatrix(m2_32, NULL) != m2_32) { 253 psError(PS_ERR_UNKNOWN,true,"Did not return output image"); 254 return 13; 255 } 160 256 printFooter(stdout, "psMatrix", "Attempt to use null input vector argument", true); 161 257 … … 168 264 CHECK_MATRIX(m3, truthMatrix); 169 265 if(m3->type.dimen != PS_DIMEN_IMAGE) { 170 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n"); 266 psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_IMAGE"); 267 return 14; 171 268 } else if(m3 != tempImage) { 172 printf("Error: Return pointer not equal to output argument pointer\n"); 269 psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer"); 270 return 15; 271 } 272 v2_32->type.dimen = PS_DIMEN_TRANSV; 273 tempImage_32 = m3_32; 274 psVectorToMatrix(m3_32, v2_32); 275 CHECK_MATRIX(m3_32, truthMatrix_32); 276 if(m3_32->type.dimen != PS_DIMEN_IMAGE) { 277 psError(PS_ERR_UNKNOWN,true,"Resulting image is not PS_DIMEN_IMAGE"); 278 return 16; 279 } else if(m3_32 != tempImage_32) { 280 psError(PS_ERR_UNKNOWN,true,"Return pointer not equal to output argument pointer"); 281 return 17; 173 282 } 174 283 printFooter(stdout, "psMatrix", "Convert PS_DIMEN_TRANSV vector to matrix", true); … … 184 293 psFree(m3); 185 294 psFree(m4); 295 psFree(m1_32); 296 psFree(v1_32); 297 psFree(m2_32); 298 psFree(v2_32); 299 psFree(v3_32); 300 psFree(m3_32); 301 psFree(m4_32); 186 302 psFree(badImage); 303 psFree(badImage_32); 187 304 if( psMemCheckLeaks(0, NULL, stdout, false) != 0) { 188 305 psError(PS_ERR_UNKNOWN,true,"Memory leaks detected."); -
trunk/psLib/test/dataManip/verified/tst_psMatrix07.stderr
r3127 r3291 1 <DATE><TIME>|<HOST>|I|main 2 Following should generate an error. 1 3 <DATE><TIME>|<HOST>|E|psMatrixToVector (FILE:LINENO) 2 4 Unallowable operation: psImage inImage or its data is NULL. 5 <DATE><TIME>|<HOST>|I|main 6 Following should generate an error. 7 <DATE><TIME>|<HOST>|E|psMatrixToVector (FILE:LINENO) 8 Unallowable operation: psImage inImage or its data is NULL. 9 <DATE><TIME>|<HOST>|I|main 10 Following should generate error message 3 11 <DATE><TIME>|<HOST>|E|psMatrixToVector (FILE:LINENO) 4 12 Image does not have dim with 1 col or 1 row: (2 x 2). 13 <DATE><TIME>|<HOST>|I|main 14 Following should generate error message 15 <DATE><TIME>|<HOST>|E|psMatrixToVector (FILE:LINENO) 16 Image does not have dim with 1 col or 1 row: (2 x 2). 17 <DATE><TIME>|<HOST>|I|main 18 Following should generate an error message 5 19 <DATE><TIME>|<HOST>|E|psVectorToMatrix (FILE:LINENO) 6 20 Unallowable operation: psVector inVector or its data is NULL. 21 <DATE><TIME>|<HOST>|I|main 22 Following should generate an error message 23 <DATE><TIME>|<HOST>|E|psVectorToMatrix (FILE:LINENO) 24 Unallowable operation: psVector inVector or its data is NULL.
Note:
See TracChangeset
for help on using the changeset viewer.
