SVNumXRef_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  /*********************************************************************
40 *
41 * Test program for gnsstk/core/lib/GNSSCore/SVNumXRef.
42 * The last line of output will calculate how many tests fail.
43 *
44 *********************************************************************/
45 #include <iostream>
46 #include <cmath>
47 
48 #include "CivilTime.hpp"
49 #include "SVNumXRef.hpp"
50 
51 #include "TestUtil.hpp"
52 
53 using namespace gnsstk;
54 
55 int main()
56 {
57  TUDEF("SVNumXRef", "");
58 
59  SVNumXRef svNumXRef;
60 
61  //Test for overlap in SVN/PRN active time range(s)
62  //output 0 for pass; output 1 for any fail
63  testFramework.changeSourceMethod(" isConsistent");
64  TUASSERTE(bool, true, svNumXRef.isConsistent());
65 
66 
67  //Test that correct SVN availablility is given at specific time, given PRN
68  //first statement intended to be true; second intended to be false
69  testFramework.changeSourceMethod(" NAVSTARIDAvailable");
70  TUASSERTE(bool, true, svNumXRef.NAVSTARIDAvailable(8,
71  CivilTime(2015, 10, 1, 0, 0, 0.0, TimeSystem::GPS)));
72  TUASSERTE(bool, false, svNumXRef.NAVSTARIDAvailable(8,
73  CivilTime(2015, 7, 14, 0, 0, 0.0, TimeSystem::GPS)));
74 
75 
76  //Test that correct SVN is returned, given PRN and active time range
77  //try-catch ensures that an exception is thrown for a nonexistent PRN
78  testFramework.changeSourceMethod(" getNAVSTAR");
79  TUASSERTE(int, 72, svNumXRef.getNAVSTAR(8,
80  CivilTime(2015, 10, 1, 0, 0, 0.0, TimeSystem::GPS)));
81  try
82  {
83  svNumXRef.getNAVSTAR(0,
84  CivilTime(2015, 10, 1, 0, 0, 0.0, TimeSystem::GPS));
85  TUFAIL("getNAVSTAR(0) should have failed");
86  }
87  catch( NoNAVSTARNumberFound )
88  {
89  TUPASS("");
90  }
91 
92 
93  //Test that SV is correctly displayed as active, given SVN and active time range
94  //first statement intended to be true; second intended to be false
95  testFramework.changeSourceMethod(" NAVSTARIDActive");
96  TUASSERTE(bool, true, svNumXRef.NAVSTARIDActive(72,
97  CivilTime(2015, 10, 1, 0, 0, 0.0, TimeSystem::GPS)));
98  TUASSERTE(bool, false, svNumXRef.NAVSTARIDActive(72,
99  CivilTime(2015, 7, 14, 0, 0, 0.0, TimeSystem::GPS)));
100 
101 
102  //Test that exception is thrown if BlockType cannot be located for SVN input
103  //try-catch ensures that an exception is thrown for a nonexistent SVN
104  testFramework.changeSourceMethod(" getBlockType");
106  svNumXRef.getBlockType(72));
107  try
108  {
109  svNumXRef.getBlockType(0);
110  TUFAIL("getBlockType(0) should have failed");
111  }
112  catch( NoNAVSTARNumberFound )
113  {
114  TUPASS("");
115  }
116 
117 
118  //Test string output for corresponding block type or unknown if not found
119  testFramework.changeSourceMethod(" getBlockTypeString");
120  TUASSERTE(std::string, "Block IIF", svNumXRef.getBlockTypeString(72));
121  TUASSERTE(std::string, "unknown", svNumXRef.getBlockTypeString(0));
122 
123 
124  //Test that correct PRN is returned, given SVN and active time range
125  testFramework.changeSourceMethod(" getPRNID");
126  TUASSERTE(int, 8, svNumXRef.getPRNID(72,
127  CivilTime(2015, 10, 1, 0, 0, 0.0, TimeSystem::GPS)));
128  try
129  {
130  svNumXRef.getPRNID(0,
131  CivilTime(2015, 10, 1, 0, 0, 0.0, TimeSystem::GPS));
132  TUFAIL("getPRNID(0) did not fail");
133  }
134  catch( NoNAVSTARNumberFound )
135  {
136  TUPASS("");
137  }
138 
139 
140  //Test that SV is correctly displayed as active, given PRN and active time range
141  //first statement intended to be true; second intended to be falst
142  testFramework.changeSourceMethod(" PRNIDAvailable");
143  TUASSERTE(bool, true, svNumXRef.PRNIDAvailable(72,
144  CivilTime(2015, 10, 1, 0, 0, 0.0, TimeSystem::GPS)));
145  TUASSERTE(bool, false, svNumXRef.PRNIDAvailable(72,
146  CivilTime(2015, 7, 14, 0, 0, 0.0, TimeSystem::GPS)));
147 
148 
149  //Test that SVN corresponds to an available block type
150  //first statement intended to be true; second intended to be false
151  testFramework.changeSourceMethod(" BlockTypeAvailable");
152  TUASSERTE(bool, true, svNumXRef.BlockTypeAvailable(72));
153  TUASSERTE(bool, false, svNumXRef.BlockTypeAvailable(0));
154 
155 
156  std::cout << "Total Failures for " << __FILE__ << ": " << testFramework.countFails() << std::endl;
157 
158 
159  return testFramework.countFails();
160 }
gnsstk::SVNumXRef
Definition: SVNumXRef.hpp:141
gnsstk::SVNumXRef::NAVSTARIDActive
bool NAVSTARIDActive(const int NAVSTARID, const gnsstk::CommonTime dt) const
Definition: SVNumXRef.cpp:594
gnsstk::SVNumXRef::PRNIDAvailable
bool PRNIDAvailable(const int NAVSTARID, const gnsstk::CommonTime dt) const
Definition: SVNumXRef.cpp:656
TUASSERTE
#define TUASSERTE(TYPE, EXP, GOT)
Definition: TestUtil.hpp:81
TUFAIL
#define TUFAIL(MSG)
Definition: TestUtil.hpp:228
main
int main()
Definition: SVNumXRef_T.cpp:55
gnsstk::SVNumXRef::getNAVSTAR
int getNAVSTAR(const int PRNID, const gnsstk::CommonTime dt) const
Definition: SVNumXRef.cpp:565
gnsstk::SVNumXRef::getBlockTypeString
std::string getBlockTypeString(const int NAVSTARID) const
Definition: SVNumXRef.cpp:616
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::SVNumXRef::NAVSTARIDAvailable
bool NAVSTARIDAvailable(const int PRNID, const gnsstk::CommonTime dt) const
Definition: SVNumXRef.cpp:584
TestUtil.hpp
SVNumXRef.hpp
TUPASS
#define TUPASS(MSG)
Definition: TestUtil.hpp:230
CivilTime.hpp
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
gnsstk::SVNumXRef::getBlockType
BlockType getBlockType(const int NAVSTARID) const
Definition: SVNumXRef.cpp:599
gnsstk::CivilTime
Definition: CivilTime.hpp:55
gnsstk::TimeSystem::GPS
@ GPS
GPS system time.
gnsstk::SVNumXRef::IIF
@ IIF
Definition: SVNumXRef.hpp:152
gnsstk::SVNumXRef::getPRNID
int getPRNID(const int NAVSTARID, const gnsstk::CommonTime dt) const
Definition: SVNumXRef.cpp:637
gnsstk::SVNumXRef::BlockType
BlockType
Definition: SVNumXRef.hpp:145
gnsstk::SVNumXRef::BlockTypeAvailable
bool BlockTypeAvailable(const int NAVSTARID) const
Definition: SVNumXRef.cpp:666
gnsstk::SVNumXRef::isConsistent
bool isConsistent() const
Definition: SVNumXRef.cpp:753


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