BasicTimeSystemConverter_T.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
40 #include "TestUtil.hpp"
41 #include "CivilTime.hpp"
42 #include <iostream>
43 #include <sstream>
44 #include <cmath>
45 
47 {
48 public:
49  unsigned getOffsetTest()
50  {
51  TUDEF("TimeSystemConverter", "getOffset");
52  double offs;
54 
55  //Check conversion from any given time system to UTC and back
58  gnsstk::CivilTime(1990,11,6),
59  offs));
60  TUASSERTFE(6, offs);
61 
64  gnsstk::CivilTime(2004, 11, 16),
65  offs));
66  TUASSERTFE(-13, offs);
67 
70  gnsstk::CivilTime(1992, 10, 3),
71  offs));
72  TUASSERTFE(0, offs);
73 
76  gnsstk::CivilTime(1995, 5, 10),
77  offs));
78  TUASSERTFE(0, offs);
79 
82  gnsstk::CivilTime(1997, 7, 25),
83  offs));
84  TUASSERTFE(12, offs);
85 
88  gnsstk::CivilTime(2008, 6, 5),
89  offs));
90  TUASSERTFE(-14, offs);
91 
94  gnsstk::CivilTime(1985, 8, 10),
95  offs));
96  TUASSERTFE(4, offs);
97 
100  gnsstk::CivilTime(2010, 2, 14),
101  offs));
102  TUASSERTFE(15, offs);
103 
106  gnsstk::CivilTime(2006, 9, 21),
107  offs));
108  TUASSERTFE(0, offs);
109 
112  gnsstk::CivilTime(2012, 8, 27),
113  offs));
114  TUASSERTFE(-2, offs);
115 
118  gnsstk::CivilTime(2004, 11, 16),
119  offs));
120  TUASSERTFE(13, offs);
121 
124  gnsstk::CivilTime(2004, 11, 16),
125  offs));
126  TUASSERTFE(-13, offs);
127 
130  gnsstk::CivilTime(2014, 6, 1),
131  offs));
132  TUASSERTFE(35, offs);
133 
136  gnsstk::CivilTime(2015, 1, 1),
137  offs));
138  TUASSERTFE(-35, offs);
139 
142  gnsstk::CivilTime(2005, 4, 31),
143  offs));
144  TUASSERTFE(13 + 51.184, offs);
145 
146  TUASSERTE(bool, true, btsc.getOffset(gnsstk::TimeSystem::TT,
148  gnsstk::CivilTime(1990, 7, 21),
149  offs));
150  TUASSERTFE(-(6 + 51.184), offs);
151 
152  //reference section B of astronomical almanac for TDB conversion
155  gnsstk::CivilTime(2007, 12, 25),
156  offs));
157  TUASSERTFE(65.1840299405112091335467994213104248046875,
158  offs);
159 
162  gnsstk::CivilTime(1991, 4, 25),
163  offs));
164  TUASSERTFE(-58.1838658094272460630236309953033924102783203125,
165  offs);
166 
167  TURETURN();
168  }
169 };
170 
171 
172 int main() //Main function to initialize and run all tests above
173 {
174  BasicTimeSystemConverter_T testClass;
175  unsigned errorCounter = 0;
176 
177  errorCounter += testClass.getOffsetTest();
178 
179  std::cout << "Total Failures for " << __FILE__ << ": " << errorCounter
180  << std::endl;
181 
182  return errorCounter; //Return the total number of errors
183 }
gnsstk::TimeSystem::TT
@ TT
Terrestrial time (used in IERS conventions)
BasicTimeSystemConverter_T
Definition: BasicTimeSystemConverter_T.cpp:46
gnsstk::TimeSystem::TAI
@ TAI
International Atomic Time.
TUASSERTE
#define TUASSERTE(TYPE, EXP, GOT)
Definition: TestUtil.hpp:81
gnsstk::TimeSystem::TDB
@ TDB
Barycentric dynamical time (JPL ephemeris); very near TT.
TestUtil.hpp
BasicTimeSystemConverter.hpp
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
gnsstk::TimeSystem::IRN
@ IRN
IRNSS system Time.
gnsstk::TimeSystem::QZS
@ QZS
QZSS system Time.
gnsstk::TimeSystem::GAL
@ GAL
Galileo system time.
CivilTime.hpp
BasicTimeSystemConverter_T::getOffsetTest
unsigned getOffsetTest()
Definition: BasicTimeSystemConverter_T.cpp:49
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
gnsstk::TimeSystem::GLO
@ GLO
GLONASS system time (aka UTC(SU))
gnsstk::TimeSystem::UTC
@ UTC
Coordinated Universal Time (e.g., from NTP)
gnsstk::CivilTime
Definition: CivilTime.hpp:55
gnsstk::BasicTimeSystemConverter
Definition: BasicTimeSystemConverter.hpp:51
gnsstk::TimeSystem::GPS
@ GPS
GPS system time.
TUASSERTFE
#define TUASSERTFE(EXP, GOT)
Definition: TestUtil.hpp:103
gnsstk::BasicTimeSystemConverter::getOffset
bool getOffset(TimeSystem fromSys, TimeSystem toSys, const CommonTime &t, double &offs) override
Definition: BasicTimeSystemConverter.cpp:45
gnsstk::TimeSystem::BDT
@ BDT
BeiDou system Time.
main
int main()
Definition: BasicTimeSystemConverter_T.cpp:172


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:38