Changeset 720
- Timestamp:
- May 18, 2004, 1:28:33 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImage.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImage.c
r717 r720 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-05-18 19:22:34$8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-05-18 23:28:33 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 19 19 #include <math.h> 20 20 #include <float.h> 21 #include <string.h> 21 22 22 23 static int testImageAlloc(void); 24 static int testImageSubset(void); 23 25 24 26 testDescription tests[] = { 25 27 {testImageAlloc,"546-testImageAlloc",0}, 28 {testImageSubset,"547-testImageSubset",0}, 26 29 {NULL} 27 30 }; … … 31 34 psSetLogLevel(PS_LOG_INFO); 32 35 33 testImage Alloc();36 testImageSubset(); 34 37 35 38 if (! runTestSuite(stderr,"psImage",tests)) { … … 221 224 } 222 225 226 // #547: psImageSubset shall create child image of a specified size from a parent psImage structure 227 int testImageSubset(void) 228 { 229 psImage preSubsetStruct; 230 psImage* original; 231 psImage* subset1 = NULL; 232 psImage* subset2 = NULL; 233 psImage* subset3 = NULL; 234 int c = 128; 235 int r = 256; 236 237 original = psImageAlloc(c,r,PS_TYPE_U32); 238 for (int row=0;row<r;row++) { 239 for (int col=0;col<c;col++) { 240 original->data.F32[row][col] = row*1000+col; 241 } 242 } 243 244 psLogMsg(__func__,PS_LOG_INFO,"memcpy(&preSubsetStruct,original,sizeof(psImage));"); 245 memcpy(&preSubsetStruct,original,sizeof(psImage)); 246 247 psLogMsg(__func__,PS_LOG_INFO,"subset1 = psImageAlloc(c/4,r/4,PS_TYPE_U8);"); 248 subset1 = psImageAlloc(c/4,r/4,PS_TYPE_U8); 249 250 psLogMsg(__func__,PS_LOG_INFO,"subset2 = psImageSubset(subset1,original,c/2,r/2,c/4,r/4);"); 251 subset2 = psImageSubset(subset1,original,c/2,r/2,c/4,r/4); 252 253 psLogMsg(__func__,PS_LOG_INFO,"subset3 = psImageSubset(NULL,original,c/2,r/2,0,0);"); 254 subset3 = psImageSubset(NULL,original,c/2,r/2,0,0); 255 256 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure is equal to the input psImage " 257 "structure parameter out, if input parameter out is specified."); 258 259 if (subset1 != subset2 || subset2 == NULL) { 260 psError(__func__,"psImageSubset didn't recycle the psImage given"); 261 return 1; 262 } 263 264 psLogMsg(__func__,PS_LOG_INFO,"Verify a new psImage structure is created, if input parameter out is set " 265 "to null."); 266 267 if (subset3 == NULL) { 268 psError(__func__,"psImageSubset output was NULL for subset3."); 269 return 2; 270 } 271 272 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure contains expected values in the " 273 "row member, if the input psImage structure image contains known values."); 274 275 for (int row=0;row<r/2;row++) { 276 for (int col=0;col<c/2;col++) { 277 if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) { 278 psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).", 279 row,col,subset2->data.U32[row][col], original->data.U32[row+r/4][col+c/4]); 280 return 3; 281 } 282 if (subset3->data.U32[row][col] != original->data.U32[row][col]) { 283 psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).", 284 row,col,subset2->data.U32[row][col], original->data.U32[row][col]); 285 return 4; 286 } 287 } 288 } 289 290 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure members nrow and ncol are equal to " 291 "the input parameter nrow and ncol respectively."); 292 293 if (subset3->numCols != c/2 || subset3->numRows != r/2) { 294 psError(__func__,"psImageSubset output size was not proper(%dx%d, should be %dx%d).", 295 subset3->numCols, subset3->numRows, c/2,r/2); 296 return 5; 297 } 298 299 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member type is equal to the input " 300 "psImage structure member type."); 301 302 if (subset2->type.type != PS_TYPE_U32) { 303 psError(__func__,"psImageSubset output type was not proper(%d, should be %d).", 304 subset2->type.type, PS_TYPE_U32); 305 return 6; 306 } 307 if (subset3->type.type != PS_TYPE_U32) { 308 psError(__func__,"psImageSubset output type was not proper(%d, should be %d).", 309 subset3->type.type, PS_TYPE_U32); 310 return 7; 311 } 312 313 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure members row0 and col0 are equal to " 314 "the input parameters row0 and col0 respectively."); 315 316 if (subset2->col0 != c/4 || subset2->row0 != r/4) { 317 psError(__func__,"psImageSubset didn't set col0/row0 for subset2 (%d/%d, should be %d/%d).", 318 subset2->col0,subset2->row0,c/4,r/4); 319 return 8; 320 } 321 if (subset3->col0 != 0 || subset3->row0 != 0) { 322 psError(__func__,"psImageSubset didn't set col0/row0 for subset3 (%d/%d, should be %d/%d).", 323 subset3->col0,subset3->row0,0,0); 324 return 9; 325 } 326 327 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member parent is equal to the " 328 "input psImage structure pointer image."); 329 330 if (subset2->parent != original || subset3->parent != original) { 331 psError(__func__,"psImageSubset didn't set parent."); 332 return 10; 333 } 334 335 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member Nchildren is equal to " 336 "zero."); 337 338 if (subset2->nChildren != 0 || subset3->nChildren != 0) { 339 psError(__func__,"psImageSubset didn't set nChildren to zero."); 340 return 11; 341 } 342 343 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure member children is null."); 344 345 if (subset2->children != NULL || subset3->children != NULL) { 346 psError(__func__,"psImageSubset didn't set children to NULL."); 347 return 11; 348 } 349 350 psLogMsg(__func__,PS_LOG_INFO,"Verify the input psImage structure image only has the following members " 351 "changed: 1) Nchildren is increased by one. 2) parent contains pointer psImage structure " 352 "out at parent[Nchildren-1]."); 353 354 if (original->nChildren != preSubsetStruct.nChildren+2) { 355 psError(__func__,"psImageSubset didn't increment nChildren by one per subset."); 356 return 12; 357 } 358 if (original->children[0] != subset2 || original->children[1] != subset3) { 359 psError(__func__,"psImageSubset didn't properly store the children pointers."); 360 return 13; 361 } 362 363 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure pointer is null and program " 364 "execution doesn't stop, if the input parameter image is null. Also verified the input " 365 "psImage structure is not modified."); 366 367 subset1 = psImageSubset(NULL,NULL,c/2,r/2,0,0); 368 if (subset1 != NULL) { 369 psError(__func__,"psImageSubset didn't return NULL when input image was NULL."); 370 return 14; 371 } 372 373 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure pointer is null and program " 374 " execution doesn't stop, if the input parameters nrow and/or ncol are zero. Also verify " 375 "input psImage structure is not modified."); 376 377 memcpy(&preSubsetStruct,original,sizeof(psImage)); 378 subset1 = psImageSubset(NULL,original,c/2,0,0,0); 379 if (subset1 != NULL) { 380 psError(__func__,"psImageSubset didn't return NULL when numRows=0."); 381 return 15; 382 } 383 subset1 = psImageSubset(NULL,original,0,r/2,0,0); 384 if (subset1 != NULL) { 385 psError(__func__,"psImageSubset didn't return NULL when numCols=0."); 386 return 16; 387 } 388 if (memcmp(original,&preSubsetStruct,sizeof(psImage)) != 0) { 389 psError(__func__,"psImageSubset changed the original struct though it failed to subset."); 390 return 17; 391 } 392 393 394 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure pointer is null and program " 395 "execution doesn't stop, if the input parameters row0 and col0 are not within the range of " 396 "values of psImage structure image."); 397 398 subset1 = psImageSubset(NULL,original,c/2,r/2,c,0); 399 if (subset1 != NULL) { 400 psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of " 401 "image (via cols)."); 402 return 18; 403 } 404 subset1 = psImageSubset(NULL,original,c/2,r/2,0,r); 405 if (subset1 != NULL) { 406 psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of " 407 "image (via rows)."); 408 return 19; 409 } 410 subset1 = psImageSubset(NULL,original,c/2,r/2,-1,0); 411 if (subset1 != NULL) { 412 psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of " 413 "image (col0=-1)."); 414 return 20; 415 } 416 subset1 = psImageSubset(NULL,original,c/2,r/2,0,-1); 417 if (subset1 != NULL) { 418 psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of " 419 "image (row0=-1)."); 420 return 21; 421 } 422 423 psLogMsg(__func__,PS_LOG_INFO,"Verify the returned psImage structure pointer is null and program " 424 "execution doesn't stop if the input parameters nrow, ncol, row0 and col0 specify a range of " 425 "data not within the input psImage structure image. Also verify the input psImage structure " 426 "is not modified."); 427 428 subset1 = psImageSubset(NULL,original,c/2,r/2,c/2,0); 429 if (subset1 != NULL) { 430 psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via rows)."); 431 return 22; 432 } 433 subset1 = psImageSubset(NULL,original,c/2,r/2,0,r/2); 434 if (subset1 != NULL) { 435 psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via cols)."); 436 return 23; 437 } 438 subset1 = psImageSubset(NULL,original,c/2,r/2,c/2,r/2); 439 if (subset1 != NULL) { 440 psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via row+cols)."); 441 return 24; 442 } 443 444 return 0; 445 } 446
Note:
See TracChangeset
for help on using the changeset viewer.
