IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3555


Ignore:
Timestamp:
Mar 29, 2005, 2:16:51 PM (21 years ago)
Author:
gusciora
Message:

Added simple tests for the new planeTransform functions.

File:
1 edited

Legend:

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

    r3539 r3555  
    55*  @author GLG, MHPCC
    66*
    7 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-03-29 19:41:38 $
     7*  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-03-30 00:16:51 $
    99*
    1010*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1818static psS32 test3( void );
    1919static psS32 test4( void );
     20static psS32 test5( void );
     21static psS32 test6( void );
    2022
    2123testDescription tests[] = {
     
    2325                              {test2, -2, "Tests psGrommitAlloc()", 0, false},
    2426                              {test3, -3, "MISC", 0, false},
    25                               {test4, -1, "psPlaneTransformCombineTmp()", 0, false},
     27                              {test4, -1, "psPlaneTransformCombine()", 0, false},
     28                              {test5, -1, "psPlaneTransformFit()", 0, false},
     29                              {test6, -1, "psPlaneTransformInvert()", 0, false},
    2630                              {NULL}
    2731                          };
     
    532536        }
    533537    }
    534 
    535     printf("HERE 00\n");
    536538    psFree(myFPA);
    537     printf("HERE 01\n");
    538539
    539540    return(0);
     
    559560}
    560561
    561 // XXX: This function must verify the outputs.
     562/******************************************************************************
     563XXX: This is only a rudimentary test of the psPlaneTransformCombine()
     564function.  It tests a few NULL input parameter conditions.  Then, it combines
     565two very simply functions and prints the result to the screen.  No values are
     566checked.
     567 
     568// XXX: This function must verify the outputs of the combined functions.
     569 
     570// XXX: Must do: Run thru several combinations of random parameters, then pipe
     571   random x/y values thru both trans1+trans2, as well as the combined function
     572   and verify the output.
     573 *****************************************************************************/
    562574psS32 test4( void )
    563575{
     576    bool testStatus = true;
    564577    psPlaneTransform *trans1 = psPlaneTransformAlloc(2, 2);
    565578    psPlaneTransform *trans2 = psPlaneTransformAlloc(2, 2);
     579    psPlaneTransform *trans3 = NULL;
    566580
    567581    printf("trans1: x = x+y, y = x+y\n");
     
    598612    printTrans(trans2);
    599613
    600 
    601 
    602     psPlaneTransform *trans3 = psPlaneTransformCombine(NULL, trans1, trans2);
    603 
     614    printf("----------------------------------------------------------------------------------\n");
     615    printf("Calling psPlaneTransformCombine with NULL trans1.  Should generate error and return NULL.\n");
     616    trans3 = psPlaneTransformCombine(NULL, NULL, trans2);
     617    if (trans3 != NULL) {
     618        printf("TEST ERROR: psPlaneTransformCombine() returned a non-NULL psPlaneTransform.\n");
     619        testStatus = false;
     620        psFree(trans3);
     621    }
     622
     623    printf("----------------------------------------------------------------------------------\n");
     624    printf("Calling psPlaneTransformCombine with NULL trans2.  Should generate error and return NULL.\n");
     625    trans3 = psPlaneTransformCombine(NULL, trans1, NULL);
     626    if (trans3 != NULL) {
     627        printf("TEST ERROR: psPlaneTransformCombine() returned a non-NULL psPlaneTransform.\n");
     628        testStatus = false;
     629        psFree(trans3);
     630    }
     631
     632
     633    printf("----------------------------------------------------------------------------------\n");
     634    printf("Calling psPlaneTransformCombine with acceptable data.\n");
     635    trans3 = psPlaneTransformCombine(NULL, trans1, trans2);
     636    if (trans3 == NULL) {
     637        printf("TEST ERROR: psPlaneTransformCombine() returned a NULL psPlaneTransform.\n");
     638        testStatus = false;
     639        psFree(trans3);
     640    }
    604641    printf("trans3: \n");
    605642    printTrans(trans3);
     643
    606644    psFree(trans1);
    607645    psFree(trans2);
    608646    psFree(trans3);
    609     return(0);
     647
     648    return(!testStatus);
     649}
     650
     651#define NUM_DATA 100
     652
     653/******************************************************************************
     654XXX: This is only a rudimentary test of the psPlaneTransformFit() function.
     655It tests a few NULL input parameter conditions.
     656 
     657XXX: We call it with acceptable data, but we do not verify the output.
     658 *****************************************************************************/
     659psS32 test5( void )
     660{
     661    bool testStatus = true;
     662    psPlaneTransform *trans = psPlaneTransformAlloc(2, 2);
     663    psArray *src = psArrayAlloc(NUM_DATA);
     664    psArray *dst = psArrayAlloc(NUM_DATA);
     665    bool rc;
     666
     667    for (psS32 i = 0 ; i < NUM_DATA ; i++) {
     668        src->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32);
     669        dst->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32);
     670        ((psVector *) src->data[i])->data.F32[0] = (psF32) i;
     671        ((psVector *) src->data[i])->data.F32[1] = (psF32) i;
     672        ((psVector *) dst->data[i])->data.F32[0] = (psF32) 2+i;
     673        ((psVector *) dst->data[i])->data.F32[1] = (psF32) 3+i;
     674    }
     675
     676    printf("----------------------------------------------------------------------------------\n");
     677    printf("Calling psPlaneTransformFit with NULL trans.  Should generate error and return NULL.\n");
     678    rc = psPlaneTransformFit(NULL, src, dst, 100, 100.0);
     679    if (rc == true) {
     680        printf("TEST ERROR: psPlaneTransformFit() returned TRUE.\n");
     681        testStatus = false;
     682    }
     683
     684    printf("----------------------------------------------------------------------------------\n");
     685    printf("Calling psPlaneTransformFit with NULL src psArray.  Should generate error and return NULL.\n");
     686    rc = psPlaneTransformFit(trans, NULL, dst, 100, 100.0);
     687    if (rc == true) {
     688        printf("TEST ERROR: psPlaneTransformFit() returned TRUE.\n");
     689        testStatus = false;
     690    }
     691
     692    printf("----------------------------------------------------------------------------------\n");
     693    printf("Calling psPlaneTransformFit with NULL dst psArray.  Should generate error and return NULL.\n");
     694    rc = psPlaneTransformFit(trans, src, NULL, 100, 100.0);
     695    if (rc == true) {
     696        printf("TEST ERROR: psPlaneTransformFit() returned TRUE.\n");
     697        testStatus = false;
     698    }
     699
     700    printf("----------------------------------------------------------------------------------\n");
     701    printf("Calling psPlaneTransformFit with acceptable data.\n");
     702    rc = psPlaneTransformFit(trans, src, dst, 100, 100.0);
     703    if (rc != true) {
     704        printf("TEST ERROR: psPlaneTransformFit() returned TRUE.\n");
     705        testStatus = false;
     706    }
     707
     708    psFree(trans);
     709    psFree(src);
     710    psFree(dst);
     711    return(!testStatus);
     712}
     713
     714/******************************************************************************
     715XXX: This is only a rudimentary test of the psPlaneTransform()
     716function.  It tests a few NULL input parameter conditions.
     717 
     718XXX: We call it with acceptable data, but we do not verify the output.
     719 *****************************************************************************/
     720psS32 test6( void )
     721{
     722    bool testStatus = true;
     723    psPlaneTransform *trans = psPlaneTransformAlloc(2, 2);
     724    psPlaneTransform *transOut = NULL;
     725    psRegion *myRegion = psRegionAlloc(1.0, 5.0, 1.0, 5.0);
     726
     727    //
     728    // Set non-linear transformation
     729    //
     730    trans->x->coeff[0][0] = 1.0;
     731    trans->x->coeff[0][1] = 1.0;
     732    trans->x->coeff[1][0] = 1.0;
     733    trans->x->coeff[1][1] = 1.0;
     734    trans->y->coeff[0][0] = 1.0;
     735    trans->y->coeff[0][1] = 1.0;
     736    trans->y->coeff[1][0] = 1.0;
     737    trans->y->coeff[1][1] = 1.0;
     738
     739    printf("----------------------------------------------------------------------------------\n");
     740    printf("Calling psPlaneTransformInvert with NULL trans.  Should generate error and return NULL.\n");
     741    transOut = psPlaneTransformInvert(NULL, NULL, myRegion, 10);
     742    if (transOut != NULL) {
     743        printf("TEST ERROR: psPlaneTransformInvert() returned a non-NULL psPlaneTransform.\n");
     744        testStatus = false;
     745        psFree(transOut);
     746    }
     747
     748    printf("----------------------------------------------------------------------------------\n");
     749    printf("Calling psPlaneTransformInvert with NULL psRegion.  Should generate error and return NULL.\n");
     750    transOut = psPlaneTransformInvert(NULL, trans, NULL, 10);
     751    if (transOut != NULL) {
     752        printf("TEST ERROR: psPlaneTransformInvert() returned a non-NULL psPlaneTransform.\n");
     753        testStatus = false;
     754        psFree(transOut);
     755    }
     756    printf("----------------------------------------------------------------------------------\n");
     757    printf("Calling psPlaneTransformInvert with zero nSamples.  Should generate error and return NULL.\n");
     758    transOut = psPlaneTransformInvert(NULL, trans, myRegion, 0);
     759    if (transOut != NULL) {
     760        printf("TEST ERROR: psPlaneTransformInvert() returned a non-NULL psPlaneTransform.\n");
     761        testStatus = false;
     762        psFree(transOut);
     763    }
     764
     765    printf("----------------------------------------------------------------------------------\n");
     766    printf("Calling psPlaneTransformInvert with acceptable data.\n");
     767    transOut = psPlaneTransformInvert(NULL, trans, myRegion, 10);
     768    if (transOut == NULL) {
     769        printf("TEST ERROR: psPlaneTransformInvert() returned a NULL psPlaneTransform.\n");
     770        testStatus = false;
     771    }
     772
     773    psFree(trans);
     774    psFree(transOut);
     775    psFree(myRegion);
     776
     777    return(!testStatus);
    610778}
    611779//This code is
Note: See TracChangeset for help on using the changeset viewer.