22 #include "ns3/val-array.h"
79 void DoRun()
override;
100 for (uint16_t j = 0; j < v1.
GetNumCols(); ++j)
111 for (uint16_t i = 0; i < v1.
GetNumRows(); ++i)
113 for (uint16_t j = 0; j < v1.
GetNumCols(); ++j)
123 for (uint16_t i = 0; i < v1.
GetNumRows(); ++i)
125 for (uint16_t j = 0; j < v1.
GetNumCols(); ++j)
139 for (uint16_t i = 0; i < v4.
GetNumRows(); ++i)
141 for (uint16_t j = 0; j < v4.
GetNumCols(); ++j)
153 for (uint16_t i = 0; i < v5.
GetNumRows(); ++i)
155 for (uint16_t j = 0; j < v5.
GetNumCols(); ++j)
163 std::valarray<int> initArray1{0, 1, 2, 3, 4, 5, 6, 7};
164 std::valarray<T> valArray1(initArray1.size());
165 for (
size_t i = 0; i < initArray1.size(); i++)
167 valArray1[i] =
static_cast<T
>(initArray1[i]);
172 NS_LOG_INFO(
"valarray1 size before move: " << valArray1.size());
174 NS_LOG_INFO(
"valarray1 size after move: " << valArray1.size());
179 std::valarray<int> initArray2{0, 2, 4, 6, 1, 3, 5, 7};
181 for (uint16_t i = 0; i < v6.
GetNumRows(); ++i)
183 for (uint16_t j = 0; j < v6.
GetNumCols(); ++j)
186 static_cast<T
>(initArray2[testIndex]),
187 "The values are not equal.");
193 std::valarray<int> initArray3{0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7};
194 std::valarray<T> valArray2(initArray3.size());
195 for (
size_t i = 0; i < initArray3.size(); i++)
197 valArray2[i] =
static_cast<T
>(initArray3[i]);
204 std::valarray<int> initArray4{0, 2, 4, 6, 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};
208 for (uint16_t i = 0; i < v7.
GetNumRows(); ++i)
210 for (uint16_t j = 0; j < v7.
GetNumCols(); ++j)
213 static_cast<T
>(initArray4[testIndex]),
214 "The values are not equal.");
224 for (uint16_t i = 0; i < v8.
GetNumRows(); ++i)
226 for (uint16_t j = 0; j < v8.
GetNumCols(); ++j)
230 "The values are not equal");
256 "Arrays should not be equal, they have different dimensions.");
259 v9(0, 0, 0) = v9(0, 0, 0) +
static_cast<T
>(1);
262 "Matrices should be almost equal, but not equal.");
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
ValArray is a class to efficiently store 3D array.
uint16_t GetNumRows() const
uint16_t GetNumCols() const
bool IsAlmostEqual(const ValArray< T > &rhs, T tol) const
Compare Valarray up to a given absolute tolerance.
uint16_t GetNumPages() const
ValArray test case for testing ValArray class.
ValArrayTestCase()=default
Default constructor.
ValArrayTestCase< T > & operator=(const ValArrayTestCase< T > &)=default
Copy assignment operator.
ValArrayTestCase< T > & operator=(ValArrayTestCase< T > &&)=default
Move assignment operator.
void DoRun() override
Implementation to actually run this TestCase.
ValArrayTestSuite()
Constructor.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
static ValArrayTestSuite g_valArrayTestSuite
ValArrayTestSuite instance variable.
Every class exported by the ns3 library is enclosed in the ns3 namespace.