Matrix_Sizing_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 "Matrix_T.hpp"
40 
41 /* Test to check the sizing functions */
43 {
44  gnsstk::TestUtil testFramework("Matrix","Size",__FILE__,__LINE__);
45  std::string failMesg;
46 
48  for(int i = 0; i < 16; i++) v1[i] = i+1;
50  for(int i = 0; i < 16; i++) v2[i] = 16-i;
52  for(int i = 0; i < 4; i++) v3[i] = i+1;
54  for(int i = 0; i < 4; i++) {v4[i] = i+1+4; v4[i+4] = i+1+4;}
55 
56  gnsstk::Matrix<int> a(2,2,1);
57  gnsstk::Matrix<int> b(8, 2, 3);
58  gnsstk::Matrix<int> c(4, 2, 5);
59  gnsstk::Matrix<int> d(4, 4, 7);
60  gnsstk::Matrix<int> e(8, 2, v1);
61  gnsstk::Matrix<int> f(4, 4, v2);
62  gnsstk::Matrix<int> g(2, 2, v3);
63  gnsstk::Matrix<int> h(4, 2, v4);
64 
65  failMesg = "Does the size method function as expected?";
66  testFramework.assert((size_t)4 == a.size(), failMesg, __LINE__);
67 
68  failMesg = "Does the rows method function as expected?";
69  testFramework.assert((size_t)2 == a.rows(), failMesg, __LINE__);
70 
71  failMesg = "Does the cols method function as expected?";
72  testFramework.assert((size_t)2 == a.cols(), failMesg, __LINE__);
73 
74  failMesg = "Does the size method function as expected?";
75  testFramework.assert((size_t)16 == b.size(), failMesg, __LINE__);
76 
77  failMesg = "Does the rows method function as expected?";
78  testFramework.assert((size_t)8 == b.rows(), failMesg, __LINE__);
79 
80  failMesg = "Does the cols method function as expected?";
81  testFramework.assert((size_t)2 == b.cols(), failMesg, __LINE__);
82 
83  failMesg = "Does the size method function as expected?";
84  testFramework.assert((size_t)8 == c.size(), failMesg, __LINE__);
85 
86  failMesg = "Does the rows method function as expected?";
87  testFramework.assert((size_t)4 == c.rows(), failMesg, __LINE__);
88 
89  failMesg = "Does the cols method function as expected?";
90  testFramework.assert((size_t)2 == c.cols(), failMesg, __LINE__);
91 
92  failMesg = "Does the cols method function as expected?";
93  testFramework.assert((size_t)16 == d.size(), failMesg, __LINE__);
94 
95  failMesg = "Does the rows method function as expected?";
96  testFramework.assert((size_t)4 == d.rows(), failMesg, __LINE__);
97 
98  failMesg = "Does the cols method function as expected?";
99  testFramework.assert((size_t)4 == d.cols(), failMesg, __LINE__);
100 
101  failMesg = "Does the cols method function as expected?";
102  testFramework.assert((size_t)16 == e.size(), failMesg, __LINE__);
103 
104  failMesg = "Does the rows method function as expected?";
105  testFramework.assert((size_t)8 == e.rows(), failMesg, __LINE__);
106 
107  failMesg = "Does the cols method function as expected?";
108  testFramework.assert((size_t)2 == e.cols(), failMesg, __LINE__);
109 
110  failMesg = "Does the cols method function as expected?";
111  testFramework.assert((size_t)16 == f.size(), failMesg, __LINE__);
112 
113  failMesg = "Does the rows method function as expected?";
114  testFramework.assert((size_t)4 == f.rows(), failMesg, __LINE__);
115 
116  failMesg = "Does the cols method function as expected?";
117  testFramework.assert((size_t)4 == f.cols(), failMesg, __LINE__);
118 
119  failMesg = "Does the cols method function as expected?";
120  testFramework.assert((size_t)4 == g.size(), failMesg, __LINE__);
121 
122  failMesg = "Does the rows method function as expected?";
123  testFramework.assert((size_t)2 == g.rows(), failMesg, __LINE__);
124 
125  failMesg = "Does the cols method function as expected?";
126  testFramework.assert((size_t)2 == g.cols(), failMesg, __LINE__);
127 
128  failMesg = "Does the cols method function as expected?";
129  testFramework.assert((size_t)8 == h.size(), failMesg, __LINE__);
130 
131  failMesg = "Does the rows method function as expected?";
132  testFramework.assert((size_t)4 == h.rows(), failMesg, __LINE__);
133 
134  failMesg = "Does the cols method function as expected?";
135  testFramework.assert((size_t)2 == h.cols(), failMesg, __LINE__);
136 
137  return testFramework.countFails();
138 }
139 
140 int main()
141 {
142  int check, errorCounter = 0;
143  Matrix_T testClass;
144 
145  check = testClass.sizeTest();
146 
147  std::cout << "Total Failures for " << __FILE__ << ": " << errorCounter << std::endl;
148 
149  return errorCounter; //Return the total number of errors
150 }
gnsstk::TestUtil::countFails
int countFails(void)
Definition: TestUtil.hpp:771
Matrix_T.hpp
gnsstk::TestUtil::assert
void assert(bool testExpression, const std::string &testMsg, const int lineNumber)
Definition: TestUtil.hpp:607
Matrix_T
Definition: Matrix_T.hpp:49
gnsstk::Matrix::cols
size_t cols() const
The number of columns in the matrix.
Definition: Matrix.hpp:167
gnsstk::Matrix::rows
size_t rows() const
The number of rows in the matrix.
Definition: Matrix.hpp:165
main
int main()
Definition: Matrix_Sizing_T.cpp:140
Matrix_T::failMesg
std::string failMesg
Definition: Matrix_T.hpp:145
gnsstk::Matrix::size
size_t size() const
STL size.
Definition: Matrix.hpp:160
gnsstk::Matrix
Definition: Matrix.hpp:72
gnsstk::Vector< int >
gnsstk::TestUtil
Definition: TestUtil.hpp:265
Matrix_T::sizeTest
int sizeTest(void)
Definition: Matrix_Sizing_T.cpp:42


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