CppEphem
test_CEBody.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * test_CEBody.cpp: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2019 JCardenzana *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 
22 #include "test_CEBody.h"
23 #include "CENamespace.h"
24 
25 
26 /**********************************************************************/
30  CETestSuite()
31 {
32  // Let's use the Crab Nebula
33  base_ = CEBody("Crab", CEAngle::Deg(83.633), CEAngle::Deg(22.0145),
35 }
36 
37 
38 /**********************************************************************/
42 {}
43 
44 
45 /**********************************************************************/
51 {
52  std::cout << "\nTesting CEBody:\n";
53 
54  // Run each of the tests
56  test_Name();
58 
59  return pass();
60 }
61 
62 
63 /**********************************************************************/
69 {
70  // Default coordinates
71  CESkyCoord test1_coord;
72  // Default constructor
73  CEBody test1;
74  test_string(test1.Name(), "undefined", __func__, __LINE__);
75  test(test1.GetCoordinates() == test1_coord, __func__, __LINE__);
76 
77  // Copy constructor
78  test1.SetName("test1");
79  test1.SetCoordinates(12.345, 67.89);
80  CEBody test2(test1);
81  test_string(test2.Name(), test1.Name(), __func__, __LINE__);
82  test((test2.GetCoordinates() == test1.GetCoordinates()), __func__, __LINE__);
83 
84  // Copy assignment operator
85  CEBody test3 = test1;
86  test_string(test3.Name(), test1.Name(), __func__, __LINE__);
87  test((test3.GetCoordinates() == test1.GetCoordinates()), __func__, __LINE__);
88 
89  // Basic constructor
90  CEBody test4(test1.Name(),
91  test1.XCoord(), test1.YCoord(),
92  test1.GetCoordSystem());
93  test_string(test4.Name(), test1.Name(), __func__, __LINE__);
94  test(test4.GetCoordinates() == test1.GetCoordinates(), __func__, __LINE__);
95 
96  return pass();
97 }
98 
99 
100 /**********************************************************************/
106 {
107  // Check that we can get the name
108  test_string(base_.Name(), "Crab", __func__, __LINE__);
109 
110  // Check that we can set the name
111  CEBody test_body(base_);
112  std::string new_name = "NotCrab";
113  test_body.SetName(new_name);
114  test_string(test_body.Name(), new_name, __func__, __LINE__);
115 
116  return pass();
117 }
118 
119 
120 /**********************************************************************/
126 {
127  // Test getting the coordinates
128  CESkyCoord test_coords = base_.GetCoordinates();
129 
130  // Test that the coordinates are equal
131  test_bool(test_coords == base_, true, __func__, __LINE__);
132 
133  return pass();
134 }
135 
136 
137 /**********************************************************************/
140 int main(int argc, char** argv)
141 {
142  test_CEBody tester;
143  return (!tester.runtests());
144 }
test_CEBody::test_construct
virtual bool test_construct(void)
Test the various constructor methods.
Definition: test_CEBody.cpp:68
CESkyCoordType::ICRS
RA, Dec (referenced at the barycenter of the solarsystem)
CENamespace.h
test_CEBody::test_CEBody
test_CEBody()
Default constructor.
Definition: test_CEBody.cpp:29
CESkyCoord
Definition: CESkyCoord.h:49
test_CEBody
Definition: test_CEBody.h:27
CEBody::GetCoordinates
virtual CESkyCoord GetCoordinates(const CEDate &date=CEDate::CurrentJD()) const
Return the ICRS coordinates associated with this object.
Definition: CEBody.h:121
test_CEBody::base_
CEBody base_
Definition: test_CEBody.h:60
CESkyCoord::GetCoordSystem
CESkyCoordType GetCoordSystem(void) const
Return coordinate system.
Definition: CESkyCoord.h:251
test_CEBody.h
test_CEBody::test_Name
virtual bool test_Name(void)
Test getting the CEBody object's name.
Definition: test_CEBody.cpp:105
CEBody::Name
std::string Name(void) const
Get the name of this object.
Definition: CEBody.h:95
test_CEBody::test_GetCoordinates
virtual bool test_GetCoordinates(void)
Run tests.
Definition: test_CEBody.cpp:125
test_CEBody::~test_CEBody
virtual ~test_CEBody()
Destructor.
Definition: test_CEBody.cpp:41
main
int main(int argc, char **argv)
Main method that actually runs the tests.
Definition: test_CEBody.cpp:140
test_CEBody::runtests
virtual bool runtests()
Run tests.
Definition: test_CEBody.cpp:50
CEBody::SetName
void SetName(const std::string &new_name)
Set the name of this object.
Definition: CEBody.h:106
CEAngle::Deg
double Deg(void) const
Return angle in degrees as a double.
Definition: CEAngle.cpp:328
CEBody
Definition: CEBody.h:39
CESkyCoord::SetCoordinates
virtual void SetCoordinates(const CEAngle &xcoord, const CEAngle &ycoord, const CESkyCoordType &coord_type=CESkyCoordType::ICRS) const
Set the coordinates of this object.
Definition: CESkyCoord.cpp:1000
CESkyCoord::XCoord
virtual CEAngle XCoord(const CEDate &jd=CppEphem::julian_date_J2000()) const
Return x coordinate at given Julian date.
Definition: CESkyCoord.h:227
CESkyCoord::YCoord
virtual CEAngle YCoord(const CEDate &jd=CppEphem::julian_date_J2000()) const
Return y coordinate at given Julian date.
Definition: CESkyCoord.h:240