22 #include "ns3/val-array.h"
79 void DoRun()
override;
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};
180 size_t testIndex = 0;
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};
213 static_cast<T
>(initArray4[testIndex]),
214 "The values are not equal.");
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.
bool IsAlmostEqual(const ValArray< T > &rhs, T tol) const
Compare Valarray up to a given absolute tolerance.
size_t GetNumPages() const
size_t GetNumRows() const
size_t GetNumCols() const
ValArray test case for testing ValArray class.
ValArrayTestCase()=default
Default constructor.
ValArrayTestCase< T > & operator=(const ValArrayTestCase< T > &)=default
Copy assignment operator.
ValArrayTestCase(ValArrayTestCase< T > &&)=default
Move constructor.
ValArrayTestCase(const ValArrayTestCase< T > &)=default
Copy constructor.
~ValArrayTestCase() override
Destructor.
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.