IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.