IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13305


Ignore:
Timestamp:
May 7, 2007, 8:21:16 PM (19 years ago)
Author:
gusciora
Message:

Basically, added additional tests to increase overall coverage of these
psLib functions.

Location:
trunk/psLib/test
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/TABLE-SDRS-CH06-DataManip

    r13126 r13305  
    55-------------------------------------------------------------------------------
    66psVectorSort()
    7                         10              10      2       10
    8     We only test with NULL, size 1, and size 7 vectors.
    9     Add a test with NULL input, non-NULL output.
     7                        10              10      10      10
     8    in mathtypes/tap_psVectorSort.c
     9    Many more types are tested successfully than required in the SDRS.
    1010psVectorSortIndex()
    11                         10              10      2       10
    12     We only test with NULL, size 1, and size 7 vectors.
    13     Add a test with NULL input, non-NULL output.
     11                        10              10      10      10
     12    in mathtypes/tap_psVectorSortIndex.c
     13    Many more typres are tested successfully than required in the SDRS.
    1414psVectorStats()         5               10      5       5
     15    files: math/tap_psStats00.c - math/tap_psStats09.c
    1516    Must review these files more.
    1617    More extensie robust stats?
     18    Preset answers
     19    Unclear what types should be supported from SDRS:
     20        psS8, psU16, psF32, psF64
    1721psStatsAlloc()
    1822                        na              na      na      10
     
    3842                        8               na      10      8
    3943psPolynomial1DAlloc()
    40                         8               na      na      5
    41     Can we test with negative polynomial order?
    42     How about verifying the data is allocated, and initialized?
     44                        10              10      10      10      na
     45    math/tap_psPolynomial.c
    4346psPolynomial2DAlloc()
    44                         8               na      na      5
    45     Can we test with negative polynomial order?
     47                        10              10      10      10      na
     48    math/tap_psPolynomial.c
    4649psPolynomial3DAlloc()
    47                         8               na      na      5
    48     Can we test with negative polynomial order?
     50                        10              10      10      10      na
     51    math/tap_psPolynomial.c
    4952psPolynomial4DAlloc()
    50                         8               na      na      5
    51     Can we test with negative polynomial order?
     53                        10              10      10      10      na
     54    math/tap_psPolynomial.c
    5255psPolynomial1DEval()
    5356                        10              10      1       8
    5457    We only allocate polynomials with 4 terms
    55     We should ensure that asking for negatiev number of terms fails nicely.
     58    We should ensure that asking for negative number of terms fails nicely.
     59    The test uses precomputed results.
    5660psPolynomial2DEval()
    5761                        10              10      1       5
    5862    We only allocate polynomials with 4 terms
    5963        Must vary x,y number of terms.
     64    The test uses precomputed results.
    6065psPolynomial3DEval()
    6166                        10              10      1       5
    6267    We only allocate polynomials with 4 terms
    6368        Must vary x,y,z number of terms.
     69    The test uses precomputed results.
    6470psPolynomial4DEval()
    6571                        10              10      1       5
    6672    We only allocate polynomials with 4 terms
    6773        Must vary w,x,y,z number of terms.
     74    The test uses precomputed results.
    6875psPolynomial1DEvalVector()
    6976                        10              10      5       9
  • trunk/psLib/test/math/tap_psPolynomial.c

    r13084 r13305  
    1616*    XXX: Compare to FLT_EPSILON
    1717*
    18 *    @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    19 *    @date $Date: 2007-05-01 00:08:52 $
     18*    @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     19*    @date $Date: 2007-05-08 06:21:16 $
    2020*
    2121*  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    3535    psLogSetFormat("HLNM");
    3636    psLogSetLevel(PS_LOG_INFO);
    37 
    38     plan_tests(26);
     37    plan_tests(51);
    3938
    4039    // This test will allocate a 1D polynomial and verify the structure allocated
     
    7574
    7675
    77     if (0) {
    78         // Attempt to allocate with negative order
    79         // Following should generate error msg for negative terms
    80         if (psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, -1) != NULL) {
    81             diag("psPolynomial1DAlloc() Returned structure but expected NULL");
    82         }
    83     }
     76    // This test will allocate a Chebyshev 1D polynomial and verify the structure allocated
     77    {
     78        psMemId id = psMemGetId();
     79        psPolynomial1D* my1DPoly  = NULL;
     80        my1DPoly = psPolynomial1DAlloc(PS_POLYNOMIAL_CHEB, ORDER);
     81        ok(my1DPoly != NULL, "Chebyshev 1D polynomial allocated successfully");
     82        skip_start(my1DPoly == NULL, 1, "Skipping tests because psPolynomial1DAlloc() failed");
     83        ok(my1DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial1DAlloc(): Chebyshev  type set correctly");
     84        skip_end();
     85        psFree(my1DPoly);
     86        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     87    }
     88
     89
     90    // Attempt to allocate with negative order
     91    // Following should generate error msg for negative terms
     92    if (1) {
     93        psMemId id = psMemGetId();
     94        ok(psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, -1) == NULL,
     95          "psPolynomial1DAlloc() returned NULL with negative polynomial order");
     96        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     97    }
     98
    8499
    85100    // This test will allocate a 2D polynomial and verify the structure allocated
     
    122137    }
    123138
    124     if (0) {
    125         // Attempt to allocate with negative order
    126         // Following should generate error msg for negative terms
    127         if (psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, -1, 1) != NULL) {
    128             diag("psPolynomial2DAlloc() returned structure but expected NULL");
    129         }
    130         // Attempt to allocate with negative order
    131         // Following should generate error msg for negative terms
    132         if (psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, -1) != NULL) {
    133             diag("psPolynomial2DAlloc() returned structure but expected NULL");
    134         }
    135     }
     139
     140    // This test will allocate a Chebyshev 2D polynomial and verify the structure allocated
     141    {
     142        psMemId id = psMemGetId();
     143        psPolynomial2D* my2DPoly = NULL;
     144        my2DPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, ORDER,ORDER+1);
     145        ok(my2DPoly != NULL, "Chebyshev 2D polynomial allocated successfully");
     146        skip_start(my2DPoly == NULL, 1, "Skipping tests because psPolynomial2DAlloc() failed");
     147        skip_end();
     148        psFree(my2DPoly);
     149        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     150    }
     151
     152
     153    // Attempt to allocate with negative order
     154    // Following should generate error msg for negative terms
     155    if (1) {
     156        psMemId id = psMemGetId();
     157        ok(psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, -1, 1) == NULL,
     158          "psPolynomial2DAlloc() returned NULL with negative polynomial order");
     159        ok(psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, -1) == NULL,
     160          "psPolynomial2DAlloc() returned NULL with negative polynomial order");
     161        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     162    }
     163
    136164
    137165    // This test will allocate a 3D polynomial and verify the structure allocated
     
    179207        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    180208    }
    181     if (0) {
    182         // Attempt to allocate with negative order
    183         // Following should generate error msg for negative terms
    184         if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1) != NULL) {
    185             diag("psPolynomial3DAlloc(): returned structure but expected NULL");
    186         }
    187         // Attempt to allocate with negative order
    188         // Following should generate error msg for negative terms
    189         if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1) != NULL) {
    190             diag("psPolynomial3DAlloc() returned structure but expected NULL");
    191         }
    192         // Attempt to allocate with negative order
    193         // Following should generate error msg for negative terms
    194         if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1) != NULL) {
    195             diag("psPolynomial3DAlloc(): returned structure but expected NULL");
    196         }
    197     }
     209
     210
     211    // This test will allocate a Chebyshev 3D polynomial and verify the structure allocated
     212    {
     213        psMemId id = psMemGetId();
     214        psPolynomial3D* my3DPoly = NULL;
     215        my3DPoly = psPolynomial3DAlloc(PS_POLYNOMIAL_CHEB, ORDER, ORDER+1, ORDER+2);
     216        ok(my3DPoly != NULL, "Chebyshev 3D polynomial allocated successfully");
     217        skip_start(my3DPoly == NULL, 1, "Skipping tests because psPolynomial2DAlloc() failed");
     218        ok(my3DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial3DAlloc(): Chebyshev type set correctly");
     219        skip_end();
     220        psFree(my3DPoly);
     221        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     222    }
     223
     224
     225    // Attempt to allocate with negative order
     226    // Following should generate error msg for negative terms
     227    if (1) {
     228        psMemId id = psMemGetId();
     229        ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1) == NULL,
     230          "psPolynomial3DAlloc() returned NULL with negative polynomial order");
     231        ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1) == NULL,
     232          "psPolynomial3DAlloc() returned NULL with negative polynomial order");
     233        ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1) == NULL,
     234          "psPolynomial3DAlloc() returned NULL with negative polynomial order");
     235        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     236    }
     237
    198238
    199239    // This test will allocate a 4D polynomial and verify the structure allocated
     
    245285    }
    246286
    247     if (0) {
    248         // Attempt to allocate with negative order
    249         // Following should generate error msg for negative terms
    250         if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1, 1) != NULL) {
    251             diag("psPolynomial4DAlloc(): returned structure but expected NULL");
    252         }
    253         // Attempt to allocate with negative order
    254         // Following should generate error msg for negative terms
    255         if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1, 1) != NULL) {
    256             diag("psPolynomial4DAlloc(): returned structure but expected NULL");
    257             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    258         }
    259         // Attempt to allocate with negative order
    260         // Following should generate error msg for negative terms
    261         if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1, 1) != NULL) {
    262             diag("psPolynomial4DAlloc(): returned structure but expected NULL");
    263             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    264         }
    265         // Attempt to allocate with negative order
    266         // Following should generate error msg for negative terms
    267         if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, 1, -1) != NULL) {
    268             diag("psPolynomial4DAlloc(): returned structure but expected NULL");
    269         }
    270     }
     287
     288    // This test will allocate a Chebyshev 4D polynomial and verify the structure allocated
     289    {
     290        psMemId id = psMemGetId();
     291        psPolynomial4D* my4DPoly = NULL;
     292        my4DPoly = psPolynomial4DAlloc(PS_POLYNOMIAL_CHEB, ORDER,ORDER+1,ORDER+2,ORDER+3);
     293        ok(my4DPoly != NULL, "Chebyshev 4D polynomial allocated successfully");
     294        skip_start(my4DPoly == NULL, 1, "Skipping tests because psPolynomial4DAlloc() failed");
     295        ok(my4DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial4DAlloc(): Chebyshev type set correctly");
     296        skip_end();
     297        psFree(my4DPoly);
     298        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     299    }
     300
     301
     302    // Attempt to allocate with negative order
     303    // Following should generate error msg for negative terms
     304    if (1) {
     305        psMemId id = psMemGetId();
     306        ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1, 1) == NULL,
     307          "psPolynomial4DAlloc() returned NULL with negative polynomial order");
     308        ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1, 1) == NULL,
     309          "psPolynomial4DAlloc() returned NULL with negative polynomial order");
     310        ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1, 1) == NULL,
     311          "psPolynomial4DAlloc() returned NULL with negative polynomial order");
     312        ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, 1, -1) == NULL,
     313          "psPolynomial4DAlloc() returned NULL with negative polynomial order");
     314        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     315    }
     316
     317
    271318}
    272319
  • trunk/psLib/test/math/tap_psPolynomialEval1D.c

    r13124 r13305  
    44*  ORD and CHEB type polynomials.
    55*
    6 *  @version  $Revision: 1.7 $  $Name: not supported by cvs2svn $
    7 *  @date  $Date: 2007-05-02 04:20:06 $
     6*  @version  $Revision: 1.8 $  $Name: not supported by cvs2svn $
     7*  @date  $Date: 2007-05-08 06:21:16 $
    88*
    99*  XXX: Probably should test single- and multi-dimensional polynomials in
     
    7676
    7777        // Set polynomial members
    78         for(psS32 i = 0; i < TERMS; i++)
    79         {
     78        for(psS32 i = 0; i < TERMS; i++) {
    8079            polyOrd->coeff[i] = poly1DCoeff[i];
    8180            polyOrd->mask[i]  = poly1DMask[i];
     
    8483        // Evaluate test points and verify results
    8584        bool errorFlag = false;
    86         for(psS32 i = 0; i < TESTPOINTS; i++)
    87         {
     85        for(psS32 i = 0; i < TESTPOINTS; i++) {
    8886            psF64 result = psPolynomial1DEval(polyOrd,poly1DXValue[i]);
    8987            if (fabs(poly1DXResult[i]-result) > ERROR_TOL ) {
  • trunk/psLib/test/math/tap_psStats00.c

    r12781 r13305  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-04-10 21:09:30 $
     11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2007-05-08 06:21:16 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    8282    }
    8383
    84 
    85 
    86 
    87 
    88 
    89 
    90 
    91 
    92 
    93 
    94 
    95 
    96 
    97 
    98 
    99 
    100 
    101 
    102 
    103 
    104 
    105 
    106 
    107 
    108 
    109 
    110 
    111 
    112 
    113 
    114 
    115 
    11684    // Call psVectorStats() with no vector mask.
    11785    {
  • trunk/psLib/test/mathtypes/tap_psVectorSort.c

    r12918 r13305  
    1111 *  Sort vector with one element
    1212 *  Verify the sort for all supported types.
     13 *  Sort input vector into itself
    1314 *  Output vector is smaller than input vector
    1415 *  Output vector is different type from input vector
    15  *  Sort input float vector into itself
    16  *  Free float vectors
    1716 *
    1817 *  @author  Ross Harman, GLG, MHPCC
    1918 *
    20  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    21  *  @date  $Date: 2007-04-19 03:50:44 $
     19 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     20 *  @date  $Date: 2007-05-08 06:21:16 $
    2221 *
    2322 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    2423 *
    2524 */
    26 
    2725#include <pslib.h>
    2826#include "tap.h"
    2927#include "pstap.h"
    30 
     28#define VERBOSE 0
    3129
    3230#define tstVectorSortByType(datatype, boolOutNull, value) \
     
    3432    psMemId id = psMemGetId(); \
    3533    psVector *out = NULL; \
    36     psVector *in = psVectorAlloc(7,PS_TYPE_##datatype); \
     34    psVector *in = psVectorAlloc(7, PS_TYPE_##datatype); \
    3735    if (boolOutNull) { \
    3836        out = NULL; \
     
    7472    psLogSetFormat("HLNM");
    7573    psLogSetLevel(PS_LOG_INFO);
    76     plan_tests(244);
     74    plan_tests(246);
    7775
    7876
     
    9088    {
    9189        psMemId id = psMemGetId();
    92         psVector *in = psVectorAlloc(7, PS_TYPE_F32);
    93         in->type.type = PS_TYPE_BOOL;
     90        psVector *in = psVectorAlloc(7, PS_TYPE_BOOL);
    9491        psVector *out = psVectorSort(NULL, in);
    9592        ok(out == NULL, "Did return NULL on error");
    9693        psFree(in);
     94        psFree(out);
    9795        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    9896    }
     
    236234        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    237235    }
     236
     237
     238    // Sort large input vector
     239    {
     240        #define N 1000000
     241        psMemId id = psMemGetId();
     242        psVector *in = psVectorAlloc(N, PS_TYPE_S32);
     243        for (int i = 0 ; i < N ; i++) {
     244            in->data.S32[N-i-1] = i;
     245        }
     246        psVector *out = psVectorSort(NULL, in);
     247        skip_start(out == NULL,  7, "Skipping tests because psVectorSort() returned NULL.");
     248        bool errorFlag = false;
     249        for (int i = 0 ; i < N ; i++) {
     250            if (out->data.S32[i] != i) {
     251                if (VERBOSE) {
     252                    diag("Test error: out[%d] is %d, should be %d\n", i, out->data.S32[i], i);
     253                }
     254                errorFlag = true;
     255            }
     256        }
     257        ok(!errorFlag, "psVectorSort() correctly sorted a large input vector");
     258        skip_end();
     259        psFree(in);
     260        psFree(out);
     261        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     262    }
    238263}
  • trunk/psLib/test/mathtypes/tap_psVectorSortIndex.c

    r12918 r13305  
    1414 *  @author  Ross Harman, GLG, MHPCC
    1515 *
    16  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2007-04-19 03:50:44 $
     16 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2007-05-08 06:21:16 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "tap.h"
    2424#include "pstap.h"
     25#define VERBOSE 0
    2526
    2627#define tstVectorSortIndexByType(datatype, boolOutNull, value) \
     
    2829    psMemId id = psMemGetId(); \
    2930    psVector *out = NULL; \
    30     psVector *in = psVectorAlloc( 5, PS_TYPE_##datatype ); \
     31    psVector *in = psVectorAlloc(5, PS_TYPE_##datatype); \
    3132    in->data.datatype[0] = 7+value; \
    3233    in->data.datatype[1] = 9+value; \
     
    3738        out = NULL; \
    3839    } else { \
    39         out = psVectorAlloc(5,PS_TYPE_##datatype); \
     40        out = psVectorAlloc(5, PS_TYPE_##datatype); \
    4041    } \
    4142    psVector *tempVec = out; \
    42     out = psVectorSortIndex(out,in); \
     43    out = psVectorSortIndex(out, in); \
    4344    if (!boolOutNull) { \
    4445        ok(tempVec == out, "Return value equal to orignal output argument passed to function"); \
     
    7172        psVector *out = psVectorSortIndex(NULL, NULL);
    7273        ok(out == NULL, "psVectorSortIndex() return NULL with NULL input specified");
     74        psFree(out);
    7375        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    7476    }
     
    7880    {
    7981        psMemId id = psMemGetId();
    80         psVector *in = psVectorAlloc(5, PS_TYPE_U8);
    81         in->type.type = PS_TYPE_BOOL;
     82        psVector *in = psVectorAlloc(5, PS_TYPE_BOOL);
    8283        psVector *out = psVectorSortIndex(NULL, in);
    8384        ok(out == NULL, "psVectorSortIndex() returned NULL with unallowed input vector type");
    8485        psFree(in);
     86        psFree(out);
    8587        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    8688    }
     
    178180        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    179181    }
     182
     183
     184    // Sort large input vector
     185    {
     186        #define N 1000000
     187        psMemId id = psMemGetId();
     188        psVector *in = psVectorAlloc(N, PS_TYPE_S32);
     189        for (int i = 0 ; i < N ; i++) {
     190            in->data.S32[N-i-1] = i;
     191        }
     192        psVector *out = psVectorSortIndex(NULL, in);
     193        skip_start(out == NULL,  7, "Skipping tests because psVectorSort() returned NULL.");
     194        bool errorFlag = false;
     195        for (int i = 0 ; i < N ; i++) {
     196            if (out->data.U32[i] != N-i-1) {
     197                if (VERBOSE) {
     198                    diag("Test error: out[%d] is %d, should be %d\n", i, out->data.U32[i], i);
     199                }
     200                errorFlag = true;
     201            }
     202        }
     203        ok(!errorFlag, "psVectorSortIndex() correctly sorted a large input vector");
     204        skip_end();
     205        psFree(in);
     206        psFree(out);
     207        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     208    }
    180209}
Note: See TracChangeset for help on using the changeset viewer.