Changeset 3625 for trunk/psModules/test/tst_pmObjects01.c
- Timestamp:
- Apr 1, 2005, 10:47:40 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/tst_pmObjects01.c (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/tst_pmObjects01.c
r3576 r3625 19 19 * abd never deallocate, no error is generated. 20 20 * 21 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $22 * @date $Date: 2005-0 3-31 00:22:49$21 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2005-04-01 20:47:40 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 63 63 { 64 64 return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv); 65 test02(); 65 66 } 66 67 … … 153 154 154 155 #define VECTOR_SIZE 10 155 bool test_pmFindVectorPe eks(int n)156 bool test_pmFindVectorPeaks(int n) 156 157 { 157 158 bool testStatus = true; … … 159 160 psVector *outData = NULL; 160 161 161 printf("-------------- Calling test_pmFindVectorPe eks on an %d size vector. --------------\n", n);162 printf("-------------- Calling test_pmFindVectorPeaks on an %d size vector. --------------\n", n); 162 163 // 163 164 // Test first pixel peak. 164 165 // 165 printf("Test pmFindVectorPe eks() with a first-element peak.\n");166 printf("Test pmFindVectorPeaks() with a first-element peak.\n"); 166 167 for (psS32 i = 0 ; i < n ; i++) { 167 168 inData->data.F32[i] = (float) (n-i); … … 169 170 inData->data.F32[0] = (float) n; 170 171 171 outData= pmFindVectorPe eks(inData, 0.0);172 outData= pmFindVectorPeaks(inData, 0.0); 172 173 if (outData == NULL) { 173 printf("TEST ERROR: pmFindVectorPe eks returned a NULL psVector.\n");174 printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n"); 174 175 testStatus = false; 175 176 } else { … … 189 190 // Test first pixel peak, large threshold 190 191 // 191 printf("Test pmFindVectorPe eks() with a first-element peak, large threshold.\n");192 printf("Test pmFindVectorPeaks() with a first-element peak, large threshold.\n"); 192 193 for (psS32 i = 0 ; i < n ; i++) { 193 194 inData->data.F32[i] = (float) (n-i); … … 195 196 inData->data.F32[0] = (float) n; 196 197 197 outData= pmFindVectorPe eks(inData, (float) (n*n));198 outData= pmFindVectorPeaks(inData, (float) (n*n)); 198 199 if (outData == NULL) { 199 printf("TEST ERROR: pmFindVectorPe eks returned a NULL psVector.\n");200 printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n"); 200 201 testStatus = false; 201 202 } else { … … 217 218 // Test last pixel peak. 218 219 // 219 printf("Test pmFindVectorPe eks() with a last-element peak.\n");220 printf("Test pmFindVectorPeaks() with a last-element peak.\n"); 220 221 for (psS32 i = 0 ; i < n ; i++) { 221 222 inData->data.F32[i] = (float) (i); … … 223 224 inData->data.F32[n-1] = (float) n; 224 225 225 outData= pmFindVectorPe eks(inData, 0.0);226 outData= pmFindVectorPeaks(inData, 0.0); 226 227 if (outData == NULL) { 227 printf("TEST ERROR: pmFindVectorPe eks returned a NULL psVector.\n");228 printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n"); 228 229 testStatus = false; 229 230 } else { … … 243 244 // Test last pixel peak, large threshold. 244 245 // 245 printf("Test pmFindVectorPe eks() with a last-element peak, large threshold.\n");246 printf("Test pmFindVectorPeaks() with a last-element peak, large threshold.\n"); 246 247 for (psS32 i = 0 ; i < n ; i++) { 247 248 inData->data.F32[i] = (float) (i); … … 249 250 inData->data.F32[n-1] = (float) n; 250 251 251 outData= pmFindVectorPe eks(inData, (float) (n*n));252 outData= pmFindVectorPeaks(inData, (float) (n*n)); 252 253 if (outData == NULL) { 253 printf("TEST ERROR: pmFindVectorPe eks returned a NULL psVector.\n");254 printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n"); 254 255 testStatus = false; 255 256 } else { … … 266 267 // Set all even number elements to be peaks. 267 268 // 268 printf("Test pmFindVectorPe eks() with all even-numbered elements peak.\n");269 printf("Test pmFindVectorPeaks() with all even-numbered elements peak.\n"); 269 270 for (psS32 i = 0 ; i < n ; i++) { 270 271 if (0 == i%2) { … … 277 278 278 279 279 outData= pmFindVectorPe eks(inData, 0.0);280 outData= pmFindVectorPeaks(inData, 0.0); 280 281 if (outData == NULL) { 281 printf("TEST ERROR: pmFindVectorPe eks returned a NULL psVector.\n");282 printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n"); 282 283 testStatus = false; 283 284 } else { … … 301 302 // Should generate an empty output psVector. 302 303 // 303 printf("Test pmFindVectorPe eks() with all even-numbered elements peak, large threshold.\n");304 outData= pmFindVectorPe eks(inData, (float) (n*n));304 printf("Test pmFindVectorPeaks() with all even-numbered elements peak, large threshold.\n"); 305 outData= pmFindVectorPeaks(inData, (float) (n*n)); 305 306 if (outData == NULL) { 306 printf("TEST ERROR: pmFindVectorPe eks returned a NULL psVector.\n");307 printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n"); 307 308 testStatus = false; 308 309 } else { … … 331 332 332 333 printf("----------------------------------------------------------------------------------\n"); 333 printf("Calling pmFindVectorPe eks with NULL psVector. Should generate error and return NULL.\n");334 tmpVec = pmFindVectorPe eks(NULL, 0.0);334 printf("Calling pmFindVectorPeaks with NULL psVector. Should generate error and return NULL.\n"); 335 tmpVec = pmFindVectorPeaks(NULL, 0.0); 335 336 if (tmpVec != NULL) { 336 printf("TEST ERROR: pmFindVectorPe eks() returned a non-NULL psVector.\n");337 printf("TEST ERROR: pmFindVectorPeaks() returned a non-NULL psVector.\n"); 337 338 testStatus = false; 338 339 psFree(tmpVec); … … 340 341 341 342 printf("----------------------------------------------------------------------------------\n"); 342 printf("Calling pmFindVectorPe eks with empty psVector. Should generate error and return NULL.\n");343 tmpVec = pmFindVectorPe eks(tmpVecEmpty, 0.0);343 printf("Calling pmFindVectorPeaks with empty psVector. Should generate error and return NULL.\n"); 344 tmpVec = pmFindVectorPeaks(tmpVecEmpty, 0.0); 344 345 if (tmpVec != NULL) { 345 printf("TEST ERROR: pmFindVectorPe eks() returned a non-NULL psVector.\n");346 printf("TEST ERROR: pmFindVectorPeaks() returned a non-NULL psVector.\n"); 346 347 testStatus = false; 347 348 psFree(tmpVec); … … 349 350 350 351 printf("----------------------------------------------------------------------------------\n"); 351 printf("Calling pmFindVectorPe eks with PS_TYPE_F64 psVector. Should generate error and return NULL.\n");352 tmpVec = pmFindVectorPe eks(tmpVecF64, 0.0);352 printf("Calling pmFindVectorPeaks with PS_TYPE_F64 psVector. Should generate error and return NULL.\n"); 353 tmpVec = pmFindVectorPeaks(tmpVecF64, 0.0); 353 354 if (tmpVec != NULL) { 354 printf("TEST ERROR: pmFindVectorPe eks() returned a non-NULL psVector.\n");355 printf("TEST ERROR: pmFindVectorPeaks() returned a non-NULL psVector.\n"); 355 356 testStatus = false; 356 357 psFree(tmpVec); 357 358 } 358 testStatus&= test_pmFindVectorPe eks(1);359 testStatus&= test_pmFindVectorPe eks(VECTOR_SIZE);359 testStatus&= test_pmFindVectorPeaks(1); 360 testStatus&= test_pmFindVectorPeaks(VECTOR_SIZE); 360 361 361 362 psFree(tmpVecF64); … … 366 367 // XXX: Add tests for the PEAK_TYPE. 367 368 // XXX: Add interior peaks, edge peaks, and flat peaks. 368 bool test_pmFindImagePe eks(int numRows, int numCols)369 bool test_pmFindImagePeaks(int numRows, int numCols) 369 370 { 370 printf("-------------- Calling test_pmFindVectorPe eks on an %d-by-%d image. --------------\n", numRows, numCols);371 printf("-------------- Calling test_pmFindVectorPeaks on an %d-by-%d image. --------------\n", numRows, numCols); 371 372 bool testStatus = true; 372 373 psImage *inData = psImageAlloc(numCols, numRows, PS_TYPE_F32); … … 392 393 } 393 394 394 outData = pmFindImagePe eks(inData, 0.0);395 outData = pmFindImagePeaks(inData, 0.0); 395 396 396 397 if (outData == NULL) { 397 printf("TEST ERROR: pmFindImagePe eks returned a NULL psList.\n");398 printf("TEST ERROR: pmFindImagePeaks returned a NULL psList.\n"); 398 399 testStatus = false; 399 400 } else { 400 401 if (outData->size != 4) { 401 printf("TEST ERROR: pmFindImagePe eks found only %d peaks (should be 4)\n", outData->size);402 printf("TEST ERROR: pmFindImagePeaks found only %d peaks (should be 4)\n", outData->size); 402 403 testStatus = false; 403 404 } 404 405 406 //HEY 405 407 psListElem *tmpPeakLE = (psListElem *) outData->head; 406 408 while (tmpPeakLE != NULL) { … … 409 411 ((tmpPeak->y == 0) || (tmpPeak->y == numCols-1))) {} 410 412 else { 411 printf("TEST ERROR: Peak at (%d, %d) \n", tmpPeak->x, tmpPeak->y);413 printf("TEST ERROR: Peak at (%d, %d) (%f)\n", tmpPeak->x, tmpPeak->y, tmpPeak->counts); 412 414 testStatus = false; 413 415 } … … 432 434 433 435 printf("----------------------------------------------------------------------------------\n"); 434 printf("Calling pmFindImagePe eks with NULL psImage. Should generate error and return NULL.\n");435 tmpList = pmFindImagePe eks(NULL, 0.0);436 printf("Calling pmFindImagePeaks with NULL psImage. Should generate error and return NULL.\n"); 437 tmpList = pmFindImagePeaks(NULL, 0.0); 436 438 if (tmpList != NULL) { 437 printf("TEST ERROR: pmFindImagePe eks() returned a non-NULL psImage.\n");439 printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n"); 438 440 testStatus = false; 439 441 psFree(tmpList); … … 441 443 442 444 printf("----------------------------------------------------------------------------------\n"); 443 printf("Calling pmFindImagePe eks with empty psImage. Should generate error and return NULL.\n");444 tmpList = pmFindImagePe eks(tmpImageEmpty, 0.0);445 printf("Calling pmFindImagePeaks with empty psImage. Should generate error and return NULL.\n"); 446 tmpList = pmFindImagePeaks(tmpImageEmpty, 0.0); 445 447 if (tmpList != NULL) { 446 printf("TEST ERROR: pmFindImagePe eks() returned a non-NULL psImage.\n");448 printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n"); 447 449 testStatus = false; 448 450 psFree(tmpList); … … 450 452 451 453 printf("----------------------------------------------------------------------------------\n"); 452 printf("Calling pmFindImagePe eks with PS_TYPE_F64 psImage. Should generate error and return NULL.\n");453 tmpList = pmFindImagePe eks(tmpImageF64, 0.0);454 printf("Calling pmFindImagePeaks with PS_TYPE_F64 psImage. Should generate error and return NULL.\n"); 455 tmpList = pmFindImagePeaks(tmpImageF64, 0.0); 454 456 if (tmpList != NULL) { 455 printf("TEST ERROR: pmFindImagePe eks() returned a non-NULL psImage.\n");457 printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n"); 456 458 testStatus = false; 457 459 psFree(tmpList); 458 460 } 459 461 printf("----------------------------------------------------------------------------------\n"); 460 // testStatus&= test_pmFindImagePe eks(1, 1);461 // testStatus&= test_pmFindImagePe eks(2, 5);462 // testStatus&= test_pmFindImagePe eks(5, 2);463 testStatus&= test_pmFindImagePe eks(10, 10);462 // testStatus&= test_pmFindImagePeaks(1, 1); 463 // testStatus&= test_pmFindImagePeaks(2, 5); 464 // testStatus&= test_pmFindImagePeaks(5, 2); 465 testStatus&= test_pmFindImagePeaks(10, 10); 464 466 465 467 … … 470 472 471 473 /****************************************************************************** 472 test03(): We first test pmCullPe eks() with various NULL and unallowable input473 parameters. Then we generate a list of peaks and test that pmCullPe eks()474 test03(): We first test pmCullPeaks() with various NULL and unallowable input 475 parameters. Then we generate a list of peaks and test that pmCullPeaks() 474 476 removes them correctly. 475 477 *****************************************************************************/ … … 481 483 482 484 printf("----------------------------------------------------------------------------------\n"); 483 printf("Calling pmCullPe eks with NULL psList. Should generate error and return NULL.\n");484 outData = pmCullPe eks(NULL, 0.0, NULL);485 printf("Calling pmCullPeaks with NULL psList. Should generate error and return NULL.\n"); 486 outData = pmCullPeaks(NULL, 0.0, NULL); 485 487 if (outData != NULL) { 486 printf("TEST ERROR: pmCulPe eks() returned a non-NULL psList.\n");488 printf("TEST ERROR: pmCulPeaks() returned a non-NULL psList.\n"); 487 489 testStatus = false; 488 490 } … … 512 514 513 515 // 514 // Call pmCullPe eks() with HUGE maxValue and NULL psRegion. Should not516 // Call pmCullPeaks() with HUGE maxValue and NULL psRegion. Should not 515 517 // remove any peaks. 516 518 // 517 519 printf("----------------------------------------------------------------------------------\n"); 518 printf("Calling pmCullPe eks with large maxValue and NULL psRegion.\n");519 outData = pmFindImagePe eks(imgData, 0.0);520 outData = pmCullPe eks(outData, PS_MAX_F32, NULL);520 printf("Calling pmCullPeaks with large maxValue and NULL psRegion.\n"); 521 outData = pmFindImagePeaks(imgData, 0.0); 522 outData = pmCullPeaks(outData, PS_MAX_F32, NULL); 521 523 522 524 if (outData == NULL) { 523 printf("TEST ERROR: pmCullPe eks() returned a non-NULL psList.\n");525 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 524 526 testStatus = false; 525 527 return(testStatus); 526 528 } 527 529 if (outData->size != numPeaksOrig) { 528 printf("TEST ERROR (0): pmCullPe eks incorrectly removed peaks\n");529 printf("The pmCullPe eks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig);530 printf("TEST ERROR (0): pmCullPeaks incorrectly removed peaks\n"); 531 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig); 530 532 testStatus = false; 531 533 } … … 533 535 534 536 // 535 // Call pmCullPe eks() with TINY maxValue and NULL psRegion. Should537 // Call pmCullPeaks() with TINY maxValue and NULL psRegion. Should 536 538 // remove all peaks. 537 539 // 538 540 printf("----------------------------------------------------------------------------------\n"); 539 printf("Calling pmCullPe eks with tiny maxValue and NULL psRegion.\n");540 outData = pmFindImagePe eks(imgData, 0.0);541 printf("pmFindImagePe eks found %d peaks\n", outData->size);542 outData = pmCullPe eks(outData, 0.0, NULL);541 printf("Calling pmCullPeaks with tiny maxValue and NULL psRegion.\n"); 542 outData = pmFindImagePeaks(imgData, 0.0); 543 printf("pmFindImagePeaks found %d peaks\n", outData->size); 544 outData = pmCullPeaks(outData, 0.0, NULL); 543 545 544 546 if (outData == NULL) { 545 printf("TEST ERROR: pmCullPe eks() returned a non-NULL psList.\n");547 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 546 548 testStatus = false; 547 549 return(testStatus); 548 550 } 549 551 if (outData->size != 0) { 550 printf("TEST ERROR (1): pmCullPe eks incorrectly removed peaks\n");551 printf("The pmCullPe eks() output had %d peaks, should have had %d peaks.\n", outData->size, 0);552 printf("TEST ERROR (1): pmCullPeaks incorrectly removed peaks\n"); 553 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, 0); 552 554 testStatus = false; 553 555 } … … 555 557 556 558 // 557 // Call pmCullPe eks() with HUGE maxValue and disjoint psRegion. Should559 // Call pmCullPeaks() with HUGE maxValue and disjoint psRegion. Should 558 560 // not remove any peaks. 559 561 // 560 562 printf("----------------------------------------------------------------------------------\n"); 561 printf("Calling pmCullPe eks with large maxValue and disjoint psRegion.\n");562 outData = pmFindImagePe eks(imgData, 0.0);563 printf("pmFindImagePe eks found %d peaks\n", outData->size);563 printf("Calling pmCullPeaks with large maxValue and disjoint psRegion.\n"); 564 outData = pmFindImagePeaks(imgData, 0.0); 565 printf("pmFindImagePeaks found %d peaks\n", outData->size); 564 566 psRegion *tmpRegion = psRegionAlloc(10000.0, 20000.0, 10000.0, 20000.0); 565 outData = pmCullPe eks(outData, PS_MAX_F32, tmpRegion);567 outData = pmCullPeaks(outData, PS_MAX_F32, tmpRegion); 566 568 567 569 if (outData == NULL) { 568 printf("TEST ERROR: pmCullPe eks() returned a non-NULL psList.\n");570 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 569 571 testStatus = false; 570 572 return(testStatus); 571 573 } 572 574 if (outData->size != numPeaksOrig) { 573 printf("TEST ERROR (2): pmCullPe eks incorrectly removed peaks\n");574 printf("The pmCullPe eks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig);575 printf("TEST ERROR (2): pmCullPeaks incorrectly removed peaks\n"); 576 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig); 575 577 testStatus = false; 576 578 } … … 579 581 580 582 // 581 // Call pmCullPe eks() with HUGE maxValue and non-disjoint psRegion. Should583 // Call pmCullPeaks() with HUGE maxValue and non-disjoint psRegion. Should 582 584 // remove all peaks. 583 585 // 584 586 printf("----------------------------------------------------------------------------------\n"); 585 printf("Calling pmCullPe eks with large maxValue and non-disjoint psRegion.\n");586 outData = pmFindImagePe eks(imgData, 0.0);587 printf("pmFindImagePe eks found %d peaks\n", outData->size);587 printf("Calling pmCullPeaks with large maxValue and non-disjoint psRegion.\n"); 588 outData = pmFindImagePeaks(imgData, 0.0); 589 printf("pmFindImagePeaks found %d peaks\n", outData->size); 588 590 tmpRegion = psRegionAlloc(-PS_MAX_F32, PS_MAX_F32, -PS_MAX_F32, PS_MAX_F32); 589 outData = pmCullPe eks(outData, PS_MAX_F32, tmpRegion);591 outData = pmCullPeaks(outData, PS_MAX_F32, tmpRegion); 590 592 591 593 if (outData == NULL) { 592 printf("TEST ERROR: pmCullPe eks() returned a non-NULL psList.\n");594 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 593 595 testStatus = false; 594 596 return(testStatus); 595 597 } 596 598 if (outData->size != 0) { 597 printf("TEST ERROR (3): pmCullPe eks incorrectly removed peaks\n");598 printf("The pmCullPe eks() output had %d peaks, should have had %d peaks.\n", outData->size, 0);599 printf("TEST ERROR (3): pmCullPeaks incorrectly removed peaks\n"); 600 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, 0); 599 601 testStatus = false; 600 602 }
Note:
See TracChangeset
for help on using the changeset viewer.
