Changeset 15161 for trunk/psModules/test/objects/tap_pmPeaks.c
- Timestamp:
- Oct 2, 2007, 9:37:23 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/objects/tap_pmPeaks.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/objects/tap_pmPeaks.c
r13879 r15161 5 5 #include "tap.h" 6 6 #include "pstap.h" 7 /* The following are tested: 8 pmPeakAlloc() 9 pmPeaksInVector() 10 pmPeaksInImage() 11 pmPeaksSubset() 12 pmPeaksCompareAscend() 13 pmPeaksCompareDescend() 14 Must test 15 pmCullPeaks() 16 */ 7 17 8 18 #define TST01_VECTOR_LENGTH 10 … … 13 23 14 24 /****************************************************************************** 15 test01(): we first test pm FindVectorPeaks() with a variety of bad input25 test01(): we first test pmPeaksInVector() with a variety of bad input 16 26 parameters. Then we test it with a simple vector both 1- and multi-elements. 17 27 *****************************************************************************/ 18 bool test_pm FindVectorPeaks(int n)28 bool test_pmPeaksInVector(int n) 19 29 { 20 30 psMemId id = psMemGetId(); … … 29 39 } 30 40 inData->data.F32[0] = (float) n; 31 outData= pm FindVectorPeaks(inData, 0.0);41 outData= pmPeaksInVector(inData, 0.0); 32 42 if (outData == NULL) { 33 diag("TEST ERROR: pm FindVectorPeaksreturned a NULL psVector.\n");43 diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n"); 34 44 testStatus = false; 35 45 } else { … … 53 63 } 54 64 inData->data.F32[0] = (float) n; 55 outData= pm FindVectorPeaks(inData, (float) (n*n));65 outData= pmPeaksInVector(inData, (float) (n*n)); 56 66 if (outData == NULL) { 57 diag("TEST ERROR: pm FindVectorPeaksreturned a NULL psVector.\n");67 diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n"); 58 68 testStatus = false; 59 69 } else { … … 78 88 inData->data.F32[n-1] = (float) n; 79 89 80 outData= pm FindVectorPeaks(inData, 0.0);90 outData= pmPeaksInVector(inData, 0.0); 81 91 if (outData == NULL) { 82 diag("TEST ERROR: pm FindVectorPeaksreturned a NULL psVector.\n");92 diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n"); 83 93 testStatus = false; 84 94 } else { … … 100 110 } 101 111 inData->data.F32[n-1] = (float) n; 102 outData= pm FindVectorPeaks(inData, (float) (n*n));112 outData= pmPeaksInVector(inData, (float) (n*n)); 103 113 if (outData == NULL) { 104 diag("TEST ERROR: pm FindVectorPeaksreturned a NULL psVector.\n");114 diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n"); 105 115 testStatus = false; 106 116 } else { … … 125 135 126 136 127 outData= pm FindVectorPeaks(inData, 0.0);137 outData= pmPeaksInVector(inData, 0.0); 128 138 if (outData == NULL) { 129 diag("TEST ERROR: pm FindVectorPeaksreturned a NULL psVector.\n");139 diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n"); 130 140 testStatus = false; 131 141 } else { … … 146 156 // Test interior peaks, with threshold = n*n. 147 157 // Should generate an empty output psVector. 148 outData= pm FindVectorPeaks(inData, (float) (n*n));158 outData= pmPeaksInVector(inData, (float) (n*n)); 149 159 if (outData == NULL) { 150 diag("TEST ERROR: pm FindVectorPeaksreturned a NULL psVector.\n");160 diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n"); 151 161 testStatus = false; 152 162 } else { … … 163 173 164 174 165 bool test_pm FindImagePeaks(int numRows, int numCols)175 bool test_pmPeaksInImage(int numRows, int numCols) 166 176 { 167 177 psMemId id = psMemGetId(); … … 183 193 inData->data.F32[numRows/2][numCols/2] = PS_SQR(numRows) + PS_SQR(numCols); 184 194 185 // Call pm FindImagePeaks() with a threshold of 0.0.186 outData = pm FindImagePeaks(inData, 0.0);195 // Call pmPeaksInImage() with a threshold of 0.0. 196 outData = pmPeaksInImage(inData, 0.0); 187 197 188 198 if (outData == NULL) { 189 diag("TEST ERROR: pm FindImagePeaksreturned a NULL psList.\n");199 diag("TEST ERROR: pmPeaksInImage returned a NULL psList.\n"); 190 200 testStatus = false; 191 201 } else { … … 199 209 } 200 210 if (outData->n != expectedNumPeaks) { 201 diag("TEST ERROR: pm FindImagePeaksfound %ld peaks (should be %d)\n", outData->n, expectedNumPeaks);211 diag("TEST ERROR: pmPeaksInImage found %ld peaks (should be %d)\n", outData->n, expectedNumPeaks); 202 212 testStatus = false; 203 213 } … … 279 289 280 290 // ---------------------------------------- 281 // pm FindVectorPeaks() tests282 // Test pm FindVectorPeaks() with bad input parameters.283 // Calling pm FindVectorPeakswith NULL psVector. Should generate error.284 { 285 psMemId id = psMemGetId(); 286 psVector *tmpVec = pm FindVectorPeaks(NULL, 0.0);287 ok(tmpVec == NULL, "pm FindVectorPeaks() returned a NULL with NULL psVector input");291 // pmPeaksInVector() tests 292 // Test pmPeaksInVector() with bad input parameters. 293 // Calling pmPeaksInVector with NULL psVector. Should generate error. 294 { 295 psMemId id = psMemGetId(); 296 psVector *tmpVec = pmPeaksInVector(NULL, 0.0); 297 ok(tmpVec == NULL, "pmPeaksInVector() returned a NULL with NULL psVector input"); 288 298 psFree(tmpVec); 289 299 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 291 301 292 302 293 // Calling pm FindVectorPeakswith empty psVector. Should generate error.303 // Calling pmPeaksInVector with empty psVector. Should generate error. 294 304 { 295 305 psMemId id = psMemGetId(); 296 306 psVector *tmpVecEmpty = psVectorAlloc(0, PS_TYPE_F32); 297 psVector *tmpVec = pm FindVectorPeaks(tmpVecEmpty, 0.0);298 ok(tmpVec == NULL, "pm FindVectorPeaks() returned a NULL with NULL psVector input");307 psVector *tmpVec = pmPeaksInVector(tmpVecEmpty, 0.0); 308 ok(tmpVec == NULL, "pmPeaksInVector() returned a NULL with NULL psVector input"); 299 309 psFree(tmpVec); 300 310 psFree(tmpVecEmpty); … … 303 313 304 314 305 // Calling pm FindVectorPeakswith PS_TYPE_F64 psVector. Should generate error.315 // Calling pmPeaksInVector with PS_TYPE_F64 psVector. Should generate error. 306 316 { 307 317 psMemId id = psMemGetId(); 308 318 psVector *tmpVecF64 = psVectorAlloc(TST01_VECTOR_LENGTH, PS_TYPE_F64); 309 psVector *tmpVec = pm FindVectorPeaks(tmpVecF64, 0.0);310 ok(tmpVec == NULL, "pm FindVectorPeaks() returned a NULL with F64 psVector input");319 psVector *tmpVec = pmPeaksInVector(tmpVecF64, 0.0); 320 ok(tmpVec == NULL, "pmPeaksInVector() returned a NULL with F64 psVector input"); 311 321 psFree(tmpVecF64); 312 322 psFree(tmpVec); 313 323 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 314 324 } 315 ok(test_pm FindVectorPeaks(1), "Tested pmFindVectorPeaks() on length 1 input vector");316 ok(test_pm FindVectorPeaks(10), "Tested pmFindVectorPeaks() on length 10 input vector");325 ok(test_pmPeaksInVector(1), "Tested pmPeaksInVector() on length 1 input vector"); 326 ok(test_pmPeaksInVector(10), "Tested pmPeaksInVector() on length 10 input vector"); 317 327 318 328 319 329 320 330 // ---------------------------------------- 321 // pm FindImagePeaks() tests322 // Calling pm FindImagePeakswith NULL psImage. Should generate error.323 { 324 psMemId id = psMemGetId(); 325 psArray *tmpArray = pm FindImagePeaks(NULL, 0.0);326 ok(tmpArray == NULL, "pm FindImagePeaks() returned NULL with NULL input image");331 // pmPeaksInImage() tests 332 // Calling pmPeaksInImage with NULL psImage. Should generate error. 333 { 334 psMemId id = psMemGetId(); 335 psArray *tmpArray = pmPeaksInImage(NULL, 0.0); 336 ok(tmpArray == NULL, "pmPeaksInImage() returned NULL with NULL input image"); 327 337 psFree(tmpArray); 328 338 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 330 340 331 341 332 // Calling pm FindImagePeakswith empty psImage. Should generate error.342 // Calling pmPeaksInImage with empty psImage. Should generate error. 333 343 { 334 344 psMemId id = psMemGetId(); 335 345 psImage *tmpImageEmpty = psImageAlloc(0, 0, PS_TYPE_F32); 336 psArray *tmpArray = pm FindImagePeaks(tmpImageEmpty, 0.0);337 ok(tmpArray == NULL, "pm FindImagePeaks() returned NULL with empty input image");346 psArray *tmpArray = pmPeaksInImage(tmpImageEmpty, 0.0); 347 ok(tmpArray == NULL, "pmPeaksInImage() returned NULL with empty input image"); 338 348 psFree(tmpArray); 339 349 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 341 351 342 352 343 // Calling pm FindImagePeakswith PS_TYPE_F64 psImage. Should generate error353 // Calling pmPeaksInImage with PS_TYPE_F64 psImage. Should generate error 344 354 { 345 355 psMemId id = psMemGetId(); 346 356 psImage *tmpImageF64 = psImageAlloc(TST02_NUM_ROWS, TST02_NUM_COLS, PS_TYPE_F64); 347 psArray *tmpArray = pm FindImagePeaks(tmpImageF64, 0.0);348 ok(tmpArray == NULL, "pm FindImagePeaks() returned NULL with F64 input image");357 psArray *tmpArray = pmPeaksInImage(tmpImageF64, 0.0); 358 ok(tmpArray == NULL, "pmPeaksInImage() returned NULL with F64 input image"); 349 359 psFree(tmpImageF64); 350 360 psFree(tmpArray); … … 353 363 354 364 355 // testStatus&= test_pmFindImagePeaks(1, 1); 356 // testStatus&= test_pmFindImagePeaks(2, 5); 357 // testStatus&= test_pmFindImagePeaks(5, 2); 365 // XXX: Uncomment these and debug 366 // testStatus&= test_pmPeaksInImage(1, 1); 367 // testStatus&= test_pmPeaksInImage(2, 5); 368 // testStatus&= test_pmPeaksInImage(5, 2); 358 369 // HEY: add code for small images 359 // testStatus&= test_pm FindImagePeaks(1, 1);360 // testStatus&= test_pm FindImagePeaks(1, 8);361 // testStatus&= test_pm FindImagePeaks(8, 1);362 ok(test_pm FindImagePeaks(TST02_NUM_ROWS, TST02_NUM_COLS),363 "Tested pm FindImagePeaks() on (%d, %d) image", TST02_NUM_ROWS, TST02_NUM_COLS);364 ok(test_pm FindImagePeaks(2*TST02_NUM_ROWS, TST02_NUM_COLS),365 "Tested pm FindImagePeaks() on (%d, %d) image", 2*TST02_NUM_ROWS, TST02_NUM_COLS);366 ok(test_pm FindImagePeaks(TST02_NUM_ROWS, 2*TST02_NUM_COLS),367 "Tested pm FindImagePeaks() on (%d, %d) image", TST02_NUM_ROWS, 2*TST02_NUM_COLS);370 // testStatus&= test_pmPeaksInImage(1, 1); 371 // testStatus&= test_pmPeaksInImage(1, 8); 372 // testStatus&= test_pmPeaksInImage(8, 1); 373 ok(test_pmPeaksInImage(TST02_NUM_ROWS, TST02_NUM_COLS), 374 "Tested pmPeaksInImage() on (%d, %d) image", TST02_NUM_ROWS, TST02_NUM_COLS); 375 ok(test_pmPeaksInImage(2*TST02_NUM_ROWS, TST02_NUM_COLS), 376 "Tested pmPeaksInImage() on (%d, %d) image", 2*TST02_NUM_ROWS, TST02_NUM_COLS); 377 ok(test_pmPeaksInImage(TST02_NUM_ROWS, 2*TST02_NUM_COLS), 378 "Tested pmPeaksInImage() on (%d, %d) image", TST02_NUM_ROWS, 2*TST02_NUM_COLS); 368 379 369 380 … … 399 410 { 400 411 psMemId id = psMemGetId(); 401 psArray *outData = pm FindImagePeaks(imgData, 0.0);412 psArray *outData = pmPeaksInImage(imgData, 0.0); 402 413 psArray *outData2 = pmPeaksSubset(outData, PS_MAX_F32, psRegionSet(20, 20, 20, 20)); 403 414 ok(outData2 != NULL && psMemCheckArray(outData), … … 415 426 { 416 427 psMemId id = psMemGetId(); 417 psArray *outData = pm FindImagePeaks(imgData, 0.0);428 psArray *outData = pmPeaksInImage(imgData, 0.0); 418 429 psArray *outData2 = pmPeaksSubset(outData, 0.0, psRegionSet(20, 20, 20, 20)); 419 430 ok(outData2 != NULL && psMemCheckArray(outData), … … 431 442 { 432 443 psMemId id = psMemGetId(); 433 psArray *outData = pm FindImagePeaks(imgData, 0.0);444 psArray *outData = pmPeaksInImage(imgData, 0.0); 434 445 psRegion tmpRegion = psRegionSet(-PS_MAX_F32, PS_MAX_F32, -PS_MAX_F32, PS_MAX_F32); 435 446 psArray *outData2 = pmPeaksSubset(outData, PS_MAX_F32, tmpRegion); … … 448 459 { 449 460 psMemId id = psMemGetId(); 450 psArray *outData = pm FindImagePeaks(imgData, 0.0);461 psArray *outData = pmPeaksInImage(imgData, 0.0); 451 462 psRegion tmpRegion = psRegionSet(-PS_MAX_F32, PS_MAX_F32, -PS_MAX_F32, PS_MAX_F32); 452 463 psArray *outData2 = pmPeaksSubset(outData, 0.0, tmpRegion);
Note:
See TracChangeset
for help on using the changeset viewer.
