IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3472


Ignore:
Timestamp:
Mar 21, 2005, 3:37:31 PM (21 years ago)
Author:
evanalst
Message:

Update test cases for psSphereGetOffset and psSphereSetOffset.

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

Legend:

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

    r3458 r3472  
    66*    @author Eric Van Alst, MHPCC
    77*
    8 *    @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *    @date  $Date: 2005-03-19 02:20:02 $
     8*    @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*    @date  $Date: 2005-03-22 01:37:31 $
    1010*
    1111*    Copyright 2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    2626static psS32 testProjectFail(void);
    2727static psS32 testDeprojectFail(void);
     28static psS32 testSetOffsetSphere(void);
     29static psS32 testSetOffsetLinear(void);
     30static psS32 testGetOffsetSphere(void);
     31static psS32 testGetOffsetLinear(void);
    2832
    2933testDescription tests[] = {
     
    3943                              {testProjectFail, 834, "psProject",0,false},
    4044                              {testDeprojectFail, 835, "psProject",0,false},
     45                              {testSetOffsetSphere, 0000, "psSphereSetOffset",0,false},
     46                              {testSetOffsetLinear, 0000, "psSphereSetOffset",0,false},
     47                              {testGetOffsetSphere, 0000, "psSphereGetOffset",0,false},
     48                              {testGetOffsetLinear, 0000, "psSphereGetOffset",0,false},
    4149                              {NULL}
    4250                          };
    4351
     52
    4453#define ERROR_TOL    0.0001
    4554#define TESTPOINTS   4
     55#define DEG_INC   30.0
     56
     57#define MY_TINY 0.0001
     58#define PS_COMPARE_TINY_THEN_PRINT_ERROR(ACTUAL, EXPECT, TESTSTATUS) \
     59if (MY_TINY < fabs(EXPECT - ACTUAL)) { \
     60    psError(PS_ERR_UNKNOWN,true,"%s is %lg, should be %lg", #ACTUAL, ACTUAL, EXPECT, TESTSTATUS); \
     61    return TESTSTATUS; \
     62}
     63
    4664
    4765//  alpha, delta, alpha-center, delta-center, scale-x, scale-y
     
    84102            {  1.432951,  0.971372 }
    85103        };
     104
     105// Testpoints, offset and expected values for psSphereSetOffset test
     106#define TESTPOINTS_OFFSET  4
     107psF64 setOffsetTestpoint[TESTPOINTS_OFFSET][2] = {
     108            { 0.50,  0.50 },
     109            {-0.50,  0.50 },
     110            { 0.00,  0.00 },
     111            { 1.50, -0.10 }
     112        };
     113
     114psF64 setOffsetOffset[TESTPOINTS_OFFSET][2] = {
     115            { 0.190761, -0.272205 },
     116            {-0.553049, -0.460926 },
     117            { 0.100335,-14.172222 },
     118            {14.172222, -0.100335 }
     119        };
     120
     121psF64 setOffsetResult[TESTPOINTS_OFFSET][2] = {
     122            { 0.25,  0.75 },
     123            { 0.20,  0.80 },
     124            {-0.10,  1.50 },
     125            { 0.00,  0.00 }
     126        };
     127
     128psF64 getOffsetTestpoint1[TESTPOINTS_OFFSET][2] = {
     129            { 0.00,  0.00 },
     130            {-0.25,  0.50 },
     131            { 0.50, -0.25 },
     132            { 0.25, -0.10 }
     133        };
     134
     135psF64 getOffsetTestpoint2[TESTPOINTS_OFFSET][2] = {
     136            { 0.75,  0.25 },
     137            { 0.40, -0.60 },
     138            { 1.50,  0.50 },
     139            { 0.10,  0.75 }
     140        };
     141
     142psF64 getOffsetResult[TESTPOINTS_OFFSET][2] = {
     143            { -0.931596, -0.348976 },
     144            { -1.632830,  2.649629 },
     145            { -2.166795, -1.707211 },
     146            {  0.167752, -1.151351 }
     147        };
     148
    86149
    87150psS32 main( psS32 argc, char* argv[] )
     
    577640}
    578641
     642psS32 testSetOffsetSphere( void )
     643{
     644    psSphere* position1 = psSphereAlloc();
     645    psSphere* position2 = NULL;
     646    psSphere* offset    = psSphereAlloc();
     647    psSphere* tmpOffset = psSphereAlloc();
     648
     649    // Initialize first position
     650    position1->r = DEG_TO_RAD(90.0);
     651    position1->d = DEG_TO_RAD(45.0);
     652    position1->rErr = 0.0;
     653    position1->dErr = 0.0;
     654
     655    //  Using various offset verify spherical offset
     656    //  Use all the valid unit types
     657    for (psF64 r = 0.0; r < 180.0; r += DEG_INC) {
     658        for (psF64 d = 0.0; d < 90.0; d += DEG_INC) {
     659
     660            offset->r = DEG_TO_RAD(r);
     661            offset->d = DEG_TO_RAD(d);
     662            offset->rErr = 0.0;
     663            offset->dErr = 0.0;
     664
     665            position2 = psSphereSetOffset(position1, offset, PS_SPHERICAL, PS_RADIAN);
     666            PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1->r + offset->r), 1);
     667            PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1->d + offset->d), 2);
     668            psFree(position2);
     669
     670            tmpOffset->r = RAD_TO_DEG(offset->r);
     671            tmpOffset->d = RAD_TO_DEG(offset->d);
     672            tmpOffset->rErr = 0.0;
     673            tmpOffset->dErr = 0.0;
     674            position2 = psSphereSetOffset(position1, tmpOffset, PS_SPHERICAL, PS_DEGREE);
     675            PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1->r + offset->r), 3);
     676            PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1->d + offset->d), 4);
     677            psFree(position2);
     678
     679            tmpOffset->r = RAD_TO_MIN(offset->r);
     680            tmpOffset->d = RAD_TO_MIN(offset->d);
     681            tmpOffset->rErr = 0.0;
     682            tmpOffset->dErr = 0.0;
     683            position2 = psSphereSetOffset(position1, tmpOffset, PS_SPHERICAL, PS_ARCMIN);
     684            PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1->r + offset->r), 5);
     685            PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1->d + offset->d), 6);
     686            psFree(position2);
     687
     688            tmpOffset->r = RAD_TO_SEC(offset->r);
     689            tmpOffset->d = RAD_TO_SEC(offset->d);
     690            tmpOffset->rErr = 0.0;
     691            tmpOffset->dErr = 0.0;
     692            position2 = psSphereSetOffset(position1, tmpOffset, PS_SPHERICAL, PS_ARCSEC);
     693            PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1->r + offset->r), 7);
     694            PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1->d + offset->d), 8);
     695            psFree(position2);
     696        }
     697    }
     698
     699    // Attempt to call function with null input coordinate
     700    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message null input coord");
     701    position2 = psSphereSetOffset(NULL, offset, PS_LINEAR, PS_ARCSEC);
     702    if (position2 != NULL) {
     703        psError(PS_ERR_UNKNOWN,true,"Did not return NULL");
     704        return 30;
     705    }
     706
     707    // Attempt to call function with null offset
     708    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message null offset");
     709    position2 = psSphereSetOffset(position1, NULL, PS_LINEAR, PS_ARCSEC);
     710    if (position2 != NULL) {
     711        psError(PS_ERR_UNKNOWN,true,"Did not return NULL");
     712        return 31;
     713    }
     714
     715    // Attempt to call function with invalid mode
     716    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message invalid mode");
     717    position2 = psSphereSetOffset(position1, offset, 0x54321, 0);
     718    if (position2 != NULL) {
     719        psError(PS_ERR_UNKNOWN,true,"Did not return NULL");
     720        return 32;
     721    }
     722
     723    // Attempt to call function with invalid unit
     724    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message invalid unit");
     725    position2 = psSphereSetOffset(position1, offset, PS_SPHERICAL, 0x54321);
     726    if (position2 != NULL) {
     727        psError(PS_ERR_UNKNOWN,true,"Did not return NULL");
     728        return 33;
     729    }
     730
     731    psFree(position1);
     732    psFree(offset);
     733    psFree(tmpOffset);
     734
     735    return 0;
     736}
     737
     738psS32 testSetOffsetLinear(void)
     739{
     740    psSphere*   coord = psSphereAlloc();
     741    psSphere*   offset = psSphereAlloc();
     742    psSphere*   out = NULL;
     743
     744    for(psS32 i = 0; i < TESTPOINTS_OFFSET; i++) {
     745
     746        coord->r = setOffsetTestpoint[i][0];
     747        coord->d = setOffsetTestpoint[i][1];
     748
     749        offset->r = setOffsetOffset[i][0];
     750        offset->d = setOffsetOffset[i][1];
     751
     752        out = psSphereSetOffset(coord, offset, PS_LINEAR, PS_RADIAN);
     753
     754        if(fabs(out->r - setOffsetResult[i][0]) > ERROR_TOL) {
     755            psError(PS_ERR_UNKNOWN,true,"Testpoint %d: Result out->r = %lg not equal to expected %lg",
     756                    i, out->r, setOffsetResult[i][0]);
     757            return i*10;
     758        }
     759        if(fabs(out->d - setOffsetResult[i][1]) > ERROR_TOL) {
     760            psError(PS_ERR_UNKNOWN,true,"Testpoint %d: Result out->d = %lg not equal to expected %lg",
     761                    i,out->d, setOffsetResult[i][1]);
     762            return i*10+1;
     763        }
     764
     765        psFree(out);
     766    }
     767
     768    psFree(coord);
     769    psFree(offset);
     770
     771    return 0;
     772}
     773
     774psS32 testGetOffsetSphere( void )
     775{
     776    psSphere* position1 = psSphereAlloc();
     777    psSphere* position2 = psSphereAlloc();
     778    psSphere *offset = NULL;
     779
     780    position1->r = DEG_TO_RAD(90.0);
     781    position1->d = DEG_TO_RAD(45.0);
     782    position1->rErr = 0.0;
     783    position1->dErr = 0.0;
     784
     785    for (psF64 r = 0.0; r < 180.0;r += DEG_INC) {
     786        for (psF64 d = 0.0;d < 90.0; d += DEG_INC) {
     787            position2->r = DEG_TO_RAD(r);
     788            position2->d = DEG_TO_RAD(d);
     789            position2->rErr = 0.0;
     790            position2->dErr = 0.0;
     791
     792            offset = psSphereGetOffset( position1,  position2,
     793                                        PS_SPHERICAL, PS_RADIAN);
     794            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2->r - position1->r), 1);
     795            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2->d - position1->d), 1);
     796            psFree(offset);
     797
     798            offset = psSphereGetOffset( position1, position2,
     799                                        PS_SPHERICAL, PS_DEGREE);
     800            offset->r = DEG_TO_RAD(offset->r);
     801            offset->d = DEG_TO_RAD(offset->d);
     802            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2->r - position1->r), 2);
     803            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2->d - position1->d), 3);
     804            psFree(offset);
     805
     806            offset = psSphereGetOffset( position1,  position2,
     807                                        PS_SPHERICAL, PS_ARCMIN);
     808            offset->r = MIN_TO_RAD(offset->r);
     809            offset->d = MIN_TO_RAD(offset->d);
     810            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2->r - position1->r), 2);
     811            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2->d - position1->d), 3);
     812            psFree(offset);
     813
     814            offset = psSphereGetOffset( position1,  position2,
     815                                        PS_SPHERICAL, PS_ARCSEC);
     816            offset->r = SEC_TO_RAD(offset->r);
     817            offset->d = SEC_TO_RAD(offset->d);
     818            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2->r - position1->r), 2);
     819            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2->d - position1->d), 3);
     820            psFree(offset);
     821        }
     822    }
     823
     824    // Attempt to invoke function with null position 1 parameter
     825    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for null position");
     826    offset = psSphereGetOffset(NULL, position2, PS_LINEAR, 0);
     827    if (offset != NULL) {
     828        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected");
     829        return 10;
     830    }
     831
     832    // Attempt to invoke function with null position 2 parameter
     833    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for null position");
     834    offset = psSphereGetOffset(position1, NULL, PS_LINEAR, 0);
     835    if (offset != NULL) {
     836        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected");
     837        return 11;
     838    }
     839
     840    // Attempt to invoke function with invalid mode
     841    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid mode");
     842    offset = psSphereGetOffset(position1, position2, 0x54321, 0);
     843    if (offset != NULL) {
     844        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected");
     845        return 12;
     846    }
     847
     848    // Attempt to invoke function with invalid unit type
     849    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid unit type");
     850    offset = psSphereGetOffset(position1, position2, PS_SPHERICAL, 0x54321);
     851    if (offset != NULL) {
     852        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected");
     853        return 13;
     854    }
     855
     856    // Attempt to invoke function with coordinate 1 declination value 90.0 degree
     857    position1->d = DEG_TO_RAD(90.0);
     858    psLogMsg(__func__,PS_LOG_INFO,"Following should generate warning message");
     859    offset = psSphereGetOffset(position1, position2, PS_SPHERICAL, PS_RADIAN);
     860    if (offset != NULL) {
     861        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected");
     862        return 14;
     863    }
     864
     865    // Attempt to invoke function with coordinate 2 declination value 90.0 degree
     866    position1->d = DEG_TO_RAD(45.0);
     867    position2->d = DEG_TO_RAD(90.0);
     868    psLogMsg(__func__,PS_LOG_INFO,"Following should generate warning message");
     869    offset = psSphereGetOffset(position1, position2, PS_SPHERICAL, PS_RADIAN);
     870    if (offset != NULL) {
     871        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected");
     872        return 15;
     873    }
     874
     875    psFree(position1);
     876    psFree(position2);
     877
     878    return 0;
     879}
     880
     881psS32 testGetOffsetLinear(void)
     882{
     883    psSphere*   coord1 = psSphereAlloc();
     884    psSphere*   coord2 = psSphereAlloc();
     885    psSphere*   out = NULL;
     886
     887    for(psS32 i = 0; i < TESTPOINTS_OFFSET; i++) {
     888
     889        coord1->r = getOffsetTestpoint1[i][0];
     890        coord1->d = getOffsetTestpoint1[i][1];
     891
     892        coord2->r = getOffsetTestpoint2[i][0];
     893        coord2->d = getOffsetTestpoint2[i][1];
     894
     895        out = psSphereGetOffset(coord1, coord2, PS_LINEAR, PS_RADIAN);
     896
     897        if(fabs(out->r - getOffsetResult[i][0]) > ERROR_TOL) {
     898            psError(PS_ERR_UNKNOWN,true,"Testpoint %d: Result out->r = %lg not equal to expected %lg",
     899                    i, out->r, getOffsetResult[i][0]);
     900            return i*10;
     901        }
     902        if(fabs(out->d - getOffsetResult[i][1]) > ERROR_TOL) {
     903            psError(PS_ERR_UNKNOWN,true,"Testpoint %d: Result out->d = %lg not equal to expected %lg",
     904                    i,out->d, getOffsetResult[i][1]);
     905            return i*10+1;
     906        }
     907
     908        psFree(out);
     909    }
     910
     911    psFree(coord1);
     912    psFree(coord2);
     913
     914    return 0;
     915}
     916
     917
  • trunk/psLib/test/astronomy/verified/tst_psCoord01.stderr

    r3452 r3472  
    122122---> TESTPOINT PASSED (psCoord{psProject} | tst_psCoord01.c)
    123123
     124/***************************** TESTPOINT ******************************************\
     125*             TestFile: tst_psCoord01.c                                            *
     126*            TestPoint: psCoord{psSphereSetOffset}                                 *
     127*             TestType: Positive                                                   *
     128\**********************************************************************************/
     129
     130<DATE><TIME>|<HOST>|I|testSetOffsetSphere
     131    Following should generate error message null input coord
     132<DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)
     133    Unallowable operation: position is NULL.
     134<DATE><TIME>|<HOST>|I|testSetOffsetSphere
     135    Following should generate error message null offset
     136<DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)
     137    Unallowable operation: offset is NULL.
     138<DATE><TIME>|<HOST>|I|testSetOffsetSphere
     139    Following should generate error message invalid mode
     140<DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)
     141    Specified offset mode, 0x54321, is not supported.
     142<DATE><TIME>|<HOST>|I|testSetOffsetSphere
     143    Following should generate an error message invalid unit
     144<DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)
     145    Specified units, 0x54321, is not supported.
     146
     147---> TESTPOINT PASSED (psCoord{psSphereSetOffset} | tst_psCoord01.c)
     148
     149/***************************** TESTPOINT ******************************************\
     150*             TestFile: tst_psCoord01.c                                            *
     151*            TestPoint: psCoord{psSphereSetOffset}                                 *
     152*             TestType: Positive                                                   *
     153\**********************************************************************************/
     154
     155
     156---> TESTPOINT PASSED (psCoord{psSphereSetOffset} | tst_psCoord01.c)
     157
     158/***************************** TESTPOINT ******************************************\
     159*             TestFile: tst_psCoord01.c                                            *
     160*            TestPoint: psCoord{psSphereGetOffset}                                 *
     161*             TestType: Positive                                                   *
     162\**********************************************************************************/
     163
     164<DATE><TIME>|<HOST>|I|testGetOffsetSphere
     165    Following should generate an error message for null position
     166<DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)
     167    Unallowable operation: position1 is NULL.
     168<DATE><TIME>|<HOST>|I|testGetOffsetSphere
     169    Following should generate an error message for null position
     170<DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)
     171    Unallowable operation: position2 is NULL.
     172<DATE><TIME>|<HOST>|I|testGetOffsetSphere
     173    Following should generate an error message for invalid mode
     174<DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)
     175    Specified offset mode, 0x54321, is not supported.
     176<DATE><TIME>|<HOST>|I|testGetOffsetSphere
     177    Following should generate an error message for invalid unit type
     178<DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)
     179    Specified units, 0x54321, is not supported.
     180<DATE><TIME>|<HOST>|I|testGetOffsetSphere
     181    Following should generate warning message
     182<DATE><TIME>|<HOST>|W|psSphereGetOffset
     183    WARNING: psDeproject(): position1->d is larger than 90 degrees.  Returning NULL.
     184<DATE><TIME>|<HOST>|I|testGetOffsetSphere
     185    Following should generate warning message
     186<DATE><TIME>|<HOST>|W|psSphereGetOffset
     187    WARNING: psDeproject(): position2->d is larger than 90 degrees.  Returning NULL.
     188
     189---> TESTPOINT PASSED (psCoord{psSphereGetOffset} | tst_psCoord01.c)
     190
     191/***************************** TESTPOINT ******************************************\
     192*             TestFile: tst_psCoord01.c                                            *
     193*            TestPoint: psCoord{psSphereGetOffset}                                 *
     194*             TestType: Positive                                                   *
     195\**********************************************************************************/
     196
     197
     198---> TESTPOINT PASSED (psCoord{psSphereGetOffset} | tst_psCoord01.c)
     199
Note: See TracChangeset for help on using the changeset viewer.