TimeSystem_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 
39 #include "TimeSystem.hpp"
40 #include "TestUtil.hpp"
41 #include <iostream>
42 #include <sstream>
43 #include <cmath>
44 
46 {
47 public:
48  unsigned operatorTest()
49  {
50  TUDEF("TimeSystem", "operator<<");
51  std::string testMesg;
52 
54 
55  //Does operator<< function correctly?
56  std::string outputString, compareString;
57  std::stringstream outputStream;
58  outputStream << compare;
59  outputString = outputStream.str();
60  compareString = "GAL";
61  TUASSERTE(std::string, compareString, outputString);
62 
63  TURETURN();
64  }
65 
66 
67  unsigned getLeapSecondsTest()
68  {
69  TUDEF("TimeSystem", "getLeapSeconds");
70 
71  //Check leap-second computation prior to 1972 but not before 1960
72 
73  //Should be (inputDate - lastRefDate) * rate + leapSeconds
74  //4.213170+488*0.002592
75  TUASSERTFE(5.478066, gnsstk::getLeapSeconds(1969, 6, 3));
76  //1.8458580 + 118*0.0011232
77  TUASSERTFE(1.9783956, gnsstk::getLeapSeconds(1962, 4, 29));
78  //3.6401300 + 5*.001296
79  TUASSERTFE(3.64661, gnsstk::getLeapSeconds(1965, 3, 6));
80  //4.2131700 + 295*.002592
81  TUASSERTFE(4.97781, gnsstk::getLeapSeconds(1968, 11, 22));
82  //4.3131700 + 409*.002592
83  TUASSERTFE(5.373298, gnsstk::getLeapSeconds(1967, 2, 14));
84 
85  //Check leap-second computation after 1/1/1972
86  TUASSERTFE(29, gnsstk::getLeapSeconds(1995, 10, 13));
87  TUASSERTFE(32, gnsstk::getLeapSeconds(2004, 3, 25));
88  TUASSERTFE(22, gnsstk::getLeapSeconds(1984, 8, 27));
89  TUASSERTFE(10, gnsstk::getLeapSeconds(1972, 5, 8));
90 
91  TURETURN();
92  }
93 
94 
95  unsigned correctionTest()
96  {
97  TUDEF("TimeSystem", "getTimeSystemCorrection");
98 
99  //Check conversion from any given time system to UTC and back
106 
107  // QZSS can't be converted
108  //testMesg = "Conversion from UTC time to QZS time was incorrect";
109  //testFramework.assert(std::abs(gnsstk::getTimeSystemCorrection(gnsstk::TimeSystem::UTC, gnsstk::TimeSystem::QZS, 1985, 8, 10) - 4) < eps, testMesg, __LINE__);
110  //testMesg = "Conversion from QZS time to UTC time was incorrect";
111  //testFramework.assert(std::abs(gnsstk::getTimeSystemCorrection(gnsstk::TimeSystem::QZS, gnsstk::TimeSystem::UTC, 2010, 2, 14) - 15) < eps, testMesg, __LINE__);
112 
121  //reference section B of astronomical almanac for TDB conversion
122  TUASSERTFE(65.1840299405112091335467994213104248046875,
124  TUASSERTFE(-58.1838658094272460630236309953033924102783203125,
126 
127  TURETURN();
128  }
129 };
130 
131 
132 int main() //Main function to initialize and run all tests above
133 {
134  TimeSystem_T testClass;
135  unsigned errorCounter = 0;
136 
137  errorCounter += testClass.operatorTest();
138  errorCounter += testClass.getLeapSecondsTest();
139  errorCounter += testClass.correctionTest();
140 
141  std::cout << "Total Failures for " << __FILE__ << ": " << errorCounter
142  << std::endl;
143 
144  return errorCounter; //Return the total number of errors
145 }
gnsstk::TimeSystem::TT
@ TT
Terrestrial time (used in IERS conventions)
TimeSystem.hpp
TimeSystem_T
Definition: TimeSystem_T.cpp:45
TimeSystem_T::operatorTest
unsigned operatorTest()
Definition: TimeSystem_T.cpp:48
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
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
gnsstk::TimeSystem::IRN
@ IRN
IRNSS system Time.
gnsstk::TimeSystem::GAL
@ GAL
Galileo system time.
TimeSystem_T::getLeapSecondsTest
unsigned getLeapSecondsTest()
Definition: TimeSystem_T.cpp:67
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
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)
main
int main()
Definition: TimeSystem_T.cpp:132
gnsstk::TimeSystem::GPS
@ GPS
GPS system time.
TimeSystem_T::correctionTest
unsigned correctionTest()
Definition: TimeSystem_T.cpp:95
TUASSERTFE
#define TUASSERTFE(EXP, GOT)
Definition: TestUtil.hpp:103
gnsstk::getLeapSeconds
double getLeapSeconds(const int year, const int month, const double day)
Definition: TimeSystem.cpp:53
gnsstk::getTimeSystemCorrection
double getTimeSystemCorrection(const TimeSystem inTS, const TimeSystem outTS, const int year, const int month, const double day)
Definition: TimeSystem.cpp:181
gnsstk::TimeSystem::BDT
@ BDT
BeiDou system Time.


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