IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3293


Ignore:
Timestamp:
Feb 18, 2005, 4:55:33 PM (21 years ago)
Author:
evanalst
Message:

Update test case for psSphereTransformApply.

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

Legend:

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

    r3264 r3293  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-02-17 19:26:24 $
     8*  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-02-19 02:55:33 $
    1010*
    1111*  XXX: Must test psSpherePrecess.
     
    2222#include "psTest.h"
    2323#include "pslib.h"
    24 static psS32 test1( void );
     24static psS32 testSphereTransformAlloc( void );
    2525static psS32 test1b( void );
    2626static psS32 test1c( void );
    2727static psS32 test2( void );
    2828static psS32 test3( void );
    29 static psS32 test4( void );
     29static psS32 testSphereTransformApply1( void );
    3030static psS32 test4b( void );
    3131static psS32 test5( void );
     
    4040//static psS32 test43( void );
    4141testDescription tests[] = {
    42                               {test1, 0000, "psSphereTransformAlloc()", 0, false},
     42                              {testSphereTransformAlloc, 819, "psSphereTransformAlloc()", 0, false},
    4343                              {test1b, 0000, "psPlaneTransformAlloc()", 0, false},
    4444                              {test1c, 0000, "psPlaneDistortAlloc()", 0, false},
    4545                              {test2, 0000, "psPlaneTransformApply()", 0, false},
    4646                              {test3, 0000, "psPlaneDistortApply()", 0, false},
    47                               {test4, 0000, "psPSphereTransformApply()", 0, false},
     47                              {testSphereTransformApply1, 0000, "psPSphereTransformApply()", 0, false},
    4848                              {test4b, 0000, "psPSphereTransformApply()", 0, false},
    4949                              {test5, 0000, "psSphereTransformICRSToEcliptic()", 0, false},
     
    9090#define DELTA_P 2.0
    9191#define PHI_P 3.0
    92 psS32 test1( void )
    93 {
    94     psS32 testStatus = 0;
     92psS32 testSphereTransformAlloc( void )
     93{
     94    // Allocate data structure
    9595    psSphereTransform *myST = psSphereTransformAlloc(ALPHA_P, DELTA_P, PHI_P);
    96 
     96    // Verify null not returned
     97    if(myST == NULL) {
     98        psError(PS_ERR_UNKNOWN,true,"Returned NULL with valid parameters");
     99        return 1;
     100    }
     101    // Verify sin member is updated
    97102    psF32 sinDeltaP = sin(DELTA_P);
    98103    if (FLT_EPSILON < fabs(sinDeltaP - myST->sinDeltaP)) {
    99         printf("ERROR: myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sinDeltaP);
    100         testStatus = 1;
    101     }
     104        psError(PS_ERR_UNKNOWN,true,"myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sinDeltaP);
     105        return 2;
     106    }
     107    // Verify cos member is update
    102108    psF32 cosDeltaP = cos(DELTA_P);
    103109    if (FLT_EPSILON < fabs(cosDeltaP - myST->cosDeltaP)) {
    104         printf("ERROR: myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cosDeltaP);
    105         testStatus = 1;
    106     }
    107 
     110        psError(PS_ERR_UNKNOWN,true,"myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cosDeltaP);
     111        return 3;
     112    }
     113    // Verify alpha is updated
    108114    if (FLT_EPSILON < fabs(ALPHA_P - myST->alphaP)) {
    109         printf("ERROR: myST->alphaP is %f, should be %f\n", myST->alphaP, ALPHA_P);
    110         testStatus = 3;
    111     }
    112 
     115        psError(PS_ERR_UNKNOWN,true,"myST->alphaP is %f, should be %f\n", myST->alphaP, ALPHA_P);
     116        return 4;
     117    }
     118    // Verify phi is updated
    113119    if (FLT_EPSILON < fabs(PHI_P - myST->phiP)) {
    114         printf("ERROR: myST->phiP is %f, should be %f\n", myST->phiP, PHI_P);
    115         testStatus = 4;
    116     }
    117 
     120        psError(PS_ERR_UNKNOWN,true,"myST->phiP is %f, should be %f\n", myST->phiP, PHI_P);
     121        return 5;
     122    }
     123    // Free data structure
    118124    psFree(myST);
    119     return(testStatus);
     125
     126    return 0;
    120127}
    121128
     
    430437#define DEG_INC 30.0
    431438// We do a simple identity transformation on a few RA, DEC pairs.
    432 psS32 test4( void )
    433 {
    434     psS32 testStatus = 0;
    435     psSphere in;
    436     psSphere out;
     439psS32 testSphereTransformApply1( void )
     440{
     441    psSphere *in = psSphereAlloc();
     442    psSphere *out = psSphereAlloc();
     443    psSphere *temp = NULL;
    437444    psSphere *rc = NULL;
    438445    psSphereTransform *myST = psSphereTransformAlloc(0.0, 0.0, 0.0);
    439446
    440     in.r = DEG_TO_RAD(45.0);
    441     in.d = DEG_TO_RAD(30.0);
    442     in.rErr = 0.0;
    443     in.dErr = 0.0;
     447    in->r = DEG_TO_RAD(45.0);
     448    in->d = DEG_TO_RAD(30.0);
     449    in->rErr = 0.0;
     450    in->dErr = 0.0;
    444451
    445452    for (float r=0.0;r<180.0;r+=DEG_INC) {
    446453        for (float d=0.0;d<90.0;d+=DEG_INC) {
    447             in.r = DEG_TO_RAD(r);
    448             in.d = DEG_TO_RAD(d);
    449             in.rErr = 0.0;
    450             in.dErr = 0.0;
    451 
    452             psSphereTransformApply(&out, myST, &in);
    453 
    454             if (FLT_EPSILON < fabs(out.r - in.r)) {
    455                 printf("ERROR: out.r is %f, should be %f\n", out.r, in.r);
    456                 testStatus = 4;
     454            in->r = DEG_TO_RAD(r);
     455            in->d = DEG_TO_RAD(d);
     456            in->rErr = 0.0;
     457            in->dErr = 0.0;
     458
     459            if(psSphereTransformApply(out, myST, in) != out) {
     460                psError(PS_ERR_UNKNOWN,true,"Did not return output pointer.");
     461                return 1;
    457462            }
    458 
    459             if (FLT_EPSILON < fabs(out.d - in.d)) {
    460                 printf("ERROR: out.d is %f, should be %f\n", out.d, in.d);
    461                 testStatus = 5;
     463            if (FLT_EPSILON < fabs(out->r - in->r)) {
     464                psError(PS_ERR_UNKNOWN,true,"out->r is %f, should be %f\n", out->r, in->r);
     465                return 2;
     466            }
     467            if (FLT_EPSILON < fabs(out->d - in->d)) {
     468                psError(PS_ERR_UNKNOWN,true,"out->d is %f, should be %f\n", out->d, in->d);
     469                return 3;
    462470            }
    463471            // printf("psSphereTransformApply (%f, %f) -> (%f, %f)\n", out.r, out.d, in.r, in.d);
     
    465473    }
    466474
    467     printf("-------------------------------------------------------------------\n");
    468     printf("Calling psSphereTransformApply() with NULL psSphereTransform.  Should generate error, return NULL.\n");
    469     rc = psSphereTransformApply(NULL, NULL, &in);
     475    // Verify new sphere object is created if out parameter NULL
     476    temp = psSphereTransformApply(NULL, myST, in);
     477    if ( temp == NULL) {
     478        psError(PS_ERR_UNKNOWN,true,"Returned NULL when out parameter was null");
     479        return 4;
     480    }
     481    psFree(temp);
     482
     483    // Verify NULL returned if transform structure null
     484    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
     485    rc = psSphereTransformApply(NULL, NULL, in);
    470486    if (rc != NULL) {
    471         printf("TEST ERROR: psSphereTransformApply() did not return NULL.\n");
    472         testStatus = false;
    473         rc = NULL;
    474     }
    475 
    476     printf("-------------------------------------------------------------------\n");
    477     printf("Calling psSphereTransformApply() with NULL input coords.  Should generate error, return NULL.\n");
     487        psError(PS_ERR_UNKNOWN,true,"psSphereTransformApply() did not return NULL.");
     488        return 5;
     489    }
     490
     491    // Verify NULL returned when input sphere is NULL
     492    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
    478493    rc = psSphereTransformApply(NULL, myST, NULL);
    479494    if (rc != NULL) {
    480         printf("TEST ERROR: psSphereTransformApply() did not return NULL.\n");
    481         testStatus = false;
    482         rc = NULL;
    483     }
    484 
    485     printf("-------------------------------------------------------------------\n");
     495        psError(PS_ERR_UNKNOWN,true,"psSphereTransformApply() did not return NULL");
     496        return 6;
     497    }
     498
    486499    psFree(myST);
    487     return(testStatus);
     500    psFree(out);
     501    psFree(in);
     502
     503    return 0;
    488504}
    489505
  • trunk/psLib/test/astronomy/verified/tst_psCoord.stderr

    r3127 r3293  
    7878\**********************************************************************************/
    7979
     80<DATE><TIME>|<HOST>|I|testSphereTransformApply1
     81    Following should generate an error
    8082<DATE><TIME>|<HOST>|E|psSphereTransformApply (FILE:LINENO)
    8183    Unallowable operation: transform is NULL.
     84<DATE><TIME>|<HOST>|I|testSphereTransformApply1
     85    Following should generate an error
    8286<DATE><TIME>|<HOST>|E|psSphereTransformApply (FILE:LINENO)
    8387    Unallowable operation: coord is NULL.
  • trunk/psLib/test/astronomy/verified/tst_psCoord.stdout

    r2999 r3293  
    3232-------------------------------------------------------------------
    3333-------------------------------------------------------------------
    34 Calling psSphereTransformApply() with NULL psSphereTransform.  Should generate error, return NULL.
    35 -------------------------------------------------------------------
    36 Calling psSphereTransformApply() with NULL input coords.  Should generate error, return NULL.
    37 -------------------------------------------------------------------
    38 -------------------------------------------------------------------
    3934Calling psSphereTransformICRSToEcliptic() with NULL input.  Should generate error, return NULL.
    4035-------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.