IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13123


Ignore:
Timestamp:
May 1, 2007, 6:14:33 PM (19 years ago)
Author:
gusciora
Message:

Added tabular file of all psLib functions in Chapter 6 of the SDRS (Data
Manipulation). Most of the test file changes in this check-in are fairly
cosmetic.

Location:
trunk/psLib/test
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/imageops/Makefile.am

    r13042 r13123  
    2121        tap_psImageConvolve2 \
    2222        tap_psImagePixelExtract \
    23         tap_psImageInterpolate2
     23        tap_psImageInterpolate2 \
     24        tap_psImageMaskOps
    2425
    2526#       tap_psImageShiftKernel
  • trunk/psLib/test/imageops/tap_psImageGeomManip.c

    r13084 r13123  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-05-01 00:08:52 $
     7 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-05-02 04:14:33 $
    99 *
    1010 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    154154    plan_tests(237);
    155155
    156     // testImageRebin()
    157     // This function shall generate a rescaled version of a psImage structure
    158     // derived from a specified statistics method.
     156    // test psImageRebin()
     157    // This function shall generate a rescaled version of a psImage
     158    // structure derived from a specified statistics method.
    159159    if (1) {
    160160        psMemId id = psMemGetId();
     
    295295        testRebinType(U16);
    296296        testRebinType(S8);
    297         // Verify the returned psImage structure is null and program execution
     297        // Verify the returned psImage structure is NULL and program execution
    298298        // doesn't stop, if the input image type is not supported.
    299299        // Following should be an error for unsupported type
     
    305305        ok(out == NULL, "psImageRebin returned NULL for unsupported type");
    306306
    307         // Verify the returned psImage structure is null and program execution
     307        // Verify the returned psImage structure is NULL and program execution
    308308        // doesn't stop, if the mask type is not U8
    309309        // Following should be an error for invallid mask type
     
    314314        psFree(in);
    315315
    316         // Verify the returned psImage structure is null and program execution
    317         // doesn't stop, if the input parameter input is null.
     316        // Verify the returned psImage structure is NULL and program execution
     317        // doesn't stop, if the input parameter input is NULL.
    318318        out2 = psImageRebin(NULL,NULL,NULL,0,1,&stats);
    319319        ok(out2 == NULL, "psImageRebin returned NULL with NULL input");
    320320
    321         // Verify the returned psImage structure is null and program execution
     321        // Verify the returned psImage structure is NULL and program execution
    322322        // doesn't stop, if the input parameter scale is less than or equal to zero.
    323323        in = psImageAlloc(16, 16, PS_TYPE_F32);
     
    327327        ok(out2 == NULL, "psImageRebin returned NULL when the scale was zero");
    328328
    329         // Verify the returned psImage structure is null and program execution
    330         // doesn't stop, if the input parameter stats is null.
    331         // Following should be an error for stats null
     329        // Verify the returned psImage structure is NULL and program execution
     330        // doesn't stop, if the input parameter stats is NULL.
     331        // Following should be an error for stats NULL
    332332        // XXX: Verify error
    333333        out2 = psImageRebin(NULL,in,NULL,0,1,NULL);
    334334        ok(out2 == NULL, "psImageRebin returned an NULL when the stats was NULL");
    335335
    336         // Verify the returned psImage structure is null and program execution
     336        // Verify the returned psImage structure is NULL and program execution
    337337        // doesn't stop, if the input parameter psStats structure member options
    338338        // is zero or any value which doesn't correspond to a valid statistical
     
    350350        ok(out2 == NULL, "psImageRebin returned an image though the stats options was PS_STAT_USE_RANGE");
    351351
    352         // Verify the returned psImage structure is null and program execution
     352        // Verify the returned psImage structure is NULL and program execution
    353353        // doesn't stop, if the input parameter psStats structure member options
    354354        // specifies more than one valid statistical method.
     
    363363    }
    364364
    365     // testImageRoll()
     365    // test psImageRoll()
    366366    if (1) {
    367367        psMemId id = psMemGetId();
     
    387387
    388388        in = psImageAlloc(cols,rows,PS_TYPE_F32);
    389         for (psS32 row=0;row<rows;row++)
    390         {
    391             psF32 *inRow = in->data.F32[row];
    392             for (psS32 col=0;col<cols;col++) {
    393                 inRow[col] = (psF32)row+(psF32)col/1000.0f;
     389        for (psS32 row=0;row<rows;row++) {
     390            for (psS32 col=0;col<cols;col++) {
     391                in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f;
    394392            }
    395393        }
     
    397395        out = psImageRoll(NULL,in,0,0);
    398396        bool errorFlag = false;
    399         for (psS32 row=0;row<rows;row++)
    400         {
     397        for (psS32 row=0;row<rows;row++) {
    401398            psF32 *inRow = in->data.F32[row];
    402399            psF32 *outRow = out->data.F32[row];
     
    519516
    520517
    521         // Verify the returned psImage structure pointer is null and program
    522         // execution doesn't stop, if input parameter input is null.
     518        // Verify the returned psImage structure pointer is NULL and program
     519        // execution doesn't stop, if input parameter input is NULL.
    523520        out2 = psImageRoll(NULL,NULL,0,0);
    524         if (out2 != NULL)
    525         {
     521        if (out2 != NULL) {
    526522            psError(PS_ERR_UNKNOWN, true,"psImageRoll did not return NULL though input image was NULL!?");
    527523            return 2;
     
    567563    }
    568564
    569 
    570     // testImageRotate()
     565    // test psImageRotate()
    571566    if (1) {
    572567        psMemId id = psMemGetId();
     
    599594        psImage *sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
    600595
    601         for(psS32 row=0;row<rows;row++)
    602         {
     596        for(psS32 row=0;row<rows;row++) {
    603597            psF32 *fRow = fImg->data.F32[row];
    604598            psS16 *sRow = sImg->data.S16[row];
     
    612606        // is to verify the results manually and bless it for automated comparison
    613607        // thereafter
    614 
    615608
    616609        // write results of various rotates to a file and verify with truth images
     
    796789        }
    797790//HERE
    798         // Verify the returned psImage structure pointer is null and program
    799         // execution doesn't stop, if the input parameter input is null.
     791        // Verify the returned psImage structure pointer is NULL and program
     792        // execution doesn't stop, if the input parameter input is NULL.
    800793        // Following should be an error
    801794        // XXX: Verify error
     
    803796        ok(fOut == NULL, "NULL was returned when the input image was NULL");
    804797
    805         // Verify the returned psImage structure pointer is null and program
     798        // Verify the returned psImage structure pointer is NULL and program
    806799        // execution doesn't stop, if the specified interpolation mode is unallowed
    807800        // Following should be an error for unallowed interpolation type
     
    882875        ok(fRecycle == fOut, "psImageShift did recycle my image");
    883876
    884         // Verify the returned psImage structure pointer is null and program
    885         // execution doesn't stop, if the input psImage structure pointer is null.
     877        // Verify the returned psImage structure pointer is NULL and program
     878        // execution doesn't stop, if the input psImage structure pointer is NULL.
    886879        // Following should be an error
    887880        // XXX: Verify error
     
    889882        ok(fOut == NULL, "psImageShift did return NULL given a NULL input image");
    890883
    891         // Verify the returned psImage structure is null and program execution
     884        // Verify the returned psImage structure is NULL and program execution
    892885        // doesn't stop, if the specified interpolation mode is unallowed.
    893886        // Following should be an error for unallowed interpolation mode
     
    901894
    902895
    903     // testImageResample()
     896    // test psImageResample()
    904897    if (1) {
    905898        psMemId id = psMemGetId();
    906 
    907899        psS32 rows = 60;
    908900        psS32 cols = 80;
     
    911903        psErr *err;
    912904
    913         psImage *image = psImageAlloc(cols,rows,PS_TYPE_F32);
    914         for(psS32 row=0;row<rows;row++)
    915         {
    916             psF32 *imageRow = image->data.F32[row];
    917             for (psS32 col=0;col<cols;col++) {
    918                 imageRow[col] = row+2*col;
     905        psImage *image = psImageAlloc(cols, rows, PS_TYPE_F32);
     906        for(psS32 row=0;row<rows;row++) {
     907            for (psS32 col=0;col<cols;col++) {
     908                image->data.F32[row][col] = row+2*col;
    919909            }
    920910        }
     
    925915        ok(result == orig, "psImageResample() recycled image");
    926916        ok(result->type.type == PS_TYPE_F32, "psImageResample() produced the correct type");
    927 
    928 
    929917        ok(result->numCols == image->numCols*scale && result->numRows == image->numRows*scale,
    930918           "psImageResample() produced the correct size");
    931 
    932919
    933920        bool errorFlag = false;
     
    939926            psMaskType maskVal;
    940927            psF32 truthValue;
    941             for(psS32 row=0;row<result->numRows;row++)
    942             {
     928            for(psS32 row=0;row<result->numRows;row++) {
    943929                for (psS32 col=0;col<result->numCols;col++) {
    944930//                    truthValue = psImagePixelInterpolate(image,
     
    961947        ok(!errorFlag, "psImageResample() produced the correct data values");
    962948
    963         // verify that image=null is handled properly.
     949        // verify that image=NULL is handled properly.
    964950        psErrorClear();
    965951        result = psImageResample(result,NULL,scale,PS_INTERPOLATE_FLAT);
     
    1002988
    1003989
    1004     // testImageTransform()
     990    // test psImageTransform()
    1005991    if (1) {
    1006992        psMemId id = psMemGetId();
     
    1013999
    10141000        psImage *in = psImageAlloc(cols,rows,PS_TYPE_F32);
    1015         for (psS32 row=0;row<rows;row++)
    1016         {
    1017             psF32 *inRow = in->data.F32[row];
    1018             for (psS32 col=0;col<cols;col++) {
    1019                 inRow[col] = (psF32)row+(psF32)col/1000.0f;
     1001        for (psS32 row=0;row<rows;row++) {
     1002            for (psS32 col=0;col<cols;col++) {
     1003                in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f;
    10201004            }
    10211005        }
    10221006        P_PSIMAGE_SET_COL0(in, 1);
    1023         psImage *out = psImageTransform(NULL,
    1024                                         NULL,
    1025                                         in,
    1026                                         NULL,
    1027                                         0,
    1028                                         trans,
    1029                                         psRegionSet(1,1+cols*2,0,rows*2),
    1030                                         NULL,
    1031                                         PS_INTERPOLATE_FLAT,
    1032                                         -1);
     1007        psImage *out = psImageTransform(NULL, NULL, in, NULL, 0, trans,
     1008                                        psRegionSet(1,1+cols*2,0,rows*2), NULL,
     1009                                        PS_INTERPOLATE_FLAT, -1);
    10331010
    10341011        ok(out != NULL, "psImageTransform() returned non-NULL");
     
    10361013        ok(out->numRows == rows*2 && out->numCols == cols*2, "psImageTransform() produced the correct size");
    10371014
    1038         if (0) {
     1015        if (1) {
    10391016            psMemId id = psMemGetId();
    10401017            psImageInterpolateOptions *tmpIntOpts = psImageInterpolateOptionsAlloc(
     
    10451022            psMaskType maskVal;
    10461023            bool errorFlag = false;
    1047             for (psS32 row=0;row<out->numRows;row++)
    1048             {
    1049                 psF32 *outRow = out->data.F32[row];
     1024            for (psS32 row=0;row<out->numRows;row++) {
    10501025                for (psS32 col=0;col<cols;col++) {
    10511026                    psImageInterpolate(&imgVal, &varVal, &maskVal,
     
    10541029                                       tmpIntOpts);
    10551030                    float inValue = imgVal;
    1056                     if (fabsf(outRow[col] - inValue) > 0.01) {
    1057                         diag("out at %d,%d was %g, expected %g", col,row,outRow[col], inValue);
     1031                    if (fabsf(out->data.F32[row][col] - inValue) > 0.01) {
     1032                        diag("out at %d,%d was %g, expected %g", col,row,
     1033                              out->data.F32[row][col], inValue);
    10581034                        errorFlag = true;
    10591035                    }
  • trunk/psLib/test/imageops/tap_psImageMaskOps.c

    r11729 r13123  
    33 *  @brief Contains the tests for psMaskOps.[ch]
    44 *
    5  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-02-09 20:40:22 $
     5 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-05-02 04:14:33 $
    77 *
    88 *  XXX: In general, the image tests with (1, N) and (N, 1) failed and have
     
    721721        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    722722    }
     723    // XXX: These seg fault
    723724    if (0) genericImageMaskCircleTest(N, 1, N/2, 1, N/4);
    724725    if (0) genericImageMaskCircleTest(1, N, 1, N/2, N/4);
     
    734735        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    735736    }
     737    // XXX: These seg fault
    736738    if (0) genericImageKeepCircleTest(N, 1, N/2, 1, N/4);
    737739    if (0) genericImageKeepCircleTest(1, N, 1, N/2, N/4);
  • trunk/psLib/test/imageops/tap_psImagePixelExtract.c

    r13042 r13123  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2007-04-26 22:18:03 $
     8*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2007-05-02 04:14:33 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1717#include "pstap.h"
    1818
    19 psS32 main( psS32 argc, char* argv[] )
     19psS32 main(psS32 argc, char* argv[])
    2020{
    2121    psLogSetFormat("HLNM");
     
    2323    plan_tests(248);
    2424
    25     // testImageSlice()
     25    // test psImageSlice()
    2626    {
    2727        psMemId id = psMemGetId();
     
    3131        const psS32 n = r / 4 -1;
    3232        psImage* image;
    33         psPixels* positions = psPixelsAlloc( r );
    34         psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK );
    35         psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN );
     33        psPixels* positions = psPixelsAlloc(r);
     34        psImage* mask = psImageAlloc(c, r, PS_TYPE_MASK);
     35        psStats* stat = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
    3636   
    3737
     
    4646        // cases should be used for each possible direction. Data region cases
    4747        // should include 0x0, 1x1, Nx1, 1xN, NxN, MxN
    48         for ( psS32 row = 0;row < r;row++ ) {
     48        for (psS32 row = 0;row < r;row++) {
    4949            psMaskType* maskRow = mask->data.PS_TYPE_MASK_DATA[row];
    50             for ( psS32 col = 0;col < c;col++ ) {
    51                 maskRow[ col ] = 0;
     50            for (psS32 col = 0;col < c;col++) {
     51                maskRow[col] = 0;
    5252            }
    5353        }
     
    5858            psVector* out = NULL; \
    5959            bool errorFlag = false; \
    60             image = psImageAlloc( c, r, PS_TYPE_##TYPE ); \
    61             for ( psS32 row = 0;row < r;row++ ) { \
    62                 ps##TYPE *imageRow = image->data.TYPE[ row ]; \
     60            image = psImageAlloc(c, r, PS_TYPE_##TYPE); \
     61            for (psS32 row = 0;row < r;row++) { \
     62                ps##TYPE *imageRow = image->data.TYPE[row]; \
    6363                ps##TYPE rowOffset = row * 2; \
    64                 for ( psS32 col = 0;col < c;col++ ) { \
    65                     imageRow[ col ] = col + rowOffset; \
     64                for (psS32 col = 0;col < c;col++) { \
     65                    imageRow[col] = col + rowOffset; \
    6666                } \
    6767            } \
     
    111111        //
    112112        #define PSIMAGESLICE_TEST(TYPE) \
    113         PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0 ); \
    114         PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1 ); \
    115         PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2 ); \
    116         PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3 ); \
     113        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0); \
     114        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1); \
     115        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2); \
     116        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3); \
    117117        \
    118         PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4 ); \
    119         PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5 ); \
    120         PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6 ); \
    121         PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7 ); \
     118        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4); \
     119        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5); \
     120        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6); \
     121        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7); \
    122122        \
    123         PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8 ); \
    124         PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9 ); \
    125         PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10 ); \
    126         PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11 ); \
     123        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8); \
     124        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9); \
     125        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10); \
     126        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11); \
    127127        \
    128         PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12 ); \
    129         PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13 ); \
    130         PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14 ); \
    131         PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15 ); \
     128        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12); \
     129        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13); \
     130        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14); \
     131        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15); \
    132132   
    133133        PSIMAGESLICE_TEST(F32);
     
    149149                           psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1),
    150150                           PS_CUT_X_POS,
    151                            stat );
     151                           stat);
    152152        ok(out == NULL, "psImageSlice() returned NULL with NULL input");
    153153   
     
    156156        // Following should be an error
    157157        // XXX: Verify error
    158         out = psImageSlice( out,
     158        out = psImageSlice(out,
    159159                            NULL, image,
    160160                            mask, 1,
    161161                            psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1),
    162162                            PS_CUT_X_POS,
    163                             NULL );
     163                            NULL);
    164164        ok(out == NULL, "psImageSlice() returned NULL with NULL psStats");
    165             psError( PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
     165            psError(PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected");
    166166
    167167        // Verify the returned psVector structure pointer is null and program
     
    182182        // Following should be an error
    183183        // XXX: Verify error
    184         out = psImageSlice( out,
     184        out = psImageSlice(out,
    185185                            NULL,
    186186                            image,
     
    188188                            psRegionSet(c/10, c/10, r/10, r/10),
    189189                            PS_CUT_X_POS,
    190                             stat );
     190                            stat);
    191191        ok(out == NULL, "psImageSlice() returned NULL with 0x0 region");
    192192   
     
    196196        // Following should be an error
    197197        // XXX: Verify error
    198         out = psImageSlice( out, NULL,
     198        out = psImageSlice(out, NULL,
    199199                            image,
    200200                            mask, 1,
    201201                            psRegionSet(c+1, c+2, r/10, r/10 + 10),
    202202                            PS_CUT_X_POS,
    203                             stat );
     203                            stat);
    204204        ok(out == NULL, "psImageSlice() returned NULL with unallowed x position");
    205205   
    206206        // Following should be an error
    207207        // XXX: Verify error
    208         out = psImageSlice( out, NULL,
     208        out = psImageSlice(out, NULL,
    209209                            image,
    210210                            mask, 1,
    211211                            psRegionSet(c/10, c/10 + 1, r+1,r+5),
    212212                            PS_CUT_X_POS,
    213                             stat );
     213                            stat);
    214214        ok(out == NULL, "psImageSlice() returned NULL with unallowed y position");
    215215   
    216216        // Following should be an error
    217217        // XXX: Verify error
    218         out = psImageSlice( out, NULL,
     218        out = psImageSlice(out, NULL,
    219219                            image,
    220220                            mask, 1,
     
    226226        // Following should be an error
    227227        // XXX: Verify error
    228         out = psImageSlice( out, NULL,
     228        out = psImageSlice(out, NULL,
    229229                            image,
    230230                            mask, 1,
     
    240240        // XXX: Verify error
    241241        stat->options = 0;
    242         out = psImageSlice( out, NULL,
     242        out = psImageSlice(out, NULL,
    243243                            image,
    244244                            mask, 1,
     
    253253        // XXX: Verify error
    254254        stat->options = PS_STAT_SAMPLE_MEDIAN;
    255         psImage* maskSz = psImageAlloc( r, c, PS_TYPE_MASK );
    256         out = psImageSlice( out, NULL,
     255        psImage* maskSz = psImageAlloc(r, c, PS_TYPE_MASK);
     256        out = psImageSlice(out, NULL,
    257257                            image,
    258258                            maskSz, 1,
     
    265265        // Following should be an error unallowed mask type
    266266        // XXX: Verify error
    267         psImage* maskS8 = psImageAlloc( c, r, PS_TYPE_S8 );
    268         out =  psImageSlice( out, NULL,
     267        psImage* maskS8 = psImageAlloc(c, r, PS_TYPE_S8);
     268        out =  psImageSlice(out, NULL,
    269269                             image,
    270270                             maskS8, 1,
     
    276276        //Added tests after subimage changes.
    277277        psFree(image);
    278         image = psImageAlloc( c, r, PS_TYPE_F64 );
    279         for ( psS32 row = 0;row < r;row++ ) {
    280             psF64 *imageRow = image->data.F64[ row ];
     278        image = psImageAlloc(c, r, PS_TYPE_F64);
     279        for (psS32 row = 0;row < r;row++) {
     280            psF64 *imageRow = image->data.F64[row];
    281281            psF64 rowOffset = row * 2;
    282             for ( psS32 col = 0;col < c;col++ ) {
    283                 imageRow[ col ] = col + rowOffset;
     282            for (psS32 col = 0;col < c;col++) {
     283                imageRow[col] = col + rowOffset;
    284284            }
    285285        }
     
    441441                    float y = (float)startRow[n]+(float)i*deltaRow;
    442442                    if (n == 1) {
    443 //                        truth = psImagePixelInterpolate( image, x, y,
     443//                        truth = psImagePixelInterpolate(image, x, y,
    444444//                                                         NULL,0,0,PS_INTERPOLATE_FLAT);
    445445                          psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsNoMask);
    446446                          truth = imgVal;
    447447                    } else {
    448 //                        truth = psImagePixelInterpolate( image, x, y,
     448//                        truth = psImagePixelInterpolate(image, x, y,
    449449//                                                         mask,1,0,PS_INTERPOLATE_FLAT);
    450450                          psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsMask);
     
    520520
    521521
    522     // testImageRadialCut()
     522    // test psImageRadialCut()
    523523    {
    524524        psMemId id = psMemGetId();
     
    557557                if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) {
    558558                    diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)",
    559                           result->data.F64[i], (15.0+i*10) );
     559                          result->data.F64[i], (15.0+i*10));
    560560                    errorFlag = true;
    561561                }
     
    574574                if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) {
    575575                    diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)",
    576                           result->data.F64[i], (15.0+i*10) );
     576                          result->data.F64[i], (15.0+i*10));
    577577                    errorFlag = true;
    578578                }
     
    709709        // Following should generate error message(for row)
    710710        // XXX: Verify error
    711         out = psImageRow(NULL, image, num);
     711        out = psImageRow(NULL, NULL, num);
    712712        ok(out == NULL, "psImageRow() returned NULL with NULL input image");
    713713
    714714        // Following should generate error message(for col)
    715715        // XXX: Verify error
    716         out = psImageCol(NULL, image, num);
     716        out = psImageCol(NULL, NULL, num);
    717717        ok(out == NULL, "psImagecol() returned NULL with NULL input image");
    718    
    719718        image = psImageAlloc(3, 3, PS_TYPE_F64);
    720719
    721720
    722721        //Test for unallowed row0.
    723         *(psS32*)&(image->row0) = -1;
     722        P_PSIMAGE_SET_ROW0(image, -2);
    724723        // Following should generate error message(for row)
    725724        // XXX: Verify error
     
    810809   
    811810        //Test valid cases.
     811        //XXX: We do not verify the data values.
    812812        P_PSIMAGE_SET_COL0(image, 10);
    813813        P_PSIMAGE_SET_ROW0(image, 5);
     
    875875   
    876876        //Test for error with NULL image
    877         empty = psImageCol(empty, emptyImage, 0);
     877        empty = psImageCol(empty, NULL, 0);
    878878        ok(empty == NULL, "psImageCol returned NULL for NULL image input");
    879879        //Test for error with Out of Range Row
     
    894894        test1 = fabs(rowcol->data.F64[0]-66.6);
    895895        test2 = fabs(rowcol->data.F64[2]-666.66);
    896         ok(!( (test1>TOLTST) || (test2>TOLTST)),
     896        ok(!((test1>TOLTST) || (test2>TOLTST)),
    897897           "psImageRow returned correct values");
    898898        psFree(rowcol);
  • trunk/psLib/test/imageops/tap_psImagePixelManip.c

    r12440 r13123  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-03-14 21:20:28 $
     8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-05-02 04:14:33 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2222    psLogSetFormat("HLNM");
    2323    psLogSetLevel(PS_LOG_INFO);
    24     plan_tests(47);
    25 
    26     // testImageClip()
     24    plan_tests(107);
     25
     26    // test psImageClip()
    2727    {
    2828        psMemId id = psMemGetId();
     
    4444        // Verify the retuned integer is zero, psImage structure input is unmodified
    4545        // and program executions doesn't stop, if input parameter psImage structure
    46         // pointer is null.
     46        // pointer is NULL.
    4747        //
    4848        // Verify the retuned integer is zero, psImage structure input is unmodified
     
    111111        // Verify the retuned integer is zero, psImage structure input is unmodified
    112112        // and program executions doesn't stop, if input parameter psImage structure
    113         // pointer is null.
     113        // pointer is NULL.
    114114        retVal = psImageClip(NULL,min,-1.0f,max,-2.0f);
    115115        ok(retVal == 0, "Expected zero return for clips of a NULL image");
     
    144144        //
    145145        // Verify the returned integer is zero and program execution doesn't stop,
    146         // if the input parameter psImage structure pointer is null.
     146        // if the input parameter psImage structure pointer is NULL.
    147147        // create image
    148148        #define testImageClipNaNByType(datatype) \
     
    193193        // Verify the retuned integer is zero, psImage structure input is unmodified
    194194        // and program executions doesn't stop, if input parameter psImage structure
    195         // pointer is null.
     195        // pointer is NULL.
    196196        retVal = psImageClipNaN(NULL,-1.0f);
    197197        ok(retVal == 0, "Expected zero return for clips of a NULL image");
     
    286286        testOverlayTypeOP(DATATYPE,=,"=");
    287287
    288 
    289         //        testOverlayType(F64);
    290         //        testOverlayType(F32);
    291         //        testOverlayType(S16);
    292         //        testOverlayType(S8);
    293         //        testOverlayType(U16);
    294         //        testOverlayType(U8);
     288        testOverlayType(F64);
     289        testOverlayType(F32);
     290        testOverlayType(S16);
     291        testOverlayType(S8);
     292        testOverlayType(U16);
     293        testOverlayType(U8);
    295294
    296295        // Verify the returned integer is equal to non-zero and the input psImage structure
     
    351350        // Verify the returned integer is equal to non-zero, the input psImage
    352351        // structure is unmodified and program execution doesn't stop, if the
    353         // overlay specified is null.
     352        // overlay specified is NULL.
    354353        // Following should error as overlay is NULL
    355354        // XXX: Verify error
     
    371370
    372371        // Verify the returned integer is equal to non-zero and program execution
    373         // doesn't stop, if the input parameter image is null.
     372        // doesn't stop, if the input parameter image is NULL.
    374373        // Following should error as image input is NULL
    375374        // XXX: Verify error
     
    416415        ok(retVal != 0, "psImageOverlaySection returned non-zero when checking divide-by-zero");
    417416        errorFlag = false;
    418 
    419 
    420 
    421 
    422 
    423 
    424 
    425 
    426 
    427 
    428 
    429 
    430 
    431 
    432 
    433 
    434 
    435 
    436 
    437 
    438 
    439 
    440 
    441 
    442 
    443 
    444 
    445 
    446 
    447 
    448417
    449418        for (unsigned row=0;row<r;row++)
  • trunk/psLib/test/imageops/tap_psImageStats.c

    r11729 r13123  
    273273    const int CHEBY_Y_DIM = 8;
    274274    const int THRESHOLD = 1;
    275     psImage *imgIn = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32 );
    276     psImage *imgOut = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32 );
    277     for (int i = 0;i < IMAGE_SIZE;i++ ) {
    278         for (int j = 0;j < IMAGE_SIZE;j++ ) {
     275    psImage *imgIn = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
     276    psImage *imgOut = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
     277    for (int i = 0;i < IMAGE_SIZE;i++) {
     278        for (int j = 0;j < IMAGE_SIZE;j++) {
    279279            imgIn->data.F32[ i ][ j ] = 4.0;
    280             imgIn->data.F32[ i ][ j ] = ( float ) ( i + j );
    281             imgIn->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i );
     280            imgIn->data.F32[ i ][ j ] = (float) (i + j);
     281            imgIn->data.F32[ i ][ j ] = (float) (i + j) + (4.0 * (float) i);
    282282            imgOut->data.F32[ i ][ j ] = 0.0;
    283283        }
    284284    }
    285285    psPolynomial2D *my2DPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, CHEBY_X_DIM-1, CHEBY_Y_DIM-1);
    286     my2DPoly = psImageFitPolynomial(my2DPoly, imgIn );
     286    my2DPoly = psImageFitPolynomial(my2DPoly, imgIn);
    287287    ok(my2DPoly != NULL, "psImageFitPolynomial() returned non-NULL");
    288288
    289     imgOut = psImageEvalPolynomial( imgOut, my2DPoly );
     289    imgOut = psImageEvalPolynomial(imgOut, my2DPoly);
    290290    bool errorFlag = false;
    291     for (int i = 0;i < IMAGE_SIZE;i++ ) {
    292         for (int j = 0;j < IMAGE_SIZE;j++ ) {
    293             if ( fabs( imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ] ) > THRESHOLD ) {
     291    for (int i = 0;i < IMAGE_SIZE;i++) {
     292        for (int j = 0;j < IMAGE_SIZE;j++) {
     293            if (fabs(imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ]) > THRESHOLD) {
    294294                diag("Pixel (%d, %d) is %.2f, should be %.2f\n", i, j,
    295295                     imgOut->data.F32[ i ][ j ],
     
    357357        ok(hist2 == hist, "psImageHistogram() correctly recycled the input psHistogram");
    358358        bool errorFlag = false;
    359         for (int i = 0;i < numBins;i++ ) {
     359        for (int i = 0;i < numBins;i++) {
    360360            if (hist2->nums->data.F32[i] != (numCols * (numRows/numBins))) {
    361361                diag("ERROR: Bin number %d bounds: (%.1f - %.1f) data (%.2f)\n", i,
     
    434434    }
    435435
    436     // Ensure psImageCountPixelMask returns -1 for NULL input image
     436    // Ensure psImageCountPixelMask returns -1 for wrong input image type
    437437    // Following should generate error
    438438    // XXX: Verify error
     
    486486    // --------------------------------------------------------------
    487487    // psImageStats()
    488     // Ensure psImageStats() returnes NULL for NULL input image
     488    // Ensure psImageStats() returns NULL for NULL input image
    489489    // Following should generate error
    490490    // XXX: Verify error
     
    499499    }
    500500
    501     // Ensure psImageStats() returnes NULL for NULL psStats
     501    // Ensure psImageStats() returns NULL for NULL psStats
    502502    // Following should generate error
    503503    // XXX: Verify error
  • trunk/psLib/test/imageops/tap_psImageStructManip.c

    r11688 r13123  
    1 /** @file  tst_psImageExtraction.c
     1/** @file  tap_psImageStructManip.c
    22*
    33*  @brief Contains the tests for psImageExtraction.[ch]
    44*
    5 *
    65*  @author Robert DeSonia, MHPCC
    76*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2007-02-08 01:21:50 $
     7*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2007-05-02 04:14:33 $
    109*
    1110*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2625    // psImageSubset shall create child image of a specified size from a
    2726    // parent psImage structure
    28 
    2927    // psImageSubset()
    3028    {
     
    3331        psS32 c = 128;
    3432        psS32 r = 256;
    35         psRegion region1 = psRegionSet(0,c/2,0,r/2);
    36         psRegion region2 = psRegionSet(c/4,c/4+c/2,r/4,r/4+r/2);
     33        psRegion region1 = psRegionSet(0, c/2, 0, r/2);
     34        psRegion region2 = psRegionSet(c/4, c/4+c/2, r/4, r/4+r/2);
    3735
    3836        psImage* original = psImageAlloc(c,r,PS_TYPE_U32);
    39         for (psS32 row=0;row<r;row++)
    40         {
     37        for (psS32 row=0;row<r;row++) {
    4138            for (psS32 col=0;col<c;col++) {
    4239                original->data.F32[row][col] = row*1000+col;
     
    6360
    6461        bool errorFlag = false;
    65         for (psS32 row=0;row<r/2;row++)
    66         {
     62        for (psS32 row=0;row<r/2;row++) {
    6763            for (psS32 col=0;col<c/2;col++) {
    6864                if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) {
     
    9995        ok(subset2->children == NULL && subset3->children == NULL, "psImageSubset() set ->children correctly");
    10096
    101 
    10297        // Verify the input psImage structure image only has the following members
    10398        // changed: 1) Nchildren is increased by one. 2) parent contains pointer psImage structure
     
    107102           "psImageSubset did properly store the children pointers.");
    108103
     104
    109105        // Verify the returned psImage structure pointer is null and program
    110106        // execution doesn't stop, if the input parameter image is null.
     
    114110        psImage* subset1 = psImageSubset(NULL,region1);
    115111        ok(subset1 == NULL, "psImageSubset returned NULL when input image was NULL.");
     112
    116113
    117114        // Verify the returned psImage structure pointer is null and program
     
    153150        ok(subset1 == NULL,
    154151           "psImageSubset returned NULL when subset origin was outside of image (row0=-1)");
     152
    155153
    156154        // Verify the returned psImage structure pointer is null and program
     
    205203        psU32 r = 256;
    206204
    207         psImage* img = psImageAlloc(c,r,PS_TYPE_F32);
    208         for (unsigned row=0;row<r;row++)
    209         {
    210             psF32* imgRow = img->data.F32[row];
     205        psImage *img = psImageAlloc(c,r,PS_TYPE_F32);
     206        for (unsigned row=0;row<r;row++) {
    211207            for (unsigned col=0;col<c;col++) {
    212                 imgRow[col] = (psF32)(row+col);
    213             }
    214         }
    215         psImage* img2 = psImageAlloc(c,r,PS_TYPE_F32);
    216         for (unsigned row=0;row<r;row++)
    217         {
    218             psF32* img2Row = img2->data.F32[row];
     208                img->data.F32[row][col] = (psF32)(row+col);
     209            }
     210        }
     211        psImage *img2 = psImageAlloc(c,r,PS_TYPE_F32);
     212        for (unsigned row=0;row<r;row++) {
    219213            for (unsigned col=0;col<c;col++) {
    220                 img2Row[col] = 0.0f;
    221             }
    222         }
    223 
    224         psImage* img3 = psImageCopy(img2,img,PS_TYPE_F32);
    225         // Verify the returned psImage structure pointer is equal to the input parameter output.
     214                img2->data.F32[row][col] = 0.0f;
     215            }
     216        }
     217
     218        psImage *img3 = psImageCopy(img2,img,PS_TYPE_F32);
     219        // Verify the returned psImage structure pointer is equal to the input
     220        // parameter output.
    226221        ok(img2 == img3, "psImageCopy(): recycled input image");
    227222
    228         // Verify the returned psImage structure is the same type as the input image structure
    229         // if the specified output argument is NULL.
    230         psImage* img4 = psImageCopy(NULL,img,PS_TYPE_F32);
     223        // Verify the returned psImage structure is the same type as the input image
     224        // structure if the specified output argument is NULL.
     225        psImage *img4 = psImageCopy(NULL,img,PS_TYPE_F32);
    231226        ok(img4 != NULL, "psImageCopy() returned non-NULL with NULL output argument");
    232227        ok(img4->type.type == img->type.type, "psImageCopy() set the correct image type");
    233228        bool errorFlag = false;
    234         for (psU32 row=0;row<r;row++)
    235         {
     229        for (psU32 row=0;row<r;row++) {
    236230            psF32* imgInRow = img->data.F32[row];
    237231            psF32* imgOutRow = img4->data.F32[row];
     
    326320        psS32 halfR = r/2;
    327321        psS32 halfC = c/2;
    328         psRegion centerHalf = {qtrC,qtrC+halfC,qtrR,qtrR+halfR};
     322        psRegion centerHalf = {qtrC, qtrC+halfC, qtrR, qtrR+halfR};
    329323
    330324        psImage* image = psImageAlloc(c,r,PS_TYPE_F32);
    331         for (psS32 row = 0; row < image->numRows; row++)
    332         {
     325        for (psS32 row = 0; row < image->numRows; row++) {
    333326            for (psS32 col = 0; col < image->numCols; col++) {
    334327                image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f;
    335328            }
    336329        }
    337 
    338330        // invoke psImageTrim with non-NULL image, and a valid region
    339331        // x0,y0->x1,y1 (using only positive values). Verify that:
     
    350342
    351343        bool errorFlag = false;
    352         for (psS32 row = 0; row < image2->numRows; row++)
    353         {
     344        for (psS32 row = 0; row < image2->numRows; row++) {
    354345            for (psS32 col = 0; col < image2->numCols; col++) {
    355346                if (fabsf(image2->data.F32[row][col] - image->data.F32[row+qtrR][col+qtrC])
     
    379370           image->numCols-qtrC, image->numRows-qtrR);
    380371
    381         for (psS32 row = 0; row < image2->numRows; row++)
    382         {
     372        for (psS32 row = 0; row < image2->numRows; row++) {
    383373            for (psS32 col = 0; col < image2->numCols; col++) {
    384374                if (fabsf(image2->data.F32[row][col] -
     
    394384        ok(!errorFlag, "psImageTrim() set image data correctly");
    395385
    396         //  4. invoke psImageTrim with x1<0, y1<0. Verify:
     386
     387        //  Invoke psImageTrim with x1<0, y1<0. Verify:
    397388        //      a. the psImage size is (numCols+x1)-x0 by (numRows+y1)-y0.
    398389        //      b. the pixel values coorespond to the region
     
    405396           image2->numCols, image2->numRows,
    406397           image->numCols-qtrC, image->numRows-qtrR);
    407 
    408         for (psS32 row = 0; row < image2->numRows; row++)
    409         {
     398        for (psS32 row = 0; row < image2->numRows; row++) {
    410399            for (psS32 col = 0; col < image2->numCols; col++) {
    411400                if (fabsf(image2->data.F32[row][col] -
     
    422411        psFree(image1);
    423412
    424         //  6. invoke psImageTrim with image=NULL Verify:
     413
     414        //  Invoke psImageTrim with image=NULL Verify:
    425415        //      a. execution does not cease.
    426416        //      b. return value is NULL
     
    428418        // An error should follow...
    429419        // XXX: Verify errors
    430 
    431 
    432420        image2 = psImageTrim(NULL, psRegionSet(qtrC,0,qtrR,0));
    433421        ok(image2 == NULL, "psImageTrim returned NULL given a NULL input image");
     
    438426
    439427
     428        // Verify when psRegion has a coord at -1
    440429        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    441430        image2 = psImageTrim(image1, psRegionSet(-1,0,0,0));
     
    447436
    448437
     438        // Verify when psRegion has a coord at -1
    449439        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    450440        image2 = psImageTrim(image1, psRegionSet(0,0,-1,0));
     
    456446
    457447
     448        // Verify when psRegion has a coord at outside the image range
    458449        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    459450        image2 = psImageTrim(image1, psRegionSet(0,image->numCols+1,0,0));
     
    465456
    466457
     458        // Verify when psRegion has a coord at outside the image range
    467459        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    468460        image2 = psImageTrim(image1, psRegionSet(0,0,0,image->numRows+1));
     
    474466
    475467
     468        // Verify when psRegion has a coord at outside the image range
    476469        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    477470        image2 = psImageTrim(image1, psRegionSet(0,0,0,(((psF32)image->numRows)*-1.0)));
     
    483476
    484477
     478        // Verify when psRegion has a coord at outside the image range
    485479        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    486480        image2 = psImageTrim(image1, psRegionSet(0,(((psF32)image->numCols)*-1.0),0,0));
  • trunk/psLib/test/math/Makefile.am

    r12094 r13123  
    4747        tap_psStatsTiming \
    4848        tap_psFunc01 \
    49         tap_psStats_Sample_01
     49        tap_psStats_Sample_01 \
     50        tap_psMatrixVectorArithmetic01 \
     51        tap_psMatrixVectorArithmetic04 \
     52        tap_psRandom \
     53        tap_psMinimizePowell
    5054
    5155if BUILD_TESTS
  • trunk/psLib/test/math/tap_psMatrix03.c

    r10816 r13123  
    1616 *  @author  Ross Harman, MHPCC
    1717 *
    18  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    19  *  @date  $Date: 2006-12-20 20:02:29 $
     18 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     19 *  @date  $Date: 2007-05-02 04:14:33 $
    2020 *
    2121 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    184184
    185185    // Attempt to use null image input argument
    186     // XXX: This test should generate an error or warning, but we don't know how to test that.
     186    // XXX: This test should generate an error or warning
     187    // XXX: This seg-faults
    187188    if (0) {
    188189        psMemId id = psMemGetId();
     
    195196
    196197    // Attempt to use null input vector argument
    197     // XXX: This test should generate an error or warning, but we don't know how to test that.
     198    // XXX: This test should generate an error or warning
     199    // XXX: This seg-faulta
    198200    if (0) {
    199201        psMemId id = psMemGetId();
     
    212214    // Attempt to use null LU image argument
    213215    // XXX: This test should generate an error or warning, but we don't know how to test that.
     216    // XXX: This seg-faulta
    214217    if (0) {
    215218        psMemId id = psMemGetId();
  • trunk/psLib/test/math/tap_psMatrixVectorArithmetic01.c

    r12431 r13123  
    1010 *  @author  Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    13  *  @date  $Date: 2007-03-14 00:39:51 $
     12 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     13 *  @date  $Date: 2007-05-02 04:14:33 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    128128    bool errorFlag = false;
    129129    bool memoryFlag = false;
    130     plan_tests(90);
     130    plan_tests(72);
    131131
    132132    //Test matrix-matrix binary operations
  • trunk/psLib/test/math/tap_psMatrixVectorArithmetic02.c

    r12431 r13123  
    1010 *  @author  Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    13  *  @date  $Date: 2007-03-14 00:39:51 $
     12 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     13 *  @date  $Date: 2007-05-02 04:14:33 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1818#include <stdio.h>
    1919#include <string.h>
     20#include <math.h>
    2021#include <pslib.h>
    2122#include "tap.h"
  • trunk/psLib/test/math/tap_psMatrixVectorArithmetic03.c

    r12431 r13123  
    1515 *  @author  Ross Harman, MHPCC
    1616 *
    17  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    18  *  @date  $Date: 2007-03-14 00:39:51 $
     17 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     18 *  @date  $Date: 2007-05-02 04:14:33 $
    1919 *
    2020 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6868    // Check for NULL input argument #1
    6969
    70     if (0) {
     70    if (1) {
    7171        psMemId id = psMemGetId();
    7272        psImage* image6 = (psImage*)psBinaryOp(image6, NULL, "+", image2);
     
    249249    psFree(image3);
    250250    psFree(image4);
    251     psFree(image5);
    252251    psFree(vector1);
    253252    psFree(vector2);
  • trunk/psLib/test/math/tap_psMinimizePowell.c

    r10945 r13123  
    7474{
    7575    psLogSetFormat("HLNM");
    76     plan_tests(2);
     76    plan_tests(1);
    7777
    7878    // Check for various errors on unallowed input parameters
     
    134134
    135135    // Powell minimize with parameter mask
    136     {
     136    if (0) {
    137137        psMemId id = psMemGetId();
    138138        psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
     
    186186    // Powell minimize with parameter mask
    187187    // The only difference from the previous block is that paramMask is now NULL
    188     {
     188    if (0) {
    189189        psMemId id = psMemGetId();
    190190        psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
  • trunk/psLib/test/math/tap_psRandom.c

    r13084 r13123  
    4747    plan_tests(34);
    4848
    49     diag("ensure that psRandom structs are properly allocated by psRandomAlloc()");
    5049    // ensure that psRandom structs are properly allocated by psRandomAlloc()
    5150    {
     
    8180    // testRandomUniform(void)
    8281    {
    83         diag("testRandomUniform()");
     82        // testRandomUniform()
    8483        psMemId id = psMemGetId();
    8584        psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
     
    9190
    9291        // Initialize vector data with random number
    93         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    94         {
     92        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    9593            rans->data.F64[i] = psRandomUniform(myRNG);
    9694        }
    9795
    9896        // Perform vector stats on random data (mean, stdev)
    99         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     97        psVectorStats(stats, rans, NULL, NULL, 0);
    10098        stats->options = PS_STAT_SAMPLE_STDEV;
    101         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     99        psVectorStats(stats, rans, NULL, NULL, 0);
    102100
    103101        // Verify mean and stdev
     
    132130
    133131        // Initialize vector with random data
    134         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    135         {
     132        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    136133            rans->data.F64[i] = psRandomGaussian(myRNG);
    137134        }
    138135
    139136        // Perform vector stats on data (mean, stdev)
    140         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     137        psVectorStats(stats, rans, NULL, NULL, 0);
    141138        stats->options = PS_STAT_SAMPLE_STDEV;
    142         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     139        psVectorStats(stats, rans, NULL, NULL, 0);
    143140
    144141        // Verify mean and stdev
     
    175172
    176173        // Initialize vector with random data
    177         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    178         {
     174        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    179175            rans->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    180176        }
    181177
    182178        // Perform vector stats on random data (mean, stdev)
    183         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     179        psVectorStats(stats, rans, NULL, NULL, 0);
    184180        stats->options = PS_STAT_SAMPLE_STDEV;
    185         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     181        psVectorStats(stats, rans, NULL, NULL, 0);
    186182        // Verify mean and stdev
    187183        is_float_tol_per(stats->sampleMean, POISSON_MEAN, ERROR_TOLERANCE, "Mean is within expected range");
     
    221217        // Random reset
    222218        psRandomReset(myRNG, SEED);
    223         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    224         {
     219        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    225220            rans00->data.F64[i] = psRandomUniform(myRNG);
    226221        }
    227222        psRandomReset(myRNG, SEED2);
    228         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    229         {
     223        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    230224            rans01->data.F64[i] = psRandomUniform(myRNG);
    231225        }
    232226        psRandomReset(myRNG, SEED);
    233         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    234         {
     227        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    235228            rans02->data.F64[i] = psRandomUniform(myRNG);
    236229        }
     
    273266    // testRandomResetGaussian(void)
    274267    {
    275         diag("testRandomGaussian(): ensure the seed resets properly");
     268        // testRandomGaussian(): ensure the seed resets properly
    276269        psMemId id = psMemGetId();
    277270        psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
     
    289282        // Initialize random data in vectors
    290283        psRandomReset(myRNG, SEED);
    291         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    292         {
     284        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    293285            rans00->data.F64[i] = psRandomGaussian(myRNG);
    294286        }
    295287        psRandomReset(myRNG, SEED2);
    296         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    297         {
     288        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    298289            rans01->data.F64[i] = psRandomGaussian(myRNG);
    299290        }
    300291        psRandomReset(myRNG, SEED);
    301         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    302         {
     292        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    303293            rans02->data.F64[i] = psRandomGaussian(myRNG);
    304294        }
     
    306296        // Verify data from original seed produces same data after reset
    307297        psBool errorFlag = false;
    308         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    309         {
     298        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    310299            if (rans00->data.F64[i] != rans02->data.F64[i]) {
    311300                if (VERBOSE) {
     
    315304            }
    316305        }
    317         ok(!errorFlag, "psRandomUniform() produced the same results with the same seed");
     306        ok(!errorFlag, "psRandomGaussian() produced the same results with the same seed");
    318307        skip_end();
    319308        psFree(myRNG);
     
    342331        // Initialize vectors with random data
    343332        psRandomReset(myRNG, SEED);
    344         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    345         {
     333        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    346334            rans00->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    347335        }
    348336        psRandomReset(myRNG, SEED2);
    349         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    350         {
     337        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    351338            rans01->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    352339        }
    353340        psRandomReset(myRNG, SEED);
    354         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    355         {
     341        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    356342            rans02->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    357343        }
     
    359345        // Verify the original seed produces same data after reset
    360346        psBool errorFlag = false;
    361         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    362         {
     347        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    363348            if (rans00->data.F64[i] != rans02->data.F64[i]) {
    364349                if (VERBOSE) {
     
    368353            }
    369354        }
    370         ok(!errorFlag, "psRandomUniform() produced the same results with the same seed");
     355        ok(!errorFlag, "psRandomPoisson() produced the same results with the same seed");
    371356        skip_end();
    372357        psFree(myRNG);
  • trunk/psLib/test/math/tap_psSparse.c

    r12607 r13123  
    1010    plan_tests(26);
    1111
    12 //    diag("psSparse() tests");
    13 
    1412    // test psSparseSolve for a simple normal example matrix
    1513    {
    1614        psMemId id = psMemGetId();
    1715
    18 //        diag ("solve a normalized matrix equation with psSparseSolve");
     16        //solve a normalized matrix equation with psSparseSolve
    1917
    2018        // the basic equation is Ax = b
     
    2826        skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
    2927
    30         for (int i = 0; i < 100; i++)
    31         {
     28        for (int i = 0; i < 100; i++) {
    3229            psSparseMatrixElement (matrix, i, i, 1.0);
    3330            if (i + 1 < 100) {
     
    3835        // incoming matrix elements do not need to be in order; sort before
    3936        // applying sparse matrix
    40         psSparseResort (matrix);
     37        psSparseResort(matrix);
    4138
    4239        psVector *xRef = psVectorAlloc (100, PS_TYPE_F32);
     
    4643        }
    4744
    48         psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef);
    49 
    50         for (int i = 0; i < 100; i++)
    51         {
    52             psSparseVectorElement (matrix, i, bVec->data.F32[i]);
     45        psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef);
     46
     47        for (int i = 0; i < 100; i++) {
     48            psSparseVectorElement(matrix, i, bVec->data.F32[i]);
    5349        }
    5450
     
    5955
    6056        // solve for normalization terms (need include local sky?)
    61         psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);
     57        psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4);
    6258
    6359        // measure stdev between xFit and xRes
     
    8985        psMemId id = psMemGetId();
    9086
    91 //        diag ("solve a non-normalized matrix equation with psSparseSolve");
    92 
     87        //solve a non-normalized matrix equation with psSparseSolve
    9388        // the basic equation is Ax = b
    94 
    9589        // create a matrix A with diagonals of 1 and a small number of off diagonal elements.
    9690        // construct a vector x, construct the corresponding vector b by multiplication. solve
     
    10195        skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
    10296
    103         for (int i = 0; i < 100; i++)
    104         {
     97        for (int i = 0; i < 100; i++) {
    10598            psSparseMatrixElement (matrix, i, i, 5.0);
    10699            if (i + 1 < 100) {
     
    111104        // incoming matrix elements do not need to be in order; sort before
    112105        // applying sparse matrix
    113         psSparseResort (matrix);
     106        psSparseResort(matrix);
    114107
    115108        psVector *xRef = psVectorAlloc (100, PS_TYPE_F32);
     
    119112        }
    120113
    121         psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef);
    122 
    123         for (int i = 0; i < 100; i++)
    124         {
    125             psSparseVectorElement (matrix, i, bVec->data.F32[i]);
     114        psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef);
     115
     116        for (int i = 0; i < 100; i++) {
     117            psSparseVectorElement(matrix, i, bVec->data.F32[i]);
    126118        }
    127119
     
    132124
    133125        // solve for normalization terms (need include local sky?)
    134         psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);
     126        psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4);
    135127
    136128        // measure stdev between xFit and xRes
     
    173165        psMemId id = psMemGetId();
    174166
    175 //        diag ("solve a simple, small matrix equation ");
     167        //solve a simple, small matrix equation
    176168
    177169        // the basic equation (Ax = b) is:
     
    192184        skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
    193185
    194         psSparseMatrixElement (matrix, 0, 0, 1.0);
    195         psSparseMatrixElement (matrix, 1, 1, 1.0);
    196         psSparseMatrixElement (matrix, 1, 0, 0.1);
    197         psSparseResort (matrix);
     186        psSparseMatrixElement(matrix, 0, 0, 1.0);
     187        psSparseMatrixElement(matrix, 1, 1, 1.0);
     188        psSparseMatrixElement(matrix, 1, 0, 0.1);
     189        psSparseResort(matrix);
    198190
    199191        // border region has a width of 1:
     
    244236
    245237        // supply the fVec and gVec data to the border
    246         for (int i = 0; i < Nrows; i++)
    247         {
    248             psSparseVectorElement (border->sparse, i, fVec->data.F32[i]);
    249         }
    250         for (int i = 0; i < Nborder; i++)
    251         {
    252             psSparseBorderElementG (border, i, gVec->data.F32[i]);
     238        for (int i = 0; i < Nrows; i++) {
     239            psSparseVectorElement(border->sparse, i, fVec->data.F32[i]);
     240        }
     241        for (int i = 0; i < Nborder; i++) {
     242            psSparseBorderElementG(border, i, gVec->data.F32[i]);
    253243        }
    254244
     
    262252        psVector *xFit = NULL;
    263253        psVector *yFit = NULL;
    264         psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);
     254        psSparseBorderSolve(&xFit, &yFit, constraint, border, 4);
    265255        is_float_tol (xFit->data.F32[0], 1.0, 1e-4, "f(0): %f", xFit->data.F32[0]);
    266256        is_float_tol (xFit->data.F32[1], 1.0, 1e-4, "f(1): %f", xFit->data.F32[1]);
     
    283273        psMemId id = psMemGetId();
    284274
    285 //        diag ("solve a simple, small matrix equation ");
     275        // solve a simple, small matrix equation
    286276
    287277        // the basic equation (Ax = b) is:
     
    302292        skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
    303293
    304         for (int i = 0; i < Nrows; i++)
    305         {
    306             psSparseMatrixElement (matrix, i, i, 1.0);
     294        for (int i = 0; i < Nrows; i++) {
     295            psSparseMatrixElement(matrix, i, i, 1.0);
    307296            if (i + 1 < Nrows) {
    308                 psSparseMatrixElement (matrix, i + 1, i, 0.1);
    309             }
    310         }
    311         psSparseResort (matrix);
     297                psSparseMatrixElement(matrix, i + 1, i, 0.1);
     298            }
     299        }
     300        psSparseResort(matrix);
    312301
    313302        // border region has a width of 1:
     
    349338
    350339        // supply the fVec and gVec data to the border
    351         for (int i = 0; i < Nrows; i++)
    352         {
    353             psSparseVectorElement (border->sparse, i, fVec->data.F32[i]);
    354         }
    355         for (int i = 0; i < Nborder; i++)
    356         {
    357             psSparseBorderElementG (border, i, gVec->data.F32[i]);
     340        for (int i = 0; i < Nrows; i++) {
     341            psSparseVectorElement(border->sparse, i, fVec->data.F32[i]);
     342        }
     343        for (int i = 0; i < Nborder; i++) {
     344            psSparseBorderElementG(border, i, gVec->data.F32[i]);
    358345        }
    359346
     
    367354        psVector *xFit = NULL;
    368355        psVector *yFit = NULL;
    369         psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);
     356        psSparseBorderSolve(&xFit, &yFit, constraint, border, 4);
    370357
    371358        // measure stdev between xFit and xRef
  • trunk/psLib/test/mathtypes/tap_psVector.c

    r13084 r13123  
    88int main (void)
    99{
     10    psLogSetFormat("HLNM");
     11    psLogSetLevel(PS_LOG_INFO);
    1012    plan_tests(285);
    1113
     
    626628        vec->data.U8[4] = 0;
    627629        long numPix = psVectorCountPixelMask(vec, 1);
    628         ok(numPix != -1, "returned -1 for correct Vector input");
     630        ok(numPix != -1, "did not return -1 for correct Vector input");
    629631        ok(numPix == 2, "returned pixel count %d", numPix);
    630632        psFree(vec);
  • trunk/psLib/test/types/tap_psPixels_all.c

    r12781 r13123  
    2323    plan_tests(36);
    2424
    25     note("Tests for psPixels Functions");
    26 
     25    //Tests for psPixels Functions
    2726    testPixelsCreate();
    2827    testPixelsManip();
     
    3332void testPixelsCreate(void)
    3433{
    35     note("  >>>Test 1:  psPixels Creation Fxns");
    36 
     34    //Test 1:  psPixels Creation Fxns
    3735    //Return allocated psPixels of length 0 with NULL data.
    3836    psPixels* p0 = psPixelsAlloc(0);
     
    4947    //Make sure psMemCheckPixels works correctly - return true
    5048    {
    51         ok( psMemCheckPixels(p1),
     49        ok(psMemCheckPixels(p1),
    5250            "psMemCheckPixels:      return true for psPixels input.");
    5351    }
     
    5553    {
    5654        int j = 2;
    57         ok( !psMemCheckPixels(&j),
     55        ok(!psMemCheckPixels(&j),
    5856            "psMemCheckPixels:      return false for non-psPixels input.");
    5957    }
     
    6260        psPixels *noPix = psPixelsAlloc(1);
    6361        noPix = psPixelsRealloc(noPix, 0);
    64         ok( noPix->n == 0 && noPix->nalloc == 0,
     62        ok(noPix->n == 0 && noPix->nalloc == 0,
    6563            "psPixelsRealloc:       return re-allocated psPixels of 0 length.");
    6664        psFree(noPix);
     
    7573                     "Skipping 1 tests because psPixels input is of wrong size! =%ld", p0->n);
    7674        p0 = psPixelsRealloc(p0, 2);
    77         ok( p0->n == 2 && fabs(p0->data[0].x - 1.1) < FLT_EPSILON && p0->nalloc == 2,
     75        ok(p0->n == 2 && fabs(p0->data[0].x - 1.1) < FLT_EPSILON && p0->nalloc == 2,
    7876            "psPixelsRealloc:       return properly down-sized psPixels.");
    7977        skip_end();
     
    8381        psPixels *noPix = NULL;
    8482        noPix = psPixelsCopy(noPix, p0);
    85         ok( noPix->n == 2 && fabs(noPix->data[0].x - 1.1) < FLT_EPSILON && noPix->nalloc == 2,
     83        ok(noPix->n == 2 && fabs(noPix->data[0].x - 1.1) < FLT_EPSILON && noPix->nalloc == 2,
    8684            "psPixelsCopy:          return properly copied psPixels.");
    8785        psFree(noPix);
     
    9189        psPixels *noPix = NULL;
    9290        noPix = psPixelsCopy(noPix, NULL);
    93         ok( noPix == NULL,
     91        ok(noPix == NULL,
    9492            "psPixelsCopy:          return NULL for NULL psPixels input.");
    9593    }
     
    105103void testPixelsManip(void)
    106104{
    107     note("  >>>Test 2:  psPixels Manipulation Fxns");
    108 
     105    //psPixels Manipulation Fxns
    109106    //Tests for psPixelsSet
    110107    psPixels *p0 = psPixelsAlloc(1);
     
    114111    //Return false for NULL pixels input
    115112    {
    116         ok( !psPixelsSet(NULL, 0, in),
     113        ok(!psPixelsSet(NULL, 0, in),
    117114            "psPixelsSet:          return false for NULL pixels input.");
    118115    }
    119116    //Return true for valid inputs
    120117    {
    121         ok( psPixelsSet(p0, 0, in),
     118        ok(psPixelsSet(p0, 0, in),
    122119            "psPixelsSet:          return true for valid inputs.");
    123120    }
    124121    //Return false for position == nalloc
    125122    {
    126         ok( !psPixelsSet(p0, 1, in),
     123        ok(!psPixelsSet(p0, 1, in),
    127124            "psPixelsSet:          return false for position == nalloc.");
    128125    }
    129126    //Return false for out-of-range position
    130127    {
    131         ok( !psPixelsSet(p0, 2, in),
     128        ok(!psPixelsSet(p0, 2, in),
    132129            "psPixelsSet:          return false for out-of-range position.");
    133130    }
    134131    //Return false for negative out-of-range position
    135132    {
    136         ok( !psPixelsSet(p0, -2, in),
     133        ok(!psPixelsSet(p0, -2, in),
    137134            "psPixelsSet:          return false for negative out-of-range position.");
    138135    }
    139136    //Return true for valid negative position
    140137    {
    141         ok( psPixelsSet(p0, -1, in),
     138        ok(psPixelsSet(p0, -1, in),
    142139            "psPixelsSet:          return true for valid negative position.");
    143140    }
     
    148145    {
    149146        out = psPixelsGet(NULL, 1);
    150         ok( isnan(out.x) &&  isnan(out.y),
     147        ok(isnan(out.x) &&  isnan(out.y),
    151148            "psPixelsGet:          return NANs for NULL pixels input.");
    152149    }
     
    154151    {
    155152        out = psPixelsGet(p0, 2);
    156         ok( isnan(out.x) &&  isnan(out.y),
     153        ok(isnan(out.x) &&  isnan(out.y),
    157154            "psPixelsGet:          return NANs for out-of-range position.");
    158155    }
     
    160157    {
    161158        out = psPixelsGet(p0, -2);
    162         ok( isnan(out.x) &&  isnan(out.y),
     159        ok(isnan(out.x) &&  isnan(out.y),
    163160            "psPixelsGet:          return NANs for out-of-range negative position.");
    164161    }
     
    166163    {
    167164        out = psPixelsGet(p0, 0);
    168         ok( fabs(out.x - 1.1) < FLT_EPSILON &&  fabs(out.y - 1.2) < FLT_EPSILON,
     165        ok(fabs(out.x - 1.1) < FLT_EPSILON &&  fabs(out.y - 1.2) < FLT_EPSILON,
    169166            "psPixelsGet:          return correct values for valid inputs.");
    170167    }
     
    172169    {
    173170        out = psPixelsGet(p0, -1);
    174         ok( fabs(out.x - 1.1) < FLT_EPSILON &&  fabs(out.y - 1.2) < FLT_EPSILON,
     171        ok(fabs(out.x - 1.1) < FLT_EPSILON &&  fabs(out.y - 1.2) < FLT_EPSILON,
    175172            "psPixelsGet:          return correct values for valid negative position.");
    176173    }
     
    180177    {
    181178        FILE *newFD = fopen("psPixels.out", "w+");
    182         ok ( p_psPixelsPrint(newFD, p0, "PS-PIXELS"),
     179        ok(p_psPixelsPrint(newFD, p0, "PS-PIXELS"),
    183180             "p_psPixelsPrint:      return true for valid input.");
    184181        fflush(NULL);
     
    188185    {
    189186        FILE *dummy = fopen("psPixels.out", "r");
    190         ok ( !p_psPixelsPrint(dummy, p0, "failed test"),
     187        ok(!p_psPixelsPrint(dummy, p0, "failed test"),
    191188             "p_psPixelsPrint:      return false for invalid file input.");
    192189        fclose(dummy);
     
    196193    //Return false for NULL pixels and name inputs
    197194    {
    198         ok ( !p_psPixelsPrint(stdout, NULL, NULL),
     195        ok(!p_psPixelsPrint(stdout, NULL, NULL),
    199196             "p_psPixelsPrint:      return false for NULL pixels and name inputs.");
    200197    }
     
    202199    psPixels *p1 = psPixelsAlloc(0);
    203200    {
    204         ok ( p_psPixelsPrint(NULL, p1, "noPix"),
     201        ok(p_psPixelsPrint(NULL, p1, "noPix"),
    205202             "p_psPixelsPrint:      return true for NULL file and empty pixel data inputs.");
    206203    }
    207204
     205
     206    //----------------------------------------------------------------------
    208207    //psPixelsToMask Tests
    209208    psImage *outImage = NULL;
     
    214213    region.y1 = 5.0;
    215214    psMaskType maskVal = 1;
    216 
    217215    //Return NULL for NULL pixels input
    218216    {
     217        psMemId id = psMemGetId();
    219218        outImage = psPixelsToMask(outImage, NULL, region, maskVal);
    220         ok ( outImage == NULL,
    221              "psPixelsToMask:       return NULL for NULL pixels input.");
    222     }
     219        ok(outImage == NULL, "psPixelsToMask: return NULL for NULL pixels input.");
     220        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     221    }
     222
     223
    223224    //Return NULL for empty pixel data
    224225    {
     226        psMemId id = psMemGetId();
    225227        outImage = psPixelsToMask(outImage, p1, region, maskVal);
    226         ok ( outImage == NULL,
    227              "psPixelsToMask:       return NULL for NULL pixels data input.");
    228     }
     228        ok(outImage == NULL, "psPixelsToMask: return NULL for NULL pixels data input.");
     229        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     230    }
     231
     232
    229233    //Return NULL for bad region input - negative value
    230234    {
     235        psMemId id = psMemGetId();
    231236        outImage = psPixelsToMask(outImage, p0, region, maskVal);
    232         ok ( outImage == NULL,
    233              "psPixelsToMask:       return NULL for negative value in region.");
    234     }
     237        ok(outImage == NULL, "psPixelsToMask: return NULL for negative value in region.");
     238        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     239    }
     240
     241
    235242    //Return NULL for bad region input - upper bound less than lower bound
    236243    region.x0 = 3.0;
    237244    region.x1 = 1.0;
    238245    {
     246        psMemId id = psMemGetId();
    239247        outImage = psPixelsToMask(outImage, p0, region, maskVal);
    240         ok ( outImage == NULL,
    241              "psPixelsToMask:       return NULL for bad region input.");
    242     }
     248        ok(outImage == NULL, "psPixelsToMask: return NULL for bad region input.");
     249        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     250    }
     251
     252
     253    //Return NULL for un-recyclable image - out->type.dimen != PS_DIMEN_IMAGE
    243254    region.x0 = 1.0;
    244255    region.x1 = 3.0;
    245     //Return NULL for un-recyclable image - out->type.dimen != PS_DIMEN_IMAGE
    246256    outImage = psImageAlloc(1, 1, PS_TYPE_S32);
    247257    *(psDimen*)&(outImage->type.dimen) = PS_DIMEN_OTHER;
    248258    {
     259        psMemId id = psMemGetId();
    249260        outImage = psPixelsToMask(outImage, p0, region, maskVal);
    250         ok ( outImage == NULL,
    251              "psPixelsToMask:       return NULL for bad image input.");
    252     }
     261        ok(outImage == NULL, "psPixelsToMask: return NULL for bad image input.");
     262        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     263    }
     264
     265
    253266    //Return valid image for valid inputs
     267    //XXX: Musr check pixel values
    254268    p0 = psPixelsAdd(p0, 1, 2.1, 2.2);
    255269    p0 = psPixelsAdd(p0, 1, 3.1, 3.2);
    256270    p0 = psPixelsAdd(p0, 1, 1.0, 1.0);
    257271    {
     272        psMemId id = psMemGetId();
    258273        outImage = psPixelsToMask(outImage, p0, region, maskVal);
    259         ok ( outImage != NULL,
    260              "psPixelsToMask:       return valid image for valid input.");
    261     }
    262 
     274        ok(outImage != NULL, "psPixelsToMask: return valid image for valid input.");
     275        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     276    }
     277    psFree(outImage);
     278
     279
     280    //----------------------------------------------------------------------
    263281    //psPixelsFromMask Tests
    264     //Return valid psPixels for valid inputs
    265     psFree(outImage);
    266282    outImage = psImageAlloc(31, 99, PS_TYPE_MASK);
    267283    for (int i = 0; i < outImage->numCols; i++) {
     
    270286        }
    271287    }
    272 
    273     {
     288    //Return valid psPixels for valid inputs
     289    //XXX: We never check output psPixels
     290    {
     291        psMemId id = psMemGetId();
    274292        psPixels *outPixels = NULL;
    275293        outPixels = psPixelsFromMask(outPixels, outImage, maskVal);
    276         ok ( outPixels != NULL,
    277              "psPixelsFromMask:     return valid pixels for valid input.");
     294        ok(outPixels != NULL, "psPixelsFromMask: return valid pixels for valid input.");
    278295        psFree(outPixels);
    279     }
     296        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     297    }
     298
    280299
    281300    // Return NULL for NULL image input
    282301    {
     302        psMemId id = psMemGetId();
    283303        psPixels *outPixels = NULL;
    284304        outPixels = psPixelsFromMask(outPixels, NULL, maskVal);
    285         ok ( outPixels == NULL,
    286              "psPixelsFromMask:     return NULL for NULL image input.");
    287     }
     305        ok(outPixels == NULL, "psPixelsFromMask: return NULL for NULL image input.");
     306        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     307    }
     308
    288309
    289310    // Return NULL for image with wrong maskType
    290     *(psElemType*)&(outImage->type.type) = PS_TYPE_U32;
    291     {
     311    {
     312        *(psElemType*)&(outImage->type.type) = PS_TYPE_U32;
     313        psMemId id = psMemGetId();
    292314        psPixels *outPixels = NULL;
    293315        outPixels = psPixelsFromMask(outPixels, outImage, maskVal);
    294         ok ( outPixels == NULL,
    295              "psPixelsFromMask:     return NULL for image with wrong maskType.");
    296     }
    297 
     316        ok(outPixels == NULL, "psPixelsFromMask: return NULL for image with wrong maskType.");
     317        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     318        *(psElemType*)&(outImage->type.type) = PS_TYPE_U8;
     319    }
     320
     321
     322
     323    //----------------------------------------------------------------------
    298324    // psPixelsConcatenate Tests
    299325    // Return NULL for NULL pixels input
    300326    {
     327        psMemId id = psMemGetId();
    301328        psPixels *outPixels = NULL;
    302329        outPixels = psPixelsConcatenate(outPixels, NULL);
    303         ok ( outPixels == NULL,
    304              "psPixelsConcatenate:  return NULL for NULL pixels input.");
     330        ok(outPixels == NULL, "psPixelsConcatenate: return NULL for NULL pixels input.");
     331        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    305332    }
    306333
     
    308335    //Return copy of input pixels for NULL out pixels
    309336    {
     337        psMemId id = psMemGetId();
    310338        psPixels *outPixels = NULL;
    311339        outPixels = psPixelsFromMask(outPixels, outImage, maskVal);
    312340        outPixels = psPixelsConcatenate(outPixels, p0);
    313         ok ( outPixels->n == 4 && fabs(outPixels->data[0].x - 1.1) < FLT_EPSILON &&
     341        ok(outPixels->n == 4 && fabs(outPixels->data[0].x - 1.1) < FLT_EPSILON &&
    314342             fabs(outPixels->data[0].y - 1.2) < FLT_EPSILON ,
    315343             "psPixelsConcatenate:  return copy of input pixels for NULL out input.");
    316344        psFree(outPixels);
    317     }
    318 
     345        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     346    }
     347
     348
     349    //test psPixelsConcatenate()
    319350    //Return properly concatenated psPixels list
    320     //Set all the compare cases to cover 'comparePixelCoord' as well.
    321     psPixels *outPixels = psPixelsAlloc(5);
    322     in.x = 1.0;
    323     in.y = 1.0;
    324     psPixelsSet(outPixels, 0, in);  //1, 1
    325     psPixelsSet(outPixels, 1, in);  //1, 1
    326     in.y = 2.0;
    327     psPixelsSet(outPixels, 2, in);  //1, 2
    328     in.y = 1.0;
    329     psPixelsSet(outPixels, 3, in);  //1, 1
    330     in.x = 2.0;
    331     psPixelsSet(outPixels, 4, in);  //2, 1
    332 
    333     psPixels *testPixels = psPixelsAlloc(6);
    334     in.x = 1.0;
    335     in.y = 1.0;
    336     psPixelsSet(testPixels, 0, in);  //1, 1
    337     in.y = 2.0;
    338     psPixelsSet(testPixels, 1, in);  //1, 2
    339     in.y = 1.0;
    340     psPixelsSet(testPixels, 2, in);  //1, 1
    341     in.x = 2.0;
    342     psPixelsSet(testPixels, 3, in);  //2, 1
    343     in.x = 1.0;
    344     psPixelsSet(testPixels, 4, in);  //1, 1
    345     in.x = 5.0;
    346     in.y = 3.0;
    347     psPixelsSet(testPixels, 5, in);  //5, 3
    348     //Return properly concatenate pixel list
    349     {
     351    {
     352        psMemId id = psMemGetId();
     353        psPixels *outPixels = psPixelsAlloc(5);
     354        in.x = 1.0;
     355        in.y = 1.0;
     356        psPixelsSet(outPixels, 0, in);  //1, 1
     357        psPixelsSet(outPixels, 1, in);  //1, 1
     358        in.y = 2.0;
     359        psPixelsSet(outPixels, 2, in);  //1, 2
     360        in.y = 1.0;
     361        psPixelsSet(outPixels, 3, in);  //1, 1
     362        in.x = 2.0;
     363        psPixelsSet(outPixels, 4, in);  //2, 1
     364        psPixels *testPixels = psPixelsAlloc(6);
     365        in.x = 1.0;
     366        in.y = 1.0;
     367        psPixelsSet(testPixels, 0, in);  //1, 1
     368        in.y = 2.0;
     369        psPixelsSet(testPixels, 1, in);  //1, 2
     370        in.y = 1.0;
     371        psPixelsSet(testPixels, 2, in);  //1, 1
     372        in.x = 2.0;
     373        psPixelsSet(testPixels, 3, in);  //2, 1
     374        in.x = 1.0;
     375        psPixelsSet(testPixels, 4, in);  //1, 1
     376        in.x = 5.0;
     377        in.y = 3.0;
     378        psPixelsSet(testPixels, 5, in);  //5, 3
    350379        outPixels = psPixelsConcatenate(outPixels, testPixels);
    351         ok ( outPixels->n == 6,
    352              "psPixelsConcatenate:  return properly concatenate pixel list for valid inputs.");
    353     }
    354 
    355 
    356     //Check for Memory leaks
    357     {
     380        ok(outPixels->n == 6, "psPixelsConcatenate:  return properly concatenate pixel list for valid inputs.");
    358381        psFree(testPixels);
    359382        psFree(outPixels);
     383        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     384    }
     385
     386
     387    //Check for Memory leaks
     388    //XXX: Remove this, add memory checks to individual blocks
     389    {
    360390        psFree(outImage);
    361391        psFree(p1);
Note: See TracChangeset for help on using the changeset viewer.