IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 2, 2008, 10:45:23 AM (18 years ago)
Author:
gusciora
Message:

Significant changes and additions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/objects/tap_pmPeaks.c

    r15726 r15985  
    55#include "tap.h"
    66#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         Doesn't exist
    17     pmPeakTest()
    18         Get rid of this
    19     pmPeakSortBySN()
    20         Easy
    21     pmPeakSortByY()
    22         Easy
     7/* STATUS:
     8    All functions are tested.
     9        pmPeaksInImage(): Must debug tests for small images (1-by-1, N-by-1, 1-by-N)
    2310*/
    2411
     
    2815#define TST02_NUM_ROWS 5
    2916#define TST02_NUM_COLS 5
     17#define VERBOSE                 0
     18#define ERR_TRACE_LEVEL         0
    3019
    3120/******************************************************************************
     
    253242
    254243
    255 
    256 
    257244int main(int argc, char* argv[])
    258245{
    259246    psLogSetFormat("HLNM");
    260247    psLogSetLevel(PS_LOG_INFO);
    261     plan_tests(35);
    262 
    263 
     248    psTraceSetLevel("err", ERR_TRACE_LEVEL);
     249    plan_tests(69);
     250
     251
     252    // ------------------------------------------------------------------------
    264253    // Test pmPeakAlloc()
    265254    {
     
    295284
    296285
    297     // ----------------------------------------
     286    // ------------------------------------------------------------------------
     287    // Calling pmPeaksCompareAscend with NULL peak1
     288    // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareAscend()
     289    if (0) {
     290        psMemId id = psMemGetId();
     291        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     292        *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     293        int rc = pmPeaksCompareAscend(NULL, (const void **) peak2);
     294        ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
     295        psFree(*peak2);
     296        psFree(peak2);
     297        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     298    }
     299
     300
     301    // Calling pmPeaksCompareAscend with NULL peak2
     302    // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareAscend()
     303    if (0) {
     304        psMemId id = psMemGetId();
     305        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     306        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     307        int rc = pmPeaksCompareAscend((const void **)peak1, NULL);
     308        ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
     309        psFree(*peak1);
     310        psFree(peak1);
     311        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     312    }
     313
     314
     315    // Calling pmPeaksCompareAscend with NULL *peak1
     316    // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareAscend()
     317    if (0) {
     318        psMemId id = psMemGetId();
     319        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     320        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     321        *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     322        int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
     323        ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
     324        psFree(peak1);
     325        psFree(*peak2);
     326        psFree(peak2);
     327        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     328    }
     329
     330
     331    // Calling pmPeaksCompareAscend with NULL *peak2
     332    // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareAscend()
     333    if (0) {
     334        psMemId id = psMemGetId();
     335        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     336        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     337        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     338        int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
     339        ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
     340        psFree(*peak1);
     341        psFree(peak1);
     342        psFree(peak2);
     343        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     344    }
     345
     346    // Calling pmPeaksCompareAscend with peak1 < peak2
     347    {
     348        psMemId id = psMemGetId();
     349        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     350        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     351        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     352        *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     353        int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
     354        ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
     355        psFree(*peak1);
     356        psFree(peak1);
     357        psFree(*peak2);
     358        psFree(peak2);
     359        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     360    }
     361
     362
     363    // Calling pmPeaksCompareAscend with peak1 > peak2
     364    {
     365        psMemId id = psMemGetId();
     366        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     367        *peak1 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     368        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     369        *peak2 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     370        int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
     371        ok(rc == 1, "pmPeaksCompareAscend() returned correct result (peak1 > peak2)");
     372        psFree(*peak1);
     373        psFree(peak1);
     374        psFree(*peak2);
     375        psFree(peak2);
     376        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     377    }
     378
     379
     380    // Calling pmPeaksCompareAscend with peak1 == peak2
     381    {
     382        psMemId id = psMemGetId();
     383        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     384        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     385        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     386        *peak2 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     387        int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
     388        ok(rc == 0, "pmPeaksCompareAscend() returned correct result (peak1 == peak2)", rc);
     389        psFree(*peak1);
     390        psFree(peak1);
     391        psFree(*peak2);
     392        psFree(peak2);
     393        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     394    }
     395
     396
     397    // ------------------------------------------------------------------------
     398    // Calling pmPeaksCompareDescend with NULL peak1
     399    // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareDescend()
     400    if (0) {
     401        psMemId id = psMemGetId();
     402        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     403        *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     404        int rc = pmPeaksCompareDescend(NULL, (const void **) peak2);
     405        ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
     406        psFree(*peak2);
     407        psFree(peak2);
     408        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     409    }
     410
     411
     412    // Calling pmPeaksCompareDescend with NULL peak2
     413    // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareDescend()
     414    if (0) {
     415        psMemId id = psMemGetId();
     416        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     417        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     418        int rc = pmPeaksCompareDescend((const void **)peak1, NULL);
     419        ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
     420        psFree(*peak1);
     421        psFree(peak1);
     422        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     423    }
     424
     425
     426    // Calling pmPeaksCompareDescend with NULL *peak1
     427    // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareDescend()
     428    if (0) {
     429        psMemId id = psMemGetId();
     430        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     431        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     432        *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     433        int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
     434        ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
     435        psFree(peak1);
     436        psFree(*peak2);
     437        psFree(peak2);
     438        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     439    }
     440
     441
     442    // Calling pmPeaksCompareDescend with NULL *peak2
     443    // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareDescend()
     444    if (0) {
     445        psMemId id = psMemGetId();
     446        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     447        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     448        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     449        int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
     450        ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
     451        psFree(*peak1);
     452        psFree(peak1);
     453        psFree(peak2);
     454        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     455    }
     456
     457    // Calling pmPeaksCompareDescend with peak1 < peak2
     458    {
     459        psMemId id = psMemGetId();
     460        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     461        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     462        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     463        *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     464        int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
     465        ok(rc == 1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
     466        psFree(*peak1);
     467        psFree(peak1);
     468        psFree(*peak2);
     469        psFree(peak2);
     470        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     471    }
     472
     473
     474    // Calling pmPeaksCompareDescend with peak1 > peak2
     475    {
     476        psMemId id = psMemGetId();
     477        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     478        *peak1 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     479        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     480        *peak2 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     481        int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
     482        ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 > peak2)");
     483        psFree(*peak1);
     484        psFree(peak1);
     485        psFree(*peak2);
     486        psFree(peak2);
     487        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     488    }
     489
     490
     491    // Calling pmPeaksCompareDescend with peak1 == peak2
     492    {
     493        psMemId id = psMemGetId();
     494        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     495        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     496        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     497        *peak2 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     498        int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
     499        ok(rc == 0, "pmPeaksCompareDescend() returned correct result (peak1 == peak2)", rc);
     500        psFree(*peak1);
     501        psFree(peak1);
     502        psFree(*peak2);
     503        psFree(peak2);
     504        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     505    }
     506
     507
     508    // ------------------------------------------------------------------------
     509    // pmPeakSortBySN() tests
     510    // int pmPeakSortBySN (const void **a, const void **b)
     511    // Call pmPeakSortBySN() with acceptable input parameters.
     512    // XXX: We don't test with NULL input parameters since this functions has no PS_ASSERTS to protect
     513    // against that.
     514    {
     515        psMemId id = psMemGetId();
     516        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     517        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     518        (*peak1)->SN = 10.0;
     519        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     520        *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     521        (*peak2)->SN = 20.0;
     522        int rc = pmPeakSortBySN((const void **)peak1, (const void **) peak2);
     523        ok(rc == 1, "pmPeakSortBySN() returned correct result (peak1 < peak2) (%d)", rc);
     524        rc = pmPeakSortBySN((const void **)peak2, (const void **) peak1);
     525        ok(rc == -1, "pmPeakSortBySN() returned correct result (peak2 < peak1) (%d)", rc);
     526        rc = pmPeakSortBySN((const void **)peak1, (const void **) peak1);
     527        ok(rc == 0, "pmPeakSortBySN() returned correct result (peak1 == peak2) (%d)", rc);
     528        psFree(*peak1);
     529        psFree(peak1);
     530        psFree(*peak2);
     531        psFree(peak2);
     532        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     533    }
     534
     535
     536    // ------------------------------------------------------------------------
     537    // pmPeakSortByY() tests
     538    // int pmPeakSortByY (const void **a, const void **b)
     539    // Call pmPeakSortByY() with acceptable input parameters.
     540    // XXX: We don't test with NULL input parameters since this functions has no PS_ASSERTS to protect
     541    // against that.
     542    {
     543        psMemId id = psMemGetId();
     544        pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     545        *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
     546        (*peak1)->y = 10.0;
     547        pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
     548        *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
     549        (*peak2)->y = 20.0;
     550        int rc = pmPeakSortByY((const void **)peak1, (const void **) peak2);
     551        ok(rc == -1, "pmPeakSortByY() returned correct result (peak1 < peak2) (%d)", rc);
     552        rc = pmPeakSortByY((const void **)peak2, (const void **) peak1);
     553        ok(rc == 1, "pmPeakSortByY() returned correct result (peak2 < peak1) (%d)", rc);
     554        rc = pmPeakSortByY((const void **)peak1, (const void **) peak1);
     555        ok(rc == 0, "pmPeakSortByY() returned correct result (peak1 == peak2) (%d)", rc);
     556        psFree(*peak1);
     557        psFree(peak1);
     558        psFree(*peak2);
     559        psFree(peak2);
     560        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     561    }
     562
     563
     564    // ------------------------------------------------------------------------
    298565    // pmPeaksInVector() tests
    299566    // Test pmPeaksInVector() with bad input parameters.
     
    334601
    335602
    336 
    337     // ----------------------------------------
     603    // ------------------------------------------------------------------------
    338604    // pmPeaksInImage() tests
    339605    // Calling pmPeaksInImage with NULL psImage.  Should generate error.
     
    386652
    387653
    388 
    389     // ----------------------------------------
     654    // ------------------------------------------------------------------------
    390655    // Test pmPeaksSubset()
    391656    // Calling pmPeaksSubset with NULL psList.  Should generate error.
     
    476741        psFree(outData2);
    477742        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    478         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    479         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    480         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    481         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    482         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    483         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    484     }
    485 
    486 
    487     // ----------------------------------------
    488     // Calling pmPeaksCompareAscend with NULL peak1
    489     // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareAscend()
    490     if (0) {
    491         psMemId id = psMemGetId();
    492         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    493         *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
    494         int rc = pmPeaksCompareAscend(NULL, (const void **) peak2);
    495         ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
    496         psFree(*peak2);
    497         psFree(peak2);
    498         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    499     }
    500 
    501 
    502     // Calling pmPeaksCompareAscend with NULL peak2
    503     // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareAscend()
    504     if (0) {
    505         psMemId id = psMemGetId();
    506         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    507         *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    508         int rc = pmPeaksCompareAscend((const void **)peak1, NULL);
    509         ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
    510         psFree(*peak1);
    511         psFree(peak1);
    512         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    513     }
    514 
    515 
    516     // Calling pmPeaksCompareAscend with NULL *peak1
    517     // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareAscend()
    518     if (0) {
    519         psMemId id = psMemGetId();
    520         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    521         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    522         *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
    523         int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
    524         ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
    525         psFree(peak1);
    526         psFree(*peak2);
    527         psFree(peak2);
    528         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    529     }
    530 
    531 
    532     // Calling pmPeaksCompareAscend with NULL *peak2
    533     // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareAscend()
    534     if (0) {
    535         psMemId id = psMemGetId();
    536         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    537         *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    538         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    539         int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
    540         ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
    541         psFree(*peak1);
    542         psFree(peak1);
    543         psFree(peak2);
    544         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    545     }
    546 
    547     // Calling pmPeaksCompareAscend with peak1 < peak2
    548     {
    549         psMemId id = psMemGetId();
    550         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    551         *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    552         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    553         *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
    554         int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
    555         ok(rc == -1, "pmPeaksCompareAscend() returned correct result (peak1 < peak2)");
    556         psFree(*peak1);
    557         psFree(peak1);
    558         psFree(*peak2);
    559         psFree(peak2);
    560         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    561     }
    562 
    563 
    564     // Calling pmPeaksCompareAscend with peak1 > peak2
    565     {
    566         psMemId id = psMemGetId();
    567         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    568         *peak1 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
    569         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    570         *peak2 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    571         int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
    572         ok(rc == 1, "pmPeaksCompareAscend() returned correct result (peak1 > peak2)");
    573         psFree(*peak1);
    574         psFree(peak1);
    575         psFree(*peak2);
    576         psFree(peak2);
    577         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    578     }
    579 
    580 
    581     // Calling pmPeaksCompareAscend with peak1 == peak2
    582     {
    583         psMemId id = psMemGetId();
    584         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    585         *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    586         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    587         *peak2 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    588         int rc = pmPeaksCompareAscend((const void **)peak1, (const void **) peak2);
    589         ok(rc == 0, "pmPeaksCompareAscend() returned correct result (peak1 == peak2)", rc);
    590         psFree(*peak1);
    591         psFree(peak1);
    592         psFree(*peak2);
    593         psFree(peak2);
    594         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    595     }
    596 
    597 
    598     // ----------------------------------------
    599     // Calling pmPeaksCompareDescend with NULL peak1
    600     // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareDescend()
    601     if (0) {
    602         psMemId id = psMemGetId();
    603         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    604         *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
    605         int rc = pmPeaksCompareDescend(NULL, (const void **) peak2);
    606         ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
    607         psFree(*peak2);
    608         psFree(peak2);
    609         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    610     }
    611 
    612 
    613     // Calling pmPeaksCompareDescend with NULL peak2
    614     // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareDescend()
    615     if (0) {
    616         psMemId id = psMemGetId();
    617         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    618         *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    619         int rc = pmPeaksCompareDescend((const void **)peak1, NULL);
    620         ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
    621         psFree(*peak1);
    622         psFree(peak1);
    623         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    624     }
    625 
    626 
    627     // Calling pmPeaksCompareDescend with NULL *peak1
    628     // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareDescend()
    629     if (0) {
    630         psMemId id = psMemGetId();
    631         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    632         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    633         *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
    634         int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
    635         ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
    636         psFree(peak1);
    637         psFree(*peak2);
    638         psFree(peak2);
    639         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    640     }
    641 
    642 
    643     // Calling pmPeaksCompareDescend with NULL *peak2
    644     // XXX: This currently seg-faults because NULL args are not pretested in pmPeaksCompareDescend()
    645     if (0) {
    646         psMemId id = psMemGetId();
    647         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    648         *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    649         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    650         int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
    651         ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
    652         psFree(*peak1);
    653         psFree(peak1);
    654         psFree(peak2);
    655         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    656     }
    657 
    658     // Calling pmPeaksCompareDescend with peak1 < peak2
    659     {
    660         psMemId id = psMemGetId();
    661         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    662         *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    663         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    664         *peak2 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
    665         int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
    666         ok(rc == 1, "pmPeaksCompareDescend() returned correct result (peak1 < peak2)");
    667         psFree(*peak1);
    668         psFree(peak1);
    669         psFree(*peak2);
    670         psFree(peak2);
    671         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    672     }
    673 
    674 
    675     // Calling pmPeaksCompareDescend with peak1 > peak2
    676     {
    677         psMemId id = psMemGetId();
    678         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    679         *peak1 = pmPeakAlloc(3, 4, 3.0, PM_PEAK_LONE);
    680         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    681         *peak2 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    682         int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
    683         ok(rc == -1, "pmPeaksCompareDescend() returned correct result (peak1 > peak2)");
    684         psFree(*peak1);
    685         psFree(peak1);
    686         psFree(*peak2);
    687         psFree(peak2);
    688         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    689     }
    690 
    691 
    692     // Calling pmPeaksCompareDescend with peak1 == peak2
    693     {
    694         psMemId id = psMemGetId();
    695         pmPeak **peak1 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    696         *peak1 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    697         pmPeak **peak2 = (pmPeak **) psAlloc(sizeof(pmPeak *));
    698         *peak2 = pmPeakAlloc(3, 4, 2.0, PM_PEAK_LONE);
    699         int rc = pmPeaksCompareDescend((const void **)peak1, (const void **) peak2);
    700         ok(rc == 0, "pmPeaksCompareDescend() returned correct result (peak1 == peak2)", rc);
    701         psFree(*peak1);
    702         psFree(peak1);
    703         psFree(*peak2);
    704         psFree(peak2);
    705         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    706743    }
    707744}
    708 
Note: See TracChangeset for help on using the changeset viewer.