IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3431


Ignore:
Timestamp:
Mar 15, 2005, 4:31:07 PM (21 years ago)
Author:
evanalst
Message:

Update test case for psPlaneAlloc and psPlaneTransformApply.

Location:
trunk/psLib/test/astronomy
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astronomy/tst_psCoord.c

    r3367 r3431  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-03-02 23:00:17 $
     8*  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-03-16 02:31:05 $
    1010*
    1111*  XXX: THe psProject() and psDeproject() functions do not work fully.  They
     
    2424static psS32 testPlaneTransformAlloc( void );
    2525static psS32 testPlaneDistortAlloc( void );
    26 static psS32 test2( void );
     26static psS32 testPlaneTransformApply( void );
    2727static psS32 test3( void );
    2828static psS32 testSphereTransformApply1( void );
     
    4646                              {testPlaneTransformAlloc, 826, "psPlaneTransformAlloc()", 0, false},
    4747                              {testPlaneDistortAlloc, 827, "psPlaneDistortAlloc()", 0, false},
    48                               {test2, 0000, "psPlaneTransformApply()", 0, false},
     48                              {testPlaneTransformApply, 0000, "psPlaneTransformApply()", 0, false},
    4949                              {test3, 0000, "psPlaneDistortApply()", 0, false},
    5050                              {testSphereTransformApply1, 820, "psSphereTransformApply()", 0, false},
     
    294294#define N 10
    295295// We do a simple identity transformation on a few x,y pairs.
    296 psS32 test2( void )
    297 {
    298     psS32 i;
    299     psS32 testStatus = 0;
    300     psPlane in;
    301     psPlane out;
    302     psPlane *rc;
    303     psPlaneTransform pt;
    304     psDPolynomial2D *tmp2DPoly = NULL;
    305 
    306     pt.x = psDPolynomial2DAlloc(2, 2, PS_POLYNOMIAL_ORD);
    307     pt.y = psDPolynomial2DAlloc(2, 2, PS_POLYNOMIAL_ORD);
    308     pt.x->coeff[1][0] = 1.0;
    309     pt.y->coeff[0][1] = 1.0;
    310     for (i=0;i<N;i++) {
    311         in.x = (float) i;
    312         in.y = (float) (i + 5.0);
    313         in.xErr = 0.0;
    314         in.yErr = 0.0;
    315         psPlaneTransformApply(&out, &pt, &in);
    316 
    317         if (FLT_EPSILON < fabs(out.x - in.x)) {
    318             printf("ERROR: out.x is %f, should be %f\n", out.x, in.x);
    319             testStatus = 3;
     296psS32 testPlaneTransformApply( void )
     297{
     298    psPlane*          out = NULL;
     299    psDPolynomial2D*  tmp2DPoly = NULL;
     300    psPlane*          rc;
     301
     302    // Create input coordinate
     303    psPlane* in = psPlaneAlloc();
     304    if(in == NULL) {
     305        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return from psPlaneAlloc");
     306        return 1;
     307    }
     308
     309    // Create transform
     310    psPlaneTransform* pt = psPlaneTransformAlloc(2,2);
     311
     312    // Set transform coefficients so the x coord input will equal x coord output, same for y
     313    pt->x->coeff[1][0] = 1.0;
     314    pt->y->coeff[0][1] = 1.0;
     315
     316    // Apply transform for several points
     317    for (psS32 i = 0; i < N; i++) {
     318        in->x = (psF64) i;
     319        in->y = (psF64) (i + 5.0);
     320        in->xErr = 0.0;
     321        in->yErr = 0.0;
     322
     323        // Verify function does not return NULL
     324        out = psPlaneTransformApply(out, pt, in);
     325        if( out  == NULL) {
     326            psError(PS_ERR_UNKNOWN,true,"Expected non-NULL return value");
     327            return 1;
    320328        }
    321 
    322         if (FLT_EPSILON < fabs(out.y - in.y)) {
    323             printf("ERROR: out.y is %f, should be %f\n", out.y, in.y);
    324             testStatus = 4;
     329        // Verify the expected values are returned
     330        if (FLT_EPSILON < fabs(out->x - in->x)) {
     331            psError(PS_ERR_UNKNOWN,true,"out.x is %lf, should be %lf", out->x, in->x);
     332            return 3;
    325333        }
    326         //printf("psPlaneTransformApply(): (%f, %f) -> (%f, %f)\n", in.x, in.y, out.x, out.y);
    327     }
    328 
    329     printf("-------------------------------------------------------------------\n");
    330     printf("Calling psPlaneTransformApply() with NULL psPlaneTransform.  Should generate error, return NULL.\n");
    331     rc = psPlaneTransformApply(NULL, NULL, &in);
     334        if (FLT_EPSILON < fabs(out->y - in->y)) {
     335            psError(PS_ERR_UNKNOWN,true,"out.y is %lf, should be %lf", out->y, in->y);
     336            return 4;
     337        }
     338    }
     339    psFree(out);
     340
     341    // Verify return null and error message generater for null specified transform
     342    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL psPlaneTransform");
     343    rc = psPlaneTransformApply(NULL, NULL, in);
    332344    if (rc != NULL) {
    333         printf("TEST ERROR: psPlaneTransformApply() did not return NULL.\n");
    334         testStatus = false;
    335         rc = NULL;
    336     }
    337 
    338     printf("-------------------------------------------------------------------\n");
    339     printf("Calling psPlaneTransformApply() with NULL psPlaneTransform->x.  Should generate error, return NULL.\n");
    340     tmp2DPoly = pt.x;
    341     pt.x = NULL;
    342     rc = psPlaneTransformApply(NULL, &pt, &in);
     345        psError(PS_ERR_UNKNOWN,true,"Function did not return NULL as expected for NULL psPlaneTransform.");
     346        return 5;
     347    }
     348
     349    // Verify return null and error message generated for null psPlaneTransform x coeff
     350    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL x coeff psPlaneTransform");
     351    tmp2DPoly = pt->x;
     352    pt->x = NULL;
     353    rc = psPlaneTransformApply(NULL, pt, in);
    343354    if (rc != NULL) {
    344         printf("TEST ERROR: psPlaneTransformApply() did not return NULL.\n");
    345         testStatus = false;
    346         rc = NULL;
    347     }
    348     pt.x = tmp2DPoly;
    349 
    350     printf("-------------------------------------------------------------------\n");
    351     printf("Calling psPlaneTransformApply() with NULL psPlaneTransform->y.  Should generate error, return NULL.\n");
    352     tmp2DPoly = pt.y;
    353     pt.y = NULL;
    354     rc = psPlaneTransformApply(NULL, &pt, &in);
     355        psError(PS_ERR_UNKNOWN,true,"Function did not return NULL as expected for NULL x coeff psPlaneTransform");
     356        return 6;
     357    }
     358    pt->x = tmp2DPoly;
     359
     360    // Verify return null and error message generated for null psPlaneTransform y coeff
     361    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL y coeff psPlaneTransform");
     362    tmp2DPoly = pt->y;
     363    pt->y = NULL;
     364    rc = psPlaneTransformApply(NULL, pt, in);
    355365    if (rc != NULL) {
    356         printf("TEST ERROR: psPlaneTransformApply() did not return NULL.\n");
    357         testStatus = false;
    358         rc = NULL;
    359     }
    360     pt.y = tmp2DPoly;
    361 
    362     printf("-------------------------------------------------------------------\n");
    363     printf("Calling psPlaneTransformApply() with NULL input coords.  Should generate error, return NULL.\n");
    364     rc = psPlaneTransformApply(NULL, &pt, NULL);
     366        psError(PS_ERR_UNKNOWN,true,"Function did not return NULL as expected for NULL y coeff psPlaneTransform");
     367        return 7;
     368    }
     369    pt->y = tmp2DPoly;
     370
     371    // Verify return null and error message generated for null psPlane coordinate
     372    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL psPlane");
     373    rc = psPlaneTransformApply(NULL, pt, NULL);
    365374    if (rc != NULL) {
    366         printf("TEST ERROR: psPlaneTransformApply() did not return NULL.\n");
    367         testStatus = false;
    368         rc = NULL;
    369     }
    370 
    371     printf("-------------------------------------------------------------------\n");
    372     psFree(pt.x);
    373     psFree(pt.y);
    374     return(testStatus);
     375        psError(PS_ERR_UNKNOWN,true,"Function did not return NULL as expected for NULL psPlane");
     376        return 8;
     377    }
     378
     379    psFree(pt);
     380    psFree(in);
     381
     382    return 0;
    375383}
    376384
  • trunk/psLib/test/astronomy/verified/tst_psCoord.stderr

    r3367 r3431  
    5656\**********************************************************************************/
    5757
     58<DATE><TIME>|<HOST>|I|testPlaneTransformApply
     59    Following should generate error message for NULL psPlaneTransform
    5860<DATE><TIME>|<HOST>|E|psPlaneTransformApply (FILE:LINENO)
    5961    Unallowable operation: transform is NULL.
     62<DATE><TIME>|<HOST>|I|testPlaneTransformApply
     63    Following should generate error message for NULL x coeff psPlaneTransform
    6064<DATE><TIME>|<HOST>|E|psPlaneTransformApply (FILE:LINENO)
    6165    Unallowable operation: transform->x is NULL.
     66<DATE><TIME>|<HOST>|I|testPlaneTransformApply
     67    Following should generate error message for NULL y coeff psPlaneTransform
    6268<DATE><TIME>|<HOST>|E|psPlaneTransformApply (FILE:LINENO)
    6369    Unallowable operation: transform->y is NULL.
     70<DATE><TIME>|<HOST>|I|testPlaneTransformApply
     71    Following should generate error message for NULL psPlane
    6472<DATE><TIME>|<HOST>|E|psPlaneTransformApply (FILE:LINENO)
    6573    Unallowable operation: coords is NULL.
  • trunk/psLib/test/astronomy/verified/tst_psCoord.stdout

    r3367 r3431  
    1 -------------------------------------------------------------------
    2 Calling psPlaneTransformApply() with NULL psPlaneTransform.  Should generate error, return NULL.
    3 -------------------------------------------------------------------
    4 Calling psPlaneTransformApply() with NULL psPlaneTransform->x.  Should generate error, return NULL.
    5 -------------------------------------------------------------------
    6 Calling psPlaneTransformApply() with NULL psPlaneTransform->y.  Should generate error, return NULL.
    7 -------------------------------------------------------------------
    8 Calling psPlaneTransformApply() with NULL input coords.  Should generate error, return NULL.
    9 -------------------------------------------------------------------
    101-------------------------------------------------------------------
    112Calling psPlaneDistortApply() with NULL psPlaneDistort.  Should generate error, return NULL.
Note: See TracChangeset for help on using the changeset viewer.