IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3382


Ignore:
Timestamp:
Mar 7, 2005, 11:00:03 AM (21 years ago)
Author:
evanalst
Message:

Updated allocation test cases.

Location:
trunk/psLib/test/dataManip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psFunc00.c

    r3377 r3382  
    1 /*****************************************************************************
    2     This routine must ensure that the psPolynomial structures are
    3     allocated and deallocated by the psPolynomialXXXlloc() procedures.
    4     It also calls the various psPolynomialXXXEval() procedures.
    5  
    6     The F32 and F64 polynomials are tested for all orders (1 - 4) and for
    7     both ordinary and chebyshev polynomials.
    8  
    9     NOTE: This test code requries the stdout file to verify that the results
    10     are good.
    11  *****************************************************************************/
     1/** tst_Func00.c
     2*
     3*    This routine must ensure that the psPolynomial structures are
     4*    allocated and deallocated by the psPolynomialXXXlloc() procedures.
     5*    It also calls the various psPolynomialXXXEval() procedures.
     6*
     7*    The F32 and F64 polynomials are tested for all orders (1 - 4) and for
     8*    both ordinary and chebyshev polynomials.
     9*
     10*    NOTE: This test code requries the stdout file to verify that the results
     11*    are good.
     12*
     13*    @version $Revision: 1.18 $  $Name: not supported by cvs2svn $
     14*    @date $Date: 2005-03-07 21:00:03 $
     15*
     16*  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
     17*   
     18*****************************************************************************/
    1219#include <stdio.h>
    1320#include "pslib.h"
     
    1522#include "psMemory.h"
    1623#include "psFunctions.h"
     24
     25// Defines
     26#define ORDER    3
     27
     28
    1729#define MISC_FLOAT_NUMBER 345.0
    1830#define MISC_X_VALUE 5.0
    1931#define MISC_X_CHEB_VALUE 0.5
    2032#define MISC_INT_NUMBER 35
    21 //#define AN 2
    22 #define AN 1
     33#define AN 2
    2334#define BN 4
    2435#define CN 6
    2536#define DN 8
    2637
     38static psS32 t01(void);
     39
     40static psS32 testPolynomial1DAlloc(void);
     41static psS32 testPolynomial2DAlloc(void);
     42static psS32 testPolynomial3DAlloc(void);
     43static psS32 testPolynomial4DAlloc(void);
     44static psS32 testDPolynomial1DAlloc(void);
     45static psS32 testDPolynomial2DAlloc(void);
     46static psS32 testDPolynomial3DAlloc(void);
     47static psS32 testDPolynomial4DAlloc(void);
     48
     49testDescription tests[] = {
     50                              {testPolynomial1DAlloc,578,"psPolynomial1DAlloc",0,false},
     51                              {testPolynomial2DAlloc,578,"psPolynomial2DAlloc",0,false},
     52                              {testPolynomial3DAlloc,578,"psPolynomial3DAlloc",0,false},
     53                              {testPolynomial4DAlloc,578,"psPolynomial4DAlloc",0,false},
     54                              {testDPolynomial1DAlloc,579,"psDPolynomial1DAlloc",0,false},
     55                              {testDPolynomial2DAlloc,579,"psDPolynomial2DAlloc",0,false},
     56                              {testDPolynomial3DAlloc,579,"psDPolynomial3DAlloc",0,false},
     57                              {testDPolynomial4DAlloc,579,"psDPolynomial4DAlloc",0,false},
     58                              {t01,0000,"psPolynomial1DAlloc",0,false},
     59                              {NULL}
     60                          };
     61
     62
     63psS32 main(psS32 argc, char* argv[])
     64{
     65    psLogSetLevel(PS_LOG_INFO);
     66
     67    return !runTestSuite(stderr,"psPolynomialXD", tests, argc, argv);
     68}
     69
     70
     71// This test will allocate a 1D polynomial and verify the structure allocated
     72psS32 testPolynomial1DAlloc(void)
     73{
     74    psPolynomial1D*  my1DPoly  = NULL;
     75
     76    // Allocate polynomial
     77    my1DPoly = psPolynomial1DAlloc(ORDER,PS_POLYNOMIAL_ORD);
     78    // Verify structure allocated
     79    if(my1DPoly == NULL) {
     80        psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
     81        return 1;
     82    }
     83    // Verify polynomial structure members set properly
     84    if(my1DPoly->n != ORDER) {
     85        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     86                my1DPoly->n, ORDER);
     87        return 2;
     88    }
     89    if(my1DPoly->type != PS_POLYNOMIAL_ORD) {
     90        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     91                my1DPoly->type, PS_POLYNOMIAL_ORD);
     92        return 3;
     93    }
     94    for(psS32 i = 0; i < ORDER; i++) {
     95        if(my1DPoly->coeff[i] != 0.0) {
     96            psError(PS_ERR_UNKNOWN,true,"Coeff[%d] %lg not as expected %lg",
     97                    i, my1DPoly->coeff[i], 0.0);
     98            return 4;
     99        }
     100        if(my1DPoly->coeffErr[i] != 0.0) {
     101            psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d] %lg not as expected %lg",
     102                    i, my1DPoly->coeffErr[i], 0.0);
     103            return 5;
     104        }
     105        if(my1DPoly->mask[i] != 0) {
     106            psError(PS_ERR_UNKNOWN,true,"Mask[%d] %d not as expected %d",
     107                    i, my1DPoly->mask[i], 0);
     108            return 6;
     109        }
     110    }
     111    psFree(my1DPoly);
     112
     113    // Attempt to allocate with negative order
     114    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     115    if(psPolynomial1DAlloc(-1,PS_POLYNOMIAL_ORD) != NULL) {
     116        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     117        return 7;
     118    }
     119
     120    return 0;
     121}
     122
     123// This test will allocate a 1D polynomial and verify the structure allocated
     124psS32 testDPolynomial1DAlloc(void)
     125{
     126    psDPolynomial1D*  my1DDPoly  = NULL;
     127
     128    // Allocate polynomial
     129    my1DDPoly = psDPolynomial1DAlloc(ORDER,PS_POLYNOMIAL_CHEB);
     130    // Verify structure allocated
     131    if(my1DDPoly == NULL) {
     132        psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
     133        return 1;
     134    }
     135    // Verify polynomial structure members set properly
     136    if(my1DDPoly->n != ORDER) {
     137        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     138                my1DDPoly->n, ORDER);
     139        return 2;
     140    }
     141    if(my1DDPoly->type != PS_POLYNOMIAL_CHEB) {
     142        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     143                my1DDPoly->type, PS_POLYNOMIAL_CHEB);
     144        return 3;
     145    }
     146    for(psS32 i = 0; i < ORDER; i++) {
     147        if(my1DDPoly->coeff[i] != 0.0) {
     148            psError(PS_ERR_UNKNOWN,true,"Coeff[%d] %lg not as expected %lg",
     149                    i, my1DDPoly->coeff[i], 0.0);
     150            return 4;
     151        }
     152        if(my1DDPoly->coeffErr[i] != 0.0) {
     153            psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d] %lg not as expected %lg",
     154                    i, my1DDPoly->coeffErr[i], 0.0);
     155            return 5;
     156        }
     157        if(my1DDPoly->mask[i] != 0) {
     158            psError(PS_ERR_UNKNOWN,true,"Mask[%d] %d not as expected %d",
     159                    i, my1DDPoly->mask[i], 0);
     160            return 6;
     161        }
     162    }
     163    psFree(my1DDPoly);
     164
     165    // Attempt to allocate with negative order
     166    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     167    if(psDPolynomial1DAlloc(-1,PS_POLYNOMIAL_ORD) != NULL) {
     168        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     169        return 7;
     170    }
     171
     172    return 0;
     173}
     174
     175// This test will allocate a 2D polynomial and verify the structure allocated
     176psS32 testPolynomial2DAlloc(void)
     177{
     178    psPolynomial2D* my2DPoly = NULL;
     179
     180    // Allocate polynomial
     181    my2DPoly = psPolynomial2DAlloc(ORDER,ORDER+1,PS_POLYNOMIAL_ORD);
     182    // Verify structure allocated
     183    if(my2DPoly == NULL) {
     184        psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
     185        return 1;
     186    }
     187    // Verify polynomial structure members set properly
     188    if(my2DPoly->nX != ORDER) {
     189        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     190                my2DPoly->nX, ORDER);
     191        return 2;
     192    }
     193    // Verify polynomial structure members set properly
     194    if(my2DPoly->nY != ORDER+1) {
     195        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     196                my2DPoly->nY, ORDER+1);
     197        return 3;
     198    }
     199    if(my2DPoly->type != PS_POLYNOMIAL_ORD) {
     200        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     201                my2DPoly->type, PS_POLYNOMIAL_ORD);
     202        return 4;
     203    }
     204    for(psS32 i = 0; i < ORDER; i++) {
     205        for(psS32 j = 0; j < ORDER+1; j++) {
     206            if(my2DPoly->coeff[i][j] != 0.0) {
     207                psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d] %lg not as expected %lg",
     208                        i, j, my2DPoly->coeff[i][j], 0.0);
     209                return 5;
     210            }
     211            if(my2DPoly->coeffErr[i][j] != 0.0) {
     212                psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d] %lg not as expected %lg",
     213                        i, j, my2DPoly->coeffErr[i][j], 0.0);
     214                return 6;
     215            }
     216            if(my2DPoly->mask[i][j] != 0) {
     217                psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d",
     218                        i, j, my2DPoly->mask[i][j], 0);
     219                return 7;
     220            }
     221        }
     222    }
     223    psFree(my2DPoly);
     224
     225    // Attempt to allocate with negative order
     226    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     227    if(psPolynomial2DAlloc(-1,1,PS_POLYNOMIAL_ORD) != NULL) {
     228        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     229        return 8;
     230    }
     231    // Attempt to allocate with negative order
     232    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     233    if(psPolynomial2DAlloc(1,-1,PS_POLYNOMIAL_ORD) != NULL) {
     234        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     235        return 9;
     236    }
     237
     238    return 0;
     239}
     240
     241// This test will allocate a 2D polynomial and verify the structure allocated
     242psS32 testDPolynomial2DAlloc(void)
     243{
     244    psDPolynomial2D* my2DDPoly = NULL;
     245
     246    // Allocate polynomial
     247    my2DDPoly = psDPolynomial2DAlloc(ORDER,ORDER+1,PS_POLYNOMIAL_CHEB);
     248    // Verify structure allocated
     249    if(my2DDPoly == NULL) {
     250        psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
     251        return 1;
     252    }
     253    // Verify polynomial structure members set properly
     254    if(my2DDPoly->nX != ORDER) {
     255        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     256                my2DDPoly->nX, ORDER);
     257        return 2;
     258    }
     259    // Verify polynomial structure members set properly
     260    if(my2DDPoly->nY != ORDER+1) {
     261        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     262                my2DDPoly->nY, ORDER+1);
     263        return 3;
     264    }
     265    if(my2DDPoly->type != PS_POLYNOMIAL_CHEB) {
     266        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     267                my2DDPoly->type, PS_POLYNOMIAL_ORD);
     268        return 4;
     269    }
     270    for(psS32 i = 0; i < ORDER; i++) {
     271        for(psS32 j = 0; j < ORDER+1; j++) {
     272            if(my2DDPoly->coeff[i][j] != 0.0) {
     273                psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d] %lg not as expected %lg",
     274                        i, j, my2DDPoly->coeff[i][j], 0.0);
     275                return 5;
     276            }
     277            if(my2DDPoly->coeffErr[i][j] != 0.0) {
     278                psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d] %lg not as expected %lg",
     279                        i, j, my2DDPoly->coeffErr[i][j], 0.0);
     280                return 6;
     281            }
     282            if(my2DDPoly->mask[i][j] != 0) {
     283                psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d",
     284                        i, j, my2DDPoly->mask[i][j], 0);
     285                return 7;
     286            }
     287        }
     288    }
     289    psFree(my2DDPoly);
     290
     291    // Attempt to allocate with negative order
     292    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     293    if(psDPolynomial2DAlloc(-1,1,PS_POLYNOMIAL_ORD) != NULL) {
     294        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     295        return 8;
     296    }
     297    // Attempt to allocate with negative order
     298    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     299    if(psDPolynomial2DAlloc(1,-1,PS_POLYNOMIAL_ORD) != NULL) {
     300        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     301        return 9;
     302    }
     303
     304    return 0;
     305}
     306
     307// This test will allocate a 3D polynomial and verify the structure allocated
     308psS32 testPolynomial3DAlloc(void)
     309{
     310    psPolynomial3D* my3DPoly = NULL;
     311
     312    // Allocate polynomial
     313    my3DPoly = psPolynomial3DAlloc(ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_ORD);
     314    // Verify structure allocated
     315    if(my3DPoly == NULL) {
     316        psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
     317        return 1;
     318    }
     319    // Verify polynomial structure members set properly
     320    if(my3DPoly->nX != ORDER) {
     321        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     322                my3DPoly->nX, ORDER);
     323        return 2;
     324    }
     325    // Verify polynomial structure members set properly
     326    if(my3DPoly->nY != ORDER+1) {
     327        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     328                my3DPoly->nY, ORDER+1);
     329        return 3;
     330    }
     331    // Verify polynomial structure members set properly
     332    if(my3DPoly->nZ != ORDER+2) {
     333        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     334                my3DPoly->nZ, ORDER+2);
     335        return 4;
     336    }
     337    if(my3DPoly->type != PS_POLYNOMIAL_ORD) {
     338        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     339                my3DPoly->type, PS_POLYNOMIAL_ORD);
     340        return 5;
     341    }
     342    for(psS32 i = 0; i < ORDER; i++) {
     343        for(psS32 j = 0; j < ORDER+1; j++) {
     344            for(psS32 k = 0; k < ORDER+2; k++) {
     345                if(my3DPoly->coeff[i][j][k] != 0.0) {
     346                    psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d] %lg not as expected %lg",
     347                            i, j, k, my3DPoly->coeff[i][j][k], 0.0);
     348                    return 6;
     349                }
     350                if(my3DPoly->coeffErr[i][j][k] != 0.0) {
     351                    psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d] %lg not as expected %lg",
     352                            i, j, k, my3DPoly->coeffErr[i][j][k], 0.0);
     353                    return 7;
     354                }
     355                if(my3DPoly->mask[i][j][k] != 0) {
     356                    psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d",
     357                            i, j, k, my3DPoly->mask[i][j][k], 0);
     358                    return 8;
     359                }
     360            }
     361        }
     362    }
     363    psFree(my3DPoly);
     364
     365    // Attempt to allocate with negative order
     366    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     367    if(psPolynomial3DAlloc(-1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
     368        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     369        return 9;
     370    }
     371    // Attempt to allocate with negative order
     372    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     373    if(psPolynomial3DAlloc(1,-1,1,PS_POLYNOMIAL_ORD) != NULL) {
     374        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     375        return 10;
     376    }
     377    // Attempt to allocate with negative order
     378    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     379    if(psPolynomial3DAlloc(1,1,-1,PS_POLYNOMIAL_ORD) != NULL) {
     380        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     381        return 11;
     382    }
     383
     384    return 0;
     385}
     386
     387// This test will allocate a 3D polynomial and verify the structure allocated
     388psS32 testDPolynomial3DAlloc(void)
     389{
     390    psDPolynomial3D* my3DDPoly = NULL;
     391
     392    // Allocate polynomial
     393    my3DDPoly = psDPolynomial3DAlloc(ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_CHEB);
     394    // Verify structure allocated
     395    if(my3DDPoly == NULL) {
     396        psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
     397        return 1;
     398    }
     399    // Verify polynomial structure members set properly
     400    if(my3DDPoly->nX != ORDER) {
     401        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     402                my3DDPoly->nX, ORDER);
     403        return 2;
     404    }
     405    // Verify polynomial structure members set properly
     406    if(my3DDPoly->nY != ORDER+1) {
     407        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     408                my3DDPoly->nY, ORDER+1);
     409        return 3;
     410    }
     411    // Verify polynomial structure members set properly
     412    if(my3DDPoly->nZ != ORDER+2) {
     413        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     414                my3DDPoly->nZ, ORDER+2);
     415        return 4;
     416    }
     417    if(my3DDPoly->type != PS_POLYNOMIAL_CHEB) {
     418        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     419                my3DDPoly->type, PS_POLYNOMIAL_ORD);
     420        return 5;
     421    }
     422    for(psS32 i = 0; i < ORDER; i++) {
     423        for(psS32 j = 0; j < ORDER+1; j++) {
     424            for(psS32 k = 0; k < ORDER+2; k++) {
     425                if(my3DDPoly->coeff[i][j][k] != 0.0) {
     426                    psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d] %lg not as expected %lg",
     427                            i, j, k, my3DDPoly->coeff[i][j][k], 0.0);
     428                    return 6;
     429                }
     430                if(my3DDPoly->coeffErr[i][j][k] != 0.0) {
     431                    psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d] %lg not as expected %lg",
     432                            i, j, k, my3DDPoly->coeffErr[i][j][k], 0.0);
     433                    return 7;
     434                }
     435                if(my3DDPoly->mask[i][j][k] != 0) {
     436                    psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d",
     437                            i, j, k, my3DDPoly->mask[i][j][k], 0);
     438                    return 8;
     439                }
     440            }
     441        }
     442    }
     443    psFree(my3DDPoly);
     444
     445    // Attempt to allocate with negative order
     446    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     447    if(psDPolynomial3DAlloc(-1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
     448        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     449        return 9;
     450    }
     451    // Attempt to allocate with negative order
     452    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     453    if(psDPolynomial3DAlloc(1,-1,1,PS_POLYNOMIAL_ORD) != NULL) {
     454        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     455        return 10;
     456    }
     457    // Attempt to allocate with negative order
     458    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     459    if(psDPolynomial3DAlloc(1,1,-1,PS_POLYNOMIAL_ORD) != NULL) {
     460        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     461        return 11;
     462    }
     463
     464    return 0;
     465}
     466
     467// This test will allocate a 4D polynomial and verify the structure allocated
     468psS32 testPolynomial4DAlloc(void)
     469{
     470    psPolynomial4D* my4DPoly = NULL;
     471
     472    // Allocate polynomial
     473    my4DPoly = psPolynomial4DAlloc(ORDER+3,ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_ORD);
     474    // Verify structure allocated
     475    if(my4DPoly == NULL) {
     476        psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
     477        return 1;
     478    }
     479    // Verify polynomial structure members set properly
     480    if(my4DPoly->nX != ORDER) {
     481        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     482                my4DPoly->nX, ORDER);
     483        return 2;
     484    }
     485    // Verify polynomial structure members set properly
     486    if(my4DPoly->nY != ORDER+1) {
     487        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     488                my4DPoly->nY, ORDER+1);
     489        return 3;
     490    }
     491    // Verify polynomial structure members set properly
     492    if(my4DPoly->nZ != ORDER+2) {
     493        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     494                my4DPoly->nZ, ORDER+2);
     495        return 4;
     496    }
     497    // Verify polynomial structure members set properly
     498    if(my4DPoly->nW != ORDER+3) {
     499        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     500                my4DPoly->nW, ORDER+3);
     501        return 5;
     502    }
     503    if(my4DPoly->type != PS_POLYNOMIAL_ORD) {
     504        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     505                my4DPoly->type, PS_POLYNOMIAL_ORD);
     506        return 6;
     507    }
     508    for(psS32 i = 0; i < ORDER+3; i++) {
     509        for(psS32 j = 0; j < ORDER; j++) {
     510            for(psS32 k = 0; k < ORDER+1; k++) {
     511                for(psS32 l = 0; l < ORDER+2; l++) {
     512                    if(my4DPoly->coeff[i][j][k][l] != 0.0) {
     513                        psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d][%d] %lg not as expected %lg",
     514                                i, j, k, l, my4DPoly->coeff[i][j][k][l], 0.0);
     515                        return 7;
     516                    }
     517                    if(my4DPoly->coeffErr[i][j][k][l] != 0.0) {
     518                        psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d][l] %lg not as expected %lg",
     519                                i, j, k, l, my4DPoly->coeffErr[i][j][k][l], 0.0);
     520                        return 8;
     521                    }
     522                    if(my4DPoly->mask[i][j][k][l] != 0) {
     523                        psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d][%d][%d] %d not as expected %d",
     524                                i, j, k, l, my4DPoly->mask[i][j][k][l], 0);
     525                        return 9;
     526                    }
     527                }
     528            }
     529        }
     530    }
     531    psFree(my4DPoly);
     532
     533    // Attempt to allocate with negative order
     534    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     535    if(psPolynomial4DAlloc(-1,1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
     536        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     537        return 10;
     538    }
     539    // Attempt to allocate with negative order
     540    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     541    if(psPolynomial4DAlloc(1,-1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
     542        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     543        return 11;
     544    }
     545    // Attempt to allocate with negative order
     546    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     547    if(psPolynomial4DAlloc(1,1,-1,1,PS_POLYNOMIAL_ORD) != NULL) {
     548        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     549        return 12;
     550    }
     551    // Attempt to allocate with negative order
     552    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     553    if(psPolynomial4DAlloc(1,1,1,-1,PS_POLYNOMIAL_ORD) != NULL) {
     554        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     555        return 13;
     556    }
     557
     558    return 0;
     559}
     560
     561// This test will allocate a 4D polynomial and verify the structure allocated
     562psS32 testDPolynomial4DAlloc(void)
     563{
     564    psDPolynomial4D* my4DDPoly = NULL;
     565
     566    // Allocate polynomial
     567    my4DDPoly = psDPolynomial4DAlloc(ORDER+3,ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_ORD);
     568    // Verify structure allocated
     569    if(my4DDPoly == NULL) {
     570        psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
     571        return 1;
     572    }
     573    // Verify polynomial structure members set properly
     574    if(my4DDPoly->nX != ORDER) {
     575        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     576                my4DDPoly->nX, ORDER);
     577        return 2;
     578    }
     579    // Verify polynomial structure members set properly
     580    if(my4DDPoly->nY != ORDER+1) {
     581        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     582                my4DDPoly->nY, ORDER+1);
     583        return 3;
     584    }
     585    // Verify polynomial structure members set properly
     586    if(my4DDPoly->nZ != ORDER+2) {
     587        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     588                my4DDPoly->nZ, ORDER+2);
     589        return 4;
     590    }
     591    // Verify polynomial structure members set properly
     592    if(my4DDPoly->nW != ORDER+3) {
     593        psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
     594                my4DDPoly->nW, ORDER+3);
     595        return 5;
     596    }
     597    if(my4DDPoly->type != PS_POLYNOMIAL_ORD) {
     598        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
     599                my4DDPoly->type, PS_POLYNOMIAL_ORD);
     600        return 6;
     601    }
     602    for(psS32 i = 0; i < ORDER+3; i++) {
     603        for(psS32 j = 0; j < ORDER; j++) {
     604            for(psS32 k = 0; k < ORDER+1; k++) {
     605                for(psS32 l = 0; l < ORDER+2; l++) {
     606                    if(my4DDPoly->coeff[i][j][k][l] != 0.0) {
     607                        psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d][%d] %lg not as expected %lg",
     608                                i, j, k, l, my4DDPoly->coeff[i][j][k][l], 0.0);
     609                        return 7;
     610                    }
     611                    if(my4DDPoly->coeffErr[i][j][k][l] != 0.0) {
     612                        psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d][l] %lg not as expected %lg",
     613                                i, j, k, l, my4DDPoly->coeffErr[i][j][k][l], 0.0);
     614                        return 8;
     615                    }
     616                    if(my4DDPoly->mask[i][j][k][l] != 0) {
     617                        psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d][%d][%d] %d not as expected %d",
     618                                i, j, k, l, my4DDPoly->mask[i][j][k][l], 0);
     619                        return 9;
     620                    }
     621                }
     622            }
     623        }
     624    }
     625    psFree(my4DDPoly);
     626
     627    // Attempt to allocate with negative order
     628    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     629    if(psDPolynomial4DAlloc(-1,1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
     630        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     631        return 10;
     632    }
     633    // Attempt to allocate with negative order
     634    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     635    if(psDPolynomial4DAlloc(1,-1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
     636        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     637        return 11;
     638    }
     639    // Attempt to allocate with negative order
     640    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     641    if(psDPolynomial4DAlloc(1,1,-1,1,PS_POLYNOMIAL_ORD) != NULL) {
     642        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     643        return 12;
     644    }
     645    // Attempt to allocate with negative order
     646    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
     647    if(psDPolynomial4DAlloc(1,1,1,-1,PS_POLYNOMIAL_ORD) != NULL) {
     648        psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
     649        return 13;
     650    }
     651
     652    return 0;
     653}
     654
     655
    27656// XXX: This test comes from Paul Price.  We should add into the code.
    28657#define ORDER 3
    29658#define BAD 1
    30 int t01()
     659psS32 t01(void)
    31660{
    32661    psPolynomial1D *poly = psPolynomial1DAlloc(ORDER, PS_POLYNOMIAL_ORD);
     
    55684
    56685
    57 psS32 main()
     686psS32 myTest()
    58687{
    59688    t01();
     
    5031132    /*  Allocate and initialize data structures                      */
    5041133    /*************************************************************************/
    505 
    506     // HEY
    507 
    5081134    printPositiveTestHeader(stdout,
    5091135                            "psFunctions functions",
     
    5331159                "Allocate/Deallocate the psDPolynomial1D structure (CHEBYSHEV).",
    5341160                testStatus);
    535 
    536 
    537 
    538     return (!testStatus);
    539 
    5401161
    5411162    printPositiveTestHeader(stdout,
  • trunk/psLib/test/dataManip/verified/tst_psFunc00.stderr

    r2947 r3382  
     1/***************************** TESTPOINT ******************************************\
     2*             TestFile: tst_psFunc00.c                                             *
     3*            TestPoint: psPolynomialXD{psPolynomial1DAlloc}                        *
     4*             TestType: Positive                                                   *
     5\**********************************************************************************/
     6
     7<DATE><TIME>|<HOST>|I|testPolynomial1DAlloc
     8    Following should generate error msg for negative terms
     9<DATE><TIME>|<HOST>|E|psPolynomial1DAlloc (FILE:LINENO)
     10    Error: n is less than 0.
     11
     12---> TESTPOINT PASSED (psPolynomialXD{psPolynomial1DAlloc} | tst_psFunc00.c)
     13
     14/***************************** TESTPOINT ******************************************\
     15*             TestFile: tst_psFunc00.c                                             *
     16*            TestPoint: psPolynomialXD{psPolynomial2DAlloc}                        *
     17*             TestType: Positive                                                   *
     18\**********************************************************************************/
     19
     20<DATE><TIME>|<HOST>|I|testPolynomial2DAlloc
     21    Following should generate error msg for negative terms
     22<DATE><TIME>|<HOST>|E|psPolynomial2DAlloc (FILE:LINENO)
     23    Error: nX is less than 0.
     24<DATE><TIME>|<HOST>|I|testPolynomial2DAlloc
     25    Following should generate error msg for negative terms
     26<DATE><TIME>|<HOST>|E|psPolynomial2DAlloc (FILE:LINENO)
     27    Error: nY is less than 0.
     28
     29---> TESTPOINT PASSED (psPolynomialXD{psPolynomial2DAlloc} | tst_psFunc00.c)
     30
     31/***************************** TESTPOINT ******************************************\
     32*             TestFile: tst_psFunc00.c                                             *
     33*            TestPoint: psPolynomialXD{psPolynomial3DAlloc}                        *
     34*             TestType: Positive                                                   *
     35\**********************************************************************************/
     36
     37<DATE><TIME>|<HOST>|I|testPolynomial3DAlloc
     38    Following should generate error msg for negative terms
     39<DATE><TIME>|<HOST>|E|psPolynomial3DAlloc (FILE:LINENO)
     40    Error: nX is less than 0.
     41<DATE><TIME>|<HOST>|I|testPolynomial3DAlloc
     42    Following should generate error msg for negative terms
     43<DATE><TIME>|<HOST>|E|psPolynomial3DAlloc (FILE:LINENO)
     44    Error: nY is less than 0.
     45<DATE><TIME>|<HOST>|I|testPolynomial3DAlloc
     46    Following should generate error msg for negative terms
     47<DATE><TIME>|<HOST>|E|psPolynomial3DAlloc (FILE:LINENO)
     48    Error: nZ is less than 0.
     49
     50---> TESTPOINT PASSED (psPolynomialXD{psPolynomial3DAlloc} | tst_psFunc00.c)
     51
     52/***************************** TESTPOINT ******************************************\
     53*             TestFile: tst_psFunc00.c                                             *
     54*            TestPoint: psPolynomialXD{psPolynomial4DAlloc}                        *
     55*             TestType: Positive                                                   *
     56\**********************************************************************************/
     57
     58<DATE><TIME>|<HOST>|I|testPolynomial4DAlloc
     59    Following should generate error msg for negative terms
     60<DATE><TIME>|<HOST>|E|psPolynomial4DAlloc (FILE:LINENO)
     61    Error: nW is less than 0.
     62<DATE><TIME>|<HOST>|I|testPolynomial4DAlloc
     63    Following should generate error msg for negative terms
     64<DATE><TIME>|<HOST>|E|psPolynomial4DAlloc (FILE:LINENO)
     65    Error: nX is less than 0.
     66<DATE><TIME>|<HOST>|I|testPolynomial4DAlloc
     67    Following should generate error msg for negative terms
     68<DATE><TIME>|<HOST>|E|psPolynomial4DAlloc (FILE:LINENO)
     69    Error: nY is less than 0.
     70<DATE><TIME>|<HOST>|I|testPolynomial4DAlloc
     71    Following should generate error msg for negative terms
     72<DATE><TIME>|<HOST>|E|psPolynomial4DAlloc (FILE:LINENO)
     73    Error: nZ is less than 0.
     74
     75---> TESTPOINT PASSED (psPolynomialXD{psPolynomial4DAlloc} | tst_psFunc00.c)
     76
     77/***************************** TESTPOINT ******************************************\
     78*             TestFile: tst_psFunc00.c                                             *
     79*            TestPoint: psPolynomialXD{psDPolynomial1DAlloc}                       *
     80*             TestType: Positive                                                   *
     81\**********************************************************************************/
     82
     83<DATE><TIME>|<HOST>|I|testDPolynomial1DAlloc
     84    Following should generate error msg for negative terms
     85<DATE><TIME>|<HOST>|E|psDPolynomial1DAlloc (FILE:LINENO)
     86    Error: n is less than 0.
     87
     88---> TESTPOINT PASSED (psPolynomialXD{psDPolynomial1DAlloc} | tst_psFunc00.c)
     89
     90/***************************** TESTPOINT ******************************************\
     91*             TestFile: tst_psFunc00.c                                             *
     92*            TestPoint: psPolynomialXD{psDPolynomial2DAlloc}                       *
     93*             TestType: Positive                                                   *
     94\**********************************************************************************/
     95
     96<DATE><TIME>|<HOST>|I|testDPolynomial2DAlloc
     97    Following should generate error msg for negative terms
     98<DATE><TIME>|<HOST>|E|psDPolynomial2DAlloc (FILE:LINENO)
     99    Error: nX is less than 0.
     100<DATE><TIME>|<HOST>|I|testDPolynomial2DAlloc
     101    Following should generate error msg for negative terms
     102<DATE><TIME>|<HOST>|E|psDPolynomial2DAlloc (FILE:LINENO)
     103    Error: nY is less than 0.
     104
     105---> TESTPOINT PASSED (psPolynomialXD{psDPolynomial2DAlloc} | tst_psFunc00.c)
     106
     107/***************************** TESTPOINT ******************************************\
     108*             TestFile: tst_psFunc00.c                                             *
     109*            TestPoint: psPolynomialXD{psDPolynomial3DAlloc}                       *
     110*             TestType: Positive                                                   *
     111\**********************************************************************************/
     112
     113<DATE><TIME>|<HOST>|I|testDPolynomial3DAlloc
     114    Following should generate error msg for negative terms
     115<DATE><TIME>|<HOST>|E|psDPolynomial3DAlloc (FILE:LINENO)
     116    Error: nX is less than 0.
     117<DATE><TIME>|<HOST>|I|testDPolynomial3DAlloc
     118    Following should generate error msg for negative terms
     119<DATE><TIME>|<HOST>|E|psDPolynomial3DAlloc (FILE:LINENO)
     120    Error: nY is less than 0.
     121<DATE><TIME>|<HOST>|I|testDPolynomial3DAlloc
     122    Following should generate error msg for negative terms
     123<DATE><TIME>|<HOST>|E|psDPolynomial3DAlloc (FILE:LINENO)
     124    Error: nZ is less than 0.
     125
     126---> TESTPOINT PASSED (psPolynomialXD{psDPolynomial3DAlloc} | tst_psFunc00.c)
     127
     128/***************************** TESTPOINT ******************************************\
     129*             TestFile: tst_psFunc00.c                                             *
     130*            TestPoint: psPolynomialXD{psDPolynomial4DAlloc}                       *
     131*             TestType: Positive                                                   *
     132\**********************************************************************************/
     133
     134<DATE><TIME>|<HOST>|I|testDPolynomial4DAlloc
     135    Following should generate error msg for negative terms
     136<DATE><TIME>|<HOST>|E|psDPolynomial4DAlloc (FILE:LINENO)
     137    Error: nW is less than 0.
     138<DATE><TIME>|<HOST>|I|testDPolynomial4DAlloc
     139    Following should generate error msg for negative terms
     140<DATE><TIME>|<HOST>|E|psDPolynomial4DAlloc (FILE:LINENO)
     141    Error: nX is less than 0.
     142<DATE><TIME>|<HOST>|I|testDPolynomial4DAlloc
     143    Following should generate error msg for negative terms
     144<DATE><TIME>|<HOST>|E|psDPolynomial4DAlloc (FILE:LINENO)
     145    Error: nY is less than 0.
     146<DATE><TIME>|<HOST>|I|testDPolynomial4DAlloc
     147    Following should generate error msg for negative terms
     148<DATE><TIME>|<HOST>|E|psDPolynomial4DAlloc (FILE:LINENO)
     149    Error: nZ is less than 0.
     150
     151---> TESTPOINT PASSED (psPolynomialXD{psDPolynomial4DAlloc} | tst_psFunc00.c)
     152
     153/***************************** TESTPOINT ******************************************\
     154*             TestFile: tst_psFunc00.c                                             *
     155*            TestPoint: psPolynomialXD{psPolynomial1DAlloc}                        *
     156*             TestType: Positive                                                   *
     157\**********************************************************************************/
     158
    1159Value using mask: 0.500000
    2160Value using coefficient zeroing: 0.500000
     161
     162---> TESTPOINT PASSED (psPolynomialXD{psPolynomial1DAlloc} | tst_psFunc00.c)
     163
Note: See TracChangeset for help on using the changeset viewer.