Changeset 3471
- Timestamp:
- Mar 21, 2005, 3:36:47 PM (21 years ago)
- Location:
- trunk/psLib/test/astronomy
- Files:
-
- 3 edited
-
tst_psCoord.c (modified) (6 diffs)
-
verified/tst_psCoord.stderr (modified) (1 diff)
-
verified/tst_psCoord.stdout (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astronomy/tst_psCoord.c
r3451 r3471 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-03-18 21:36:16 $ 10 * 11 * XXX: Test with a bad offfset unit type in the SphereGet/SetOffset() functions. 8 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-03-22 01:36:47 $ 12 10 * 13 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 14 12 */ 15 #include "config.h"16 13 17 14 #include "psTest.h" 18 15 #include "pslib.h" 19 static psS32 testSphereTransformAlloc( void);20 static psS32 testPlaneTransformAlloc( void);21 static psS32 testPlaneDistortAlloc( void);22 static psS32 testPlaneTransformApply( void);23 static psS32 testPlaneDistortApply( void);24 static psS32 testSphereTransformApply1( void);25 static psS32 testSphereTransformApply2( void);26 static psS32 testSphereTransformApply3( void);27 static psS32 testSphereTransformApply4( void);28 static psS32 testSphereTransformApply5( void);29 static psS32 testSphereTransformICRSToEcliptic( void);30 static psS32 testSphereTransformEclipticToICRS( void);31 static psS32 testSphereTransformICRSToGalactic( void);32 static psS32 testSphereTransformGalacticToICRS( void);16 static psS32 testSphereTransformAlloc(void); 17 static psS32 testPlaneTransformAlloc(void); 18 static psS32 testPlaneDistortAlloc(void); 19 static psS32 testPlaneTransformApply(void); 20 static psS32 testPlaneDistortApply(void); 21 static psS32 testSphereTransformApply1(void); 22 static psS32 testSphereTransformApply2(void); 23 static psS32 testSphereTransformApply3(void); 24 static psS32 testSphereTransformApply4(void); 25 static psS32 testSphereTransformApply5(void); 26 static psS32 testSphereTransformICRSToEcliptic(void); 27 static psS32 testSphereTransformEclipticToICRS(void); 28 static psS32 testSphereTransformICRSToGalactic(void); 29 static psS32 testSphereTransformGalacticToICRS(void); 33 30 static psS32 testSphereTransformPrecess(void); 34 static psS32 test40( void );35 static psS32 test41( void );36 31 testDescription tests[] = { 37 32 {testSphereTransformAlloc, 819, "psSphereTransformAlloc()", 0, false}, … … 50 45 {testSphereTransformGalacticToICRS, 823, "psSphereTransformGalacticToICRS()", 0, false}, 51 46 {testSphereTransformPrecess, 825, "psSphereTransformPrecess()", 0, false}, 52 {test40, 0000, "psSphereGetOffset()", 0, false},53 {test41, 0000, "psSphereSetOffset()", 0, false},54 47 {NULL} 55 48 }; … … 61 54 return ( ! runTestSuite( stderr, "psCoord", tests, argc, argv ) ); 62 55 } 56 57 #define DEG_INC 30.0 63 58 64 59 #define MJD_1900 15021.0 // Modified Julian Day 1/1/1900 00:00:00 … … 67 62 68 63 #define ERROR_TOL 0.0001 69 70 #define MY_TINY 0.000171 #define PS_COMPARE_TINY_THEN_PRINT_ERROR(ACTUAL, EXPECT, TESTSTATUS) \72 if (MY_TINY < fabs(EXPECT - ACTUAL)) { \73 printf("ERROR: %s is %f, should be %f (testStatus = %d)\n", #ACTUAL, ACTUAL, EXPECT, TESTSTATUS); \74 testStatus = TESTSTATUS; \75 }76 #define MY_TINY 0.000177 #define PS_COMPARE_EPSILON_THEN_PRINT_ERROR(ACTUAL, EXPECT, TESTSTATUS) \78 if (FLT_EPSILON < fabs(EXPECT - ACTUAL)) { \79 printf("ERROR: %s is %f, should be %f (testStatus = %d)\n", #ACTUAL, ACTUAL, EXPECT, TESTSTATUS); \80 testStatus = TESTSTATUS; \81 }82 83 #define PS_COT(X) (1.0 / atan(X))84 float p_psArg(float x,85 float y)86 {87 return((float) atan2((double) x, (double) y));88 }89 64 90 65 #define ALPHA_P 1.0 … … 465 440 } 466 441 467 #define DEG_INC 30.0468 442 // We do a simple identity transformation on a few RA, DEC pairs. 469 443 psS32 testSphereTransformApply1( void ) … … 1379 1353 } 1380 1354 1381 1382 psS32 test40( void )1383 {1384 psS32 testStatus = 0;1385 psSphere position1;1386 psSphere position2;1387 psSphere *offset = NULL;1388 1389 position1.r = DEG_TO_RAD(90.0);1390 position1.d = DEG_TO_RAD(45.0);1391 position1.rErr = 0.0;1392 position1.dErr = 0.0;1393 1394 for (float r=0.0;r<180.0;r+=DEG_INC) {1395 for (float d=0.0;d<90.0;d+=DEG_INC) {1396 position2.r = DEG_TO_RAD(r);1397 position2.d = DEG_TO_RAD(d);1398 position2.rErr = 0.0;1399 position2.dErr = 0.0;1400 1401 offset = psSphereGetOffset(&position1, &position2,1402 PS_SPHERICAL, PS_RADIAN);1403 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2.r - position1.r), 1);1404 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2.d - position1.d), 1);1405 psFree(offset);1406 1407 offset = psSphereGetOffset(&position1, &position2,1408 PS_SPHERICAL, PS_DEGREE);1409 offset->r = DEG_TO_RAD(offset->r);1410 offset->d = DEG_TO_RAD(offset->d);1411 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2.r - position1.r), 2);1412 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2.d - position1.d), 3);1413 psFree(offset);1414 1415 offset = psSphereGetOffset(&position1, &position2,1416 PS_SPHERICAL, PS_ARCMIN);1417 offset->r = MIN_TO_RAD(offset->r);1418 offset->d = MIN_TO_RAD(offset->d);1419 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2.r - position1.r), 2);1420 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2.d - position1.d), 3);1421 psFree(offset);1422 1423 offset = psSphereGetOffset(&position1, &position2,1424 PS_SPHERICAL, PS_ARCSEC);1425 offset->r = SEC_TO_RAD(offset->r);1426 offset->d = SEC_TO_RAD(offset->d);1427 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2.r - position1.r), 2);1428 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2.d - position1.d), 3);1429 psFree(offset);1430 1431 //HEY /* XXX: This code does not work correctly.1432 // printf("--------------- (%f, %f) to (%f, %f) is (%f, %f) ---------------\n",1433 // position1.r, position1.d, position2.r, position2.d,1434 // offset->r, offset->d);1435 // offset = psSphereGetOffset(&position1, &position2, PS_LINEAR, 0);1436 // PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2.r - position1.r), 1);1437 // PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2.d - position1.d), 1);1438 // psFree(offset);1439 }1440 }1441 1442 printf("-------------------------------------------------------------------\n");1443 printf("Calling psSphereGetOffset() with NULL position1. Should generate error, return NULL.\n");1444 offset = psSphereGetOffset(NULL, &position2, PS_LINEAR, 0);1445 if (offset != NULL) {1446 printf("TEST ERROR: psSphereGetOffset() did not return NULL.\n");1447 testStatus = false;1448 offset = NULL;1449 }1450 1451 printf("-------------------------------------------------------------------\n");1452 printf("Calling psSphereGetOffset() with NULL position2. Should generate error, return NULL.\n");1453 offset = psSphereGetOffset(&position1, NULL, PS_LINEAR, 0);1454 if (offset != NULL) {1455 printf("TEST ERROR: psSphereGetOffset() did not return NULL.\n");1456 testStatus = false;1457 offset = NULL;1458 }1459 1460 printf("-------------------------------------------------------------------\n");1461 printf("Calling psSphereGetOffset() with bogus offset mode. Should generate error, return NULL.\n");1462 offset = psSphereGetOffset(&position1, &position2, 0x54321, 0);1463 if (offset != NULL) {1464 printf("TEST ERROR: psSphereGetOffset() did not return NULL.\n");1465 testStatus = false;1466 offset = NULL;1467 }1468 1469 printf("-------------------------------------------------------------------\n");1470 printf("Calling psSphereGetOffset() with bogus offset units. Should generate error, return NULL.\n");1471 offset = psSphereGetOffset(&position1, &position2, PS_SPHERICAL, 0x54321);1472 if (offset != NULL) {1473 printf("TEST ERROR: psSphereGetOffset() did not return NULL.\n");1474 testStatus = false;1475 offset = NULL;1476 }1477 1478 printf("-------------------------------------------------------------------\n");1479 return(testStatus);1480 }1481 1482 psS32 test41( void )1483 {1484 psS32 testStatus = 0;1485 psSphere position1;1486 psSphere *position2;1487 psSphere offset;1488 psSphere tmpOffset;1489 1490 position1.r = DEG_TO_RAD(90.0);1491 position1.d = DEG_TO_RAD(45.0);1492 position1.rErr = 0.0;1493 position1.dErr = 0.0;1494 1495 for (float r=0.0;r<180.0;r+=DEG_INC) {1496 for (float d=0.0;d<90.0;d+=DEG_INC) {1497 offset.r = DEG_TO_RAD(r);1498 offset.d = DEG_TO_RAD(d);1499 offset.rErr = 0.0;1500 offset.dErr = 0.0;1501 1502 position2 = psSphereSetOffset(&position1, &offset,1503 PS_SPHERICAL, PS_RADIAN);1504 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1.r + offset.r), 1);1505 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1.d + offset.d), 2);1506 psFree(position2);1507 1508 tmpOffset.r = RAD_TO_DEG(offset.r);1509 tmpOffset.d = RAD_TO_DEG(offset.d);1510 tmpOffset.rErr = 0.0;1511 tmpOffset.dErr = 0.0;1512 position2 = psSphereSetOffset(&position1, &tmpOffset,1513 PS_SPHERICAL, PS_DEGREE);1514 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1.r + offset.r), 3);1515 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1.d + offset.d), 4);1516 psFree(position2);1517 1518 tmpOffset.r = RAD_TO_MIN(offset.r);1519 tmpOffset.d = RAD_TO_MIN(offset.d);1520 tmpOffset.rErr = 0.0;1521 tmpOffset.dErr = 0.0;1522 position2 = psSphereSetOffset(&position1, &tmpOffset,1523 PS_SPHERICAL, PS_ARCMIN);1524 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1.r + offset.r), 5);1525 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1.d + offset.d), 6);1526 psFree(position2);1527 1528 tmpOffset.r = RAD_TO_SEC(offset.r);1529 tmpOffset.d = RAD_TO_SEC(offset.d);1530 tmpOffset.rErr = 0.0;1531 tmpOffset.dErr = 0.0;1532 position2 = psSphereSetOffset(&position1, &tmpOffset,1533 PS_SPHERICAL, PS_ARCSEC);1534 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1.r + offset.r), 7);1535 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1.d + offset.d), 8);1536 psFree(position2);1537 1538 /* XXX: This code does not work correctly.1539 position2 = psSphereSetOffset(&position1, &offset,1540 PS_LINEAR, 0);1541 printf("--------------- (%f, %f) and (%f, %f) is (%f, %f) ---------------\n",1542 position1.r, position1.d, offset.r, offset.d,1543 position2->r, position2->d);1544 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->r, (position1.r + offset.r), 1);1545 PS_COMPARE_TINY_THEN_PRINT_ERROR(position2->d, (position1.d + offset.d), 1);1546 psFree(position2);1547 */1548 }1549 }1550 1551 printf("-------------------------------------------------------------------\n");1552 printf("Calling psSphereSetOffset() with NULL position1. Should generate error, return NULL.\n");1553 position2 = psSphereSetOffset(NULL, &offset, PS_LINEAR, 0);1554 if (position2 != NULL) {1555 printf("TEST ERROR: psSphereSetOffset() did not return NULL.\n");1556 testStatus = false;1557 position2 = NULL;1558 }1559 1560 printf("-------------------------------------------------------------------\n");1561 printf("Calling psSphereSetOffset() with NULL offset. Should generate error, return NULL.\n");1562 position2 = psSphereSetOffset(&position1, NULL, PS_LINEAR, 0);1563 if (position2 != NULL) {1564 printf("TEST ERROR: psSphereSetOffset() did not return NULL.\n");1565 testStatus = false;1566 position2 = NULL;1567 }1568 1569 printf("-------------------------------------------------------------------\n");1570 printf("Calling psSphereSetOffset() with bogus offset mode. Should generate error, return NULL.\n");1571 position2 = psSphereSetOffset(&position1, &offset, 0x54321, 0);1572 if (position2 != NULL) {1573 printf("TEST ERROR: psSphereSetOffset() did not return NULL.\n");1574 testStatus = false;1575 position2 = NULL;1576 }1577 1578 printf("-------------------------------------------------------------------\n");1579 printf("Calling psSphereSetOffset() with bogus offset unit. Should generate error, return NULL.\n");1580 position2 = psSphereSetOffset(&position1, &offset, PS_SPHERICAL, 0x54321);1581 if (position2 != NULL) {1582 printf("TEST ERROR: psSphereSetOffset() did not return NULL.\n");1583 testStatus = false;1584 position2 = NULL;1585 }1586 1587 printf("-------------------------------------------------------------------\n");1588 return(testStatus);1589 }1590 1591 /******************************************************************************1592 test43(): Not really a test. We simply project many points and print the1593 results.1594 *****************************************************************************/1595 psS32 test43( void )1596 {1597 psS32 testStatus = 0;1598 psSphere projCenter;1599 psSphere startCoords;1600 psPlane *planeCoords;1601 1602 projCenter.r = DEG_TO_RAD(33.0);1603 projCenter.d = DEG_TO_RAD(22.0);1604 projCenter.r = 0.0;1605 projCenter.d = 0.0;1606 // Create the psProjection plane:1607 psProjection myProj;1608 myProj.R = projCenter.r;1609 myProj.D = projCenter.d;1610 myProj.Xs = 1.0;1611 myProj.Ys = 1.0;1612 myProj.type = PS_PROJ_TAN;1613 1614 printf(" projCenter is (%f, %f)\n", projCenter.r, projCenter.d);1615 for (float r=-90.0;r<90.0;r+=DEG_INC/5.0) {1616 for (float d=-90.0;d<90.0;d+=DEG_INC/5.0) {1617 printf("----------------------------------------------------------\n");1618 printf("Angles (R, D) are (%.2f, %.2f)\n", r, d);1619 startCoords.r = DEG_TO_RAD(r);1620 startCoords.d = DEG_TO_RAD(d);1621 1622 planeCoords = psProject(&startCoords, &myProj);1623 printf(" startCoords (R, D) is (%f, %f)\n", startCoords.r, startCoords.d);1624 printf(" plane Coords (X, Y) is (%f, %f)\n", planeCoords->x, planeCoords->y);1625 psFree(planeCoords);1626 }1627 }1628 printf("----------------------------------------------------------\n");1629 return(testStatus);1630 }1631 1632 bool testNonEqualF32(psF32 num1, psF32 num2)1633 {1634 if ((fabs(num1) <= FLT_EPSILON) && (fabs(num2) <= FLT_EPSILON)) {1635 return(false);1636 }1637 1638 if (fabs((num2 - num1) / num1) <= ERROR_PERCENT) {1639 return(false);1640 }1641 return(true);1642 }1643 -
trunk/psLib/test/astronomy/verified/tst_psCoord.stderr
r3432 r3471 226 226 ---> TESTPOINT PASSED (psCoord{psSphereTransformPrecess()} | tst_psCoord.c) 227 227 228 /***************************** TESTPOINT ******************************************\229 * TestFile: tst_psCoord.c *230 * TestPoint: psCoord{psSphereGetOffset()} *231 * TestType: Positive *232 \**********************************************************************************/233 234 <DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)235 Unallowable operation: position1 is NULL.236 <DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)237 Unallowable operation: position2 is NULL.238 <DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)239 Specified offset mode, 0x54321, is not supported.240 <DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)241 Specified units, 0x54321, is not supported.242 243 ---> TESTPOINT PASSED (psCoord{psSphereGetOffset()} | tst_psCoord.c)244 245 /***************************** TESTPOINT ******************************************\246 * TestFile: tst_psCoord.c *247 * TestPoint: psCoord{psSphereSetOffset()} *248 * TestType: Positive *249 \**********************************************************************************/250 251 <DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)252 Unallowable operation: position is NULL.253 <DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)254 Unallowable operation: offset is NULL.255 <DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)256 Specified offset mode, 0x54321, is not supported.257 <DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)258 Specified units, 0x54321, is not supported.259 260 ---> TESTPOINT PASSED (psCoord{psSphereSetOffset()} | tst_psCoord.c)261 -
trunk/psLib/test/astronomy/verified/tst_psCoord.stdout
r3432 r3471 1 -------------------------------------------------------------------2 Calling psSphereGetOffset() with NULL position1. Should generate error, return NULL.3 -------------------------------------------------------------------4 Calling psSphereGetOffset() with NULL position2. Should generate error, return NULL.5 -------------------------------------------------------------------6 Calling psSphereGetOffset() with bogus offset mode. Should generate error, return NULL.7 -------------------------------------------------------------------8 Calling psSphereGetOffset() with bogus offset units. Should generate error, return NULL.9 -------------------------------------------------------------------10 -------------------------------------------------------------------11 Calling psSphereSetOffset() with NULL position1. Should generate error, return NULL.12 -------------------------------------------------------------------13 Calling psSphereSetOffset() with NULL offset. Should generate error, return NULL.14 -------------------------------------------------------------------15 Calling psSphereSetOffset() with bogus offset mode. Should generate error, return NULL.16 -------------------------------------------------------------------17 Calling psSphereSetOffset() with bogus offset unit. Should generate error, return NULL.18 -------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.
