Changeset 4096
- Timestamp:
- Jun 3, 2005, 10:34:47 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/tst_pmObjects01.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/tst_pmObjects01.c
r3723 r4096 19 19 * abd never deallocate, no error is generated. 20 20 * 21 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $22 * @date $Date: 2005-0 4-19 23:44:54$21 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2005-06-03 20:34:47 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 126 126 testStatus = false; 127 127 } else { 128 if (tmpModel->Nparams != 7) { 129 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 128 if ((tmpModel->params->n != 7) || (tmpModel->dparams->n != 7)) { 129 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) allocated an incorrect number of params (%d, %d)\n", 130 tmpModel->params->n, tmpModel->dparams->n); 130 131 testStatus = false; 131 132 } else { 132 133 for (psS32 i = 0 ; i < 7 ; i++) { 133 if ((tmpModel->params [i] != 0.0) ||134 (tmpModel->dparams [i] != 0.0)) {134 if ((tmpModel->params->data.F32[i] != 0.0) || 135 (tmpModel->dparams->data.F32[i] != 0.0)) { 135 136 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 136 137 testStatus = false; … … 147 148 testStatus = false; 148 149 } else { 149 if (tmpModel->Nparams != 7) { 150 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 150 if ((tmpModel->params->n != 7) || (tmpModel->dparams->n != 7)) { 151 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) allocated an incorrect number of params (%d, %d)\n", 152 tmpModel->params->n, tmpModel->dparams->n); 151 153 testStatus = false; 152 154 } else { 153 155 for (psS32 i = 0 ; i < 7 ; i++) { 154 if ((tmpModel->params [i] != 0.0) ||155 (tmpModel->dparams [i] != 0.0)) {156 if ((tmpModel->params->data.F32[i] != 0.0) || 157 (tmpModel->dparams->data.F32[i] != 0.0)) { 156 158 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 157 159 testStatus = false; … … 168 170 testStatus = false; 169 171 } else { 170 if (tmpModel->Nparams != 11) { 171 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 172 if ((tmpModel->params->n != 11) || (tmpModel->dparams->n != 11)) { 173 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) allocated an incorrect number of params (%d, %d)\n", 174 tmpModel->params->n, tmpModel->dparams->n); 172 175 testStatus = false; 173 176 } else { 174 177 for (psS32 i = 0 ; i < 11 ; i++) { 175 if ((tmpModel->params [i] != 0.0) ||176 (tmpModel->dparams [i] != 0.0)) {178 if ((tmpModel->params->data.F32[i] != 0.0) || 179 (tmpModel->dparams->data.F32[i] != 0.0)) { 177 180 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 178 181 testStatus = false; … … 189 192 testStatus = false; 190 193 } else { 191 if (tmpModel->Nparams != 9) { 192 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 194 if ((tmpModel->params->n != 9) || (tmpModel->dparams->n != 9)) { 195 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) allocated an incorrect number of params (%d, %d)\n", 196 tmpModel->params->n, tmpModel->dparams->n); 193 197 testStatus = false; 194 198 } else { 195 199 for (psS32 i = 0 ; i < 9 ; i++) { 196 if ((tmpModel->params [i] != 0.0) ||197 (tmpModel->dparams [i] != 0.0)) {200 if ((tmpModel->params->data.F32[i] != 0.0) || 201 (tmpModel->dparams->data.F32[i] != 0.0)) { 198 202 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 199 203 testStatus = false; … … 210 214 testStatus = false; 211 215 } else { 212 if (tmpModel->Nparams != 8) { 213 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 216 if ((tmpModel->params->n != 8) || (tmpModel->dparams->n != 8)) { 217 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) allocated an incorrect number of params (%d, %d)\n", 218 tmpModel->params->n, tmpModel->dparams->n); 214 219 testStatus = false; 215 220 } else { 216 221 for (psS32 i = 0 ; i < 8 ; i++) { 217 if ((tmpModel->params [i] != 0.0) ||218 (tmpModel->dparams [i] != 0.0)) {222 if ((tmpModel->params->data.F32[i] != 0.0) || 223 (tmpModel->dparams->data.F32[i] != 0.0)) { 219 224 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) did not ininitialize the params/dparams array to 0.0.\n"); 220 225 testStatus = false; … … 231 236 testStatus = false; 232 237 } else { 233 if (tmpModel->Nparams != 12) { 234 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) allocated an incorrect number of params (%d)\n", tmpModel->Nparams); 238 if ((tmpModel->params->n != 12) || (tmpModel->dparams->n != 12)) { 239 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) allocated an incorrect number of params (%d, %d)\n", 240 tmpModel->params->n, tmpModel->dparams->n); 235 241 testStatus = false; 236 242 } else { 237 243 for (psS32 i = 0 ; i < 12 ; i++) { 238 if ((tmpModel->params [i] != 0.0) ||239 (tmpModel->dparams [i] != 0.0)) {244 if ((tmpModel->params->data.F32[i] != 0.0) || 245 (tmpModel->dparams->data.F32[i] != 0.0)) { 240 246 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) did not ininitialize the params/dparams array to 0.0.\n"); 241 247 testStatus = false; … … 485 491 bool testStatus = true; 486 492 psImage *inData = psImageAlloc(numCols, numRows, PS_TYPE_F32); 487 ps List*outData = NULL;493 psArray *outData = NULL; 488 494 489 495 // … … 531 537 expectedNumPeaks = 5; 532 538 } 533 if (outData->size != expectedNumPeaks) { 534 printf("TEST ERROR: pmFindImagePeaks found %d peaks (should be %d)\n", outData->size, expectedNumPeaks); 535 testStatus = false; 536 } 537 538 // HEY 539 psListElem *tmpPeakLE = (psListElem *) outData->head; 540 while (tmpPeakLE != NULL) { 541 psPeak *tmpPeak = (psPeak *) tmpPeakLE->data; 539 if (outData->n != expectedNumPeaks) { 540 printf("TEST ERROR: pmFindImagePeaks found %d peaks (should be %d)\n", outData->n, expectedNumPeaks); 541 testStatus = false; 542 } 543 544 // HEY: verify 545 for (psS32 i = 0 ; i < outData->n ; i++) { 546 psPeak *tmpPeak = (psPeak *) outData->data[i]; 542 547 if (((tmpPeak->x == 0) && (tmpPeak->y == 0)) || 543 548 ((tmpPeak->x == 0) && (tmpPeak->y == numRows-1)) || … … 558 563 testStatus = false; 559 564 } 560 561 tmpPeakLE = tmpPeakLE->next;562 565 } 563 566 } … … 571 574 { 572 575 bool testStatus = true; 573 ps List *tmpList= NULL;576 psArray *tmpArray = NULL; 574 577 psImage *tmpImageF64 = psImageAlloc(TST02_NUM_ROWS, TST02_NUM_COLS, PS_TYPE_F64); 575 578 psImage *tmpImageEmpty = psImageAlloc(0, 0, PS_TYPE_F32); … … 579 582 printf("----------------------------------------------------------------------------------\n"); 580 583 printf("Calling pmFindImagePeaks with NULL psImage. Should generate error and return NULL.\n"); 581 tmp List= pmFindImagePeaks(NULL, 0.0);582 if (tmp List!= NULL) {584 tmpArray = pmFindImagePeaks(NULL, 0.0); 585 if (tmpArray != NULL) { 583 586 printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n"); 584 587 testStatus = false; 585 psFree(tmp List);588 psFree(tmpArray); 586 589 } 587 590 588 591 printf("----------------------------------------------------------------------------------\n"); 589 592 printf("Calling pmFindImagePeaks with empty psImage. Should generate error and return NULL.\n"); 590 tmp List= pmFindImagePeaks(tmpImageEmpty, 0.0);591 if (tmp List!= NULL) {593 tmpArray = pmFindImagePeaks(tmpImageEmpty, 0.0); 594 if (tmpArray != NULL) { 592 595 printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n"); 593 596 testStatus = false; 594 psFree(tmp List);597 psFree(tmpArray); 595 598 } 596 599 597 600 printf("----------------------------------------------------------------------------------\n"); 598 601 printf("Calling pmFindImagePeaks with PS_TYPE_F64 psImage. Should generate error and return NULL.\n"); 599 tmp List= pmFindImagePeaks(tmpImageF64, 0.0);600 if (tmp List!= NULL) {602 tmpArray = pmFindImagePeaks(tmpImageF64, 0.0); 603 if (tmpArray != NULL) { 601 604 printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n"); 602 605 testStatus = false; 603 psFree(tmp List);606 psFree(tmpArray); 604 607 } 605 608 printf("----------------------------------------------------------------------------------\n"); … … 630 633 bool testStatus = true; 631 634 psImage *imgData = psImageAlloc(NUM_COLS, NUM_ROWS, PS_TYPE_F32); 632 psList *outData = NULL; 633 634 printf("----------------------------------------------------------------------------------\n"); 635 printf("Calling pmCullPeaks with NULL psList. Should generate error and return NULL.\n"); 636 outData = pmCullPeaks(NULL, 0.0, NULL); 637 if (outData != NULL) { 638 printf("TEST ERROR: pmCulPeaks() returned a non-NULL psList.\n"); 639 testStatus = false; 640 } 635 psArray *outData = NULL; 636 637 /* XXX: Modify for new pmCullPeaks() 638 printf("----------------------------------------------------------------------------------\n"); 639 printf("Calling pmCullPeaks with NULL psList. Should generate error and return NULL.\n"); 640 outData = pmCullPeaks(NULL, 0.0, NULL); 641 if (outData != NULL) { 642 printf("TEST ERROR: pmCulPeaks() returned a non-NULL psList.\n"); 643 testStatus = false; 644 } 645 */ 641 646 642 647 // … … 670 675 printf("Calling pmCullPeaks with large maxValue and NULL psRegion.\n"); 671 676 outData = pmFindImagePeaks(imgData, 0.0); 672 outData = pmCullPeaks(outData, PS_MAX_F32, NULL); 673 674 if (outData == NULL) { 675 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 676 testStatus = false; 677 return(testStatus); 678 } 679 if (outData->size != numPeaksOrig) { 680 printf("TEST ERROR (0): pmCullPeaks incorrectly removed peaks\n"); 681 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig); 682 testStatus = false; 683 } 677 /* XXX: Modify for new pmCullPeaks 678 outData = pmCullPeaks(outData, PS_MAX_F32, NULL); 679 680 if (outData == NULL) { 681 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 682 testStatus = false; 683 return(testStatus); 684 } 685 if (outData->n != numPeaksOrig) { 686 printf("TEST ERROR (0): pmCullPeaks incorrectly removed peaks\n"); 687 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->n, numPeaksOrig); 688 testStatus = false; 689 } 690 */ 684 691 psFree(outData); 685 692 … … 691 698 printf("Calling pmCullPeaks with tiny maxValue and NULL psRegion.\n"); 692 699 outData = pmFindImagePeaks(imgData, 0.0); 693 printf("pmFindImagePeaks found %d peaks\n", outData->size); 694 outData = pmCullPeaks(outData, 0.0, NULL); 695 696 if (outData == NULL) { 697 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 698 testStatus = false; 699 return(testStatus); 700 } 701 if (outData->size != 0) { 702 printf("TEST ERROR (1): pmCullPeaks incorrectly removed peaks\n"); 703 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, 0); 704 testStatus = false; 705 } 706 psFree(outData); 700 printf("pmFindImagePeaks found %d peaks\n", outData->n); 701 /* XXX: Modify for new pmCullPeaks 702 outData = pmCullPeaks(outData, 0.0, NULL); 703 704 if (outData == NULL) { 705 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 706 testStatus = false; 707 return(testStatus); 708 } 709 if (outData->n != 0) { 710 printf("TEST ERROR (1): pmCullPeaks incorrectly removed peaks\n"); 711 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->n, 0); 712 testStatus = false; 713 } 714 psFree(outData); 715 */ 707 716 708 717 // … … 713 722 printf("Calling pmCullPeaks with large maxValue and disjoint psRegion.\n"); 714 723 outData = pmFindImagePeaks(imgData, 0.0); 715 printf("pmFindImagePeaks found %d peaks\n", outData->size); 716 psRegion *tmpRegion = psRegionAlloc(10000.0, 20000.0, 10000.0, 20000.0); 717 outData = pmCullPeaks(outData, PS_MAX_F32, tmpRegion); 718 719 if (outData == NULL) { 720 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 721 testStatus = false; 722 return(testStatus); 723 } 724 if (outData->size != numPeaksOrig) { 725 printf("TEST ERROR (2): pmCullPeaks incorrectly removed peaks\n"); 726 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig); 727 testStatus = false; 728 } 724 printf("pmFindImagePeaks found %d peaks\n", outData->n); 725 psRegion tmpRegion = psRegionSet(10000.0, 20000.0, 10000.0, 20000.0); 726 727 /* XXX: Modify for new pmCullPeaks 728 outData = pmCullPeaks(outData, PS_MAX_F32, tmpRegion); 729 730 if (outData == NULL) { 731 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 732 testStatus = false; 733 return(testStatus); 734 } 735 if (outData->n != numPeaksOrig) { 736 printf("TEST ERROR (2): pmCullPeaks incorrectly removed peaks\n"); 737 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->n, numPeaksOrig); 738 testStatus = false; 739 } 740 */ 729 741 psFree(outData); 730 psFree(tmpRegion);731 742 732 743 // … … 737 748 printf("Calling pmCullPeaks with large maxValue and non-disjoint psRegion.\n"); 738 749 outData = pmFindImagePeaks(imgData, 0.0); 739 printf("pmFindImagePeaks found %d peaks\n", outData->size); 740 tmpRegion = psRegionAlloc(-PS_MAX_F32, PS_MAX_F32, -PS_MAX_F32, PS_MAX_F32); 741 outData = pmCullPeaks(outData, PS_MAX_F32, tmpRegion); 742 743 if (outData == NULL) { 744 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 745 testStatus = false; 746 return(testStatus); 747 } 748 if (outData->size != 0) { 749 printf("TEST ERROR (3): pmCullPeaks incorrectly removed peaks\n"); 750 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, 0); 751 testStatus = false; 752 } 750 printf("pmFindImagePeaks found %d peaks\n", outData->n); 751 tmpRegion = psRegionSet(-PS_MAX_F32, PS_MAX_F32, -PS_MAX_F32, PS_MAX_F32); 752 /* XXX: Modify for new pmCullPeaks 753 outData = pmCullPeaks(outData, PS_MAX_F32, tmpRegion); 754 755 if (outData == NULL) { 756 printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n"); 757 testStatus = false; 758 return(testStatus); 759 } 760 if (outData->n != 0) { 761 printf("TEST ERROR (3): pmCullPeaks incorrectly removed peaks\n"); 762 printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->n, 0); 763 testStatus = false; 764 } 765 */ 753 766 psFree(outData); 754 psFree(tmpRegion);755 767 756 768 printf("----------------------------------------------------------------------------------\n"); … … 1637 1649 printf("Calling pmSourceContour with acceptable data.\n"); 1638 1650 printf("NOTE: must figure out the parameters for this test to be meaningful.\n"); 1639 mySrc->models->params [0] = TST09_SKY;1640 mySrc->models->params [1] = 15.0;1641 mySrc->models->params [2] = (psF32) (TST09_NUM_ROWS / 2);1642 mySrc->models->params [3] = (psF32) (TST09_NUM_COLS / 2);1643 mySrc->models->params [4] = 2.0;1644 mySrc->models->params [5] = 2.0;1645 mySrc->models->params [6] = 2.0;1651 mySrc->models->params->data.F32[0] = TST09_SKY; 1652 mySrc->models->params->data.F32[1] = 15.0; 1653 mySrc->models->params->data.F32[2] = (psF32) (TST09_NUM_ROWS / 2); 1654 mySrc->models->params->data.F32[3] = (psF32) (TST09_NUM_COLS / 2); 1655 mySrc->models->params->data.F32[4] = 2.0; 1656 mySrc->models->params->data.F32[5] = 2.0; 1657 mySrc->models->params->data.F32[6] = 2.0; 1646 1658 rc = pmSourceContour(mySrc, imgData, LEVEL, PS_CONTOUR_CRUDE); 1647 1659 if (rc != NULL) { … … 1700 1712 1701 1713 mySrc->models = pmModelAlloc(PS_MODEL_GAUSS); 1702 mySrc->models->params [0] = 5.0;1703 mySrc->models->params [1] = 70.0;1704 mySrc->models->params [2] = (psF32) (TST15_NUM_ROWS / 2);1705 mySrc->models->params [3] = (psF32) (TST15_NUM_COLS / 2);1706 mySrc->models->params [4] = 1.0;1707 mySrc->models->params [5] = 1.0;1708 mySrc->models->params [6] = 2.0;1714 mySrc->models->params->data.F32[0] = 5.0; 1715 mySrc->models->params->data.F32[1] = 70.0; 1716 mySrc->models->params->data.F32[2] = (psF32) (TST15_NUM_ROWS / 2); 1717 mySrc->models->params->data.F32[3] = (psF32) (TST15_NUM_COLS / 2); 1718 mySrc->models->params->data.F32[4] = 1.0; 1719 mySrc->models->params->data.F32[5] = 1.0; 1720 mySrc->models->params->data.F32[6] = 2.0; 1709 1721 1710 1722 printf("----------------------------------------------------------------------------------\n"); … … 1780 1792 1781 1793 mySrc->models = pmModelAlloc(PS_MODEL_GAUSS); 1782 mySrc->models->params [0] = 5.0;1783 mySrc->models->params [1] = 70.0;1784 mySrc->models->params [2] = (psF32) (TST16_NUM_ROWS / 2);1785 mySrc->models->params [3] = (psF32) (TST16_NUM_COLS / 2);1786 mySrc->models->params [4] = 1.0;1787 mySrc->models->params [5] = 1.0;1788 mySrc->models->params [6] = 2.0;1794 mySrc->models->params->data.F32[0] = 5.0; 1795 mySrc->models->params->data.F32[1] = 70.0; 1796 mySrc->models->params->data.F32[2] = (psF32) (TST16_NUM_ROWS / 2); 1797 mySrc->models->params->data.F32[3] = (psF32) (TST16_NUM_COLS / 2); 1798 mySrc->models->params->data.F32[4] = 1.0; 1799 mySrc->models->params->data.F32[5] = 1.0; 1800 mySrc->models->params->data.F32[6] = 2.0; 1789 1801 1790 1802 printf("----------------------------------------------------------------------------------\n"); … … 1862 1874 1863 1875 1864 mySrc->models->params [0] = 5.0;1865 mySrc->models->params [1] = 70.0;1866 mySrc->models->params [2] = (psF32) (TST20_NUM_ROWS / 2);1867 mySrc->models->params [3] = (psF32) (TST20_NUM_COLS / 2);1868 mySrc->models->params [4] = 1.0;1869 mySrc->models->params [5] = 1.0;1870 mySrc->models->params [6] = 2.0;1876 mySrc->models->params->data.F32[0] = 5.0; 1877 mySrc->models->params->data.F32[1] = 70.0; 1878 mySrc->models->params->data.F32[2] = (psF32) (TST20_NUM_ROWS / 2); 1879 mySrc->models->params->data.F32[3] = (psF32) (TST20_NUM_COLS / 2); 1880 mySrc->models->params->data.F32[4] = 1.0; 1881 mySrc->models->params->data.F32[5] = 1.0; 1882 mySrc->models->params->data.F32[6] = 2.0; 1871 1883 1872 1884 printf("----------------------------------------------------------------------------------\n");
Note:
See TracChangeset
for help on using the changeset viewer.
