IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4096


Ignore:
Timestamp:
Jun 3, 2005, 10:34:47 AM (21 years ago)
Author:
gusciora
Message:

Modified to be compatible with Eugene's changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/tst_pmObjects01.c

    r3723 r4096  
    1919 * abd never deallocate, no error is generated.
    2020 *
    21  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    22  *  @date $Date: 2005-04-19 23:44:54 $
     21 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     22 *  @date $Date: 2005-06-03 20:34:47 $
    2323 *
    2424 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    126126        testStatus = false;
    127127    } 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);
    130131            testStatus = false;
    131132        } else {
    132133            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)) {
    135136                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) did not ininitialize the params/dparams array to 0.0.\n");
    136137                    testStatus = false;
     
    147148        testStatus = false;
    148149    } 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);
    151153            testStatus = false;
    152154        } else {
    153155            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)) {
    156158                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) did not ininitialize the params/dparams array to 0.0.\n");
    157159                    testStatus = false;
     
    168170        testStatus = false;
    169171    } 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);
    172175            testStatus = false;
    173176        } else {
    174177            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)) {
    177180                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) did not ininitialize the params/dparams array to 0.0.\n");
    178181                    testStatus = false;
     
    189192        testStatus = false;
    190193    } 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);
    193197            testStatus = false;
    194198        } else {
    195199            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)) {
    198202                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) did not ininitialize the params/dparams array to 0.0.\n");
    199203                    testStatus = false;
     
    210214        testStatus = false;
    211215    } 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);
    214219            testStatus = false;
    215220        } else {
    216221            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)) {
    219224                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) did not ininitialize the params/dparams array to 0.0.\n");
    220225                    testStatus = false;
     
    231236        testStatus = false;
    232237    } 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);
    235241            testStatus = false;
    236242        } else {
    237243            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)) {
    240246                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) did not ininitialize the params/dparams array to 0.0.\n");
    241247                    testStatus = false;
     
    485491    bool testStatus = true;
    486492    psImage *inData = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    487     psList *outData = NULL;
     493    psArray *outData = NULL;
    488494
    489495    //
     
    531537            expectedNumPeaks = 5;
    532538        }
    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];
    542547            if (((tmpPeak->x == 0) && (tmpPeak->y == 0)) ||
    543548                    ((tmpPeak->x == 0) && (tmpPeak->y == numRows-1)) ||
     
    558563                testStatus = false;
    559564            }
    560 
    561             tmpPeakLE = tmpPeakLE->next;
    562565        }
    563566    }
     
    571574{
    572575    bool testStatus = true;
    573     psList *tmpList = NULL;
     576    psArray *tmpArray = NULL;
    574577    psImage *tmpImageF64 = psImageAlloc(TST02_NUM_ROWS, TST02_NUM_COLS, PS_TYPE_F64);
    575578    psImage *tmpImageEmpty = psImageAlloc(0, 0, PS_TYPE_F32);
     
    579582    printf("----------------------------------------------------------------------------------\n");
    580583    printf("Calling pmFindImagePeaks with NULL psImage.  Should generate error and return NULL.\n");
    581     tmpList = pmFindImagePeaks(NULL, 0.0);
    582     if (tmpList != NULL) {
     584    tmpArray = pmFindImagePeaks(NULL, 0.0);
     585    if (tmpArray != NULL) {
    583586        printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n");
    584587        testStatus = false;
    585         psFree(tmpList);
     588        psFree(tmpArray);
    586589    }
    587590
    588591    printf("----------------------------------------------------------------------------------\n");
    589592    printf("Calling pmFindImagePeaks with empty psImage.  Should generate error and return NULL.\n");
    590     tmpList = pmFindImagePeaks(tmpImageEmpty, 0.0);
    591     if (tmpList != NULL) {
     593    tmpArray = pmFindImagePeaks(tmpImageEmpty, 0.0);
     594    if (tmpArray != NULL) {
    592595        printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n");
    593596        testStatus = false;
    594         psFree(tmpList);
     597        psFree(tmpArray);
    595598    }
    596599
    597600    printf("----------------------------------------------------------------------------------\n");
    598601    printf("Calling pmFindImagePeaks with PS_TYPE_F64 psImage.  Should generate error and return NULL.\n");
    599     tmpList = pmFindImagePeaks(tmpImageF64, 0.0);
    600     if (tmpList != NULL) {
     602    tmpArray = pmFindImagePeaks(tmpImageF64, 0.0);
     603    if (tmpArray != NULL) {
    601604        printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n");
    602605        testStatus = false;
    603         psFree(tmpList);
     606        psFree(tmpArray);
    604607    }
    605608    printf("----------------------------------------------------------------------------------\n");
     
    630633    bool testStatus = true;
    631634    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    */
    641646
    642647    //
     
    670675    printf("Calling pmCullPeaks with large maxValue and NULL psRegion.\n");
    671676    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    */
    684691    psFree(outData);
    685692
     
    691698    printf("Calling pmCullPeaks with tiny maxValue and NULL psRegion.\n");
    692699    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    */
    707716
    708717    //
     
    713722    printf("Calling pmCullPeaks with large maxValue and disjoint psRegion.\n");
    714723    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    */
    729741    psFree(outData);
    730     psFree(tmpRegion);
    731742
    732743    //
     
    737748    printf("Calling pmCullPeaks with large maxValue and non-disjoint psRegion.\n");
    738749    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    */
    753766    psFree(outData);
    754     psFree(tmpRegion);
    755767
    756768    printf("----------------------------------------------------------------------------------\n");
     
    16371649    printf("Calling pmSourceContour with acceptable data.\n");
    16381650    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;
    16461658    rc = pmSourceContour(mySrc, imgData, LEVEL, PS_CONTOUR_CRUDE);
    16471659    if (rc != NULL) {
     
    17001712
    17011713    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;
    17091721
    17101722    printf("----------------------------------------------------------------------------------\n");
     
    17801792
    17811793    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;
    17891801
    17901802    printf("----------------------------------------------------------------------------------\n");
     
    18621874
    18631875
    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;
    18711883
    18721884    printf("----------------------------------------------------------------------------------\n");
Note: See TracChangeset for help on using the changeset viewer.