20 #include "ns3/data-rate.h"
22 #include "ns3/simulator.h"
50 void CheckTimesEqual(
Time t1,
Time t2,
const std::string msg);
105 void SingleTest(std::string rate,
size_t nBits,
Time correctTime);
108 void DoRun()
override;
121 CheckTimesEqual(bitsTime, correctTime,
"CalculateBitsTxTime returned incorrect value");
122 if ((nBits % 8) == 0)
125 CheckTimesEqual(bytesTime, correctTime,
"CalculateBytesTxTime returned incorrect value");
132 if (Time::GetResolution() != Time::FS)
134 Time::SetResolution(Time::FS);
141 for (nBits = 0; nBits <= 512; nBits++)
173 void AdditionTest(std::string rate1, std::string rate2, std::string rate3);
180 void SubtractionTest(std::string rate1, std::string rate2, std::string rate3);
197 void DoRun()
override;
239 "DataRate Multiplication with Int returned incorrect value");
242 CheckDataRateEqual(dr1, dr2,
"DataRate Multiplication with Int returned incorrect value");
253 "DataRate Multiplication with Double returned incorrect value");
256 CheckDataRateEqual(dr1, dr2,
"DataRate Multiplication with Double returned incorrect value");
void DoRun() override
Implementation to actually run this TestCase.
void SingleTest(std::string rate, size_t nBits, Time correctTime)
Checks that a given number of bits, at a specified datarate, are corresponding to a given time.
void MultiplicationIntTest(std::string rate1, uint64_t factor, std::string rate2)
Checks data rate integer multiplication.
void DoRun() override
Implementation to actually run this TestCase.
void MultiplicationDoubleTest(std::string rate1, double factor, std::string rate2)
Checks data rate floating point multiplication.
void SubtractionTest(std::string rate1, std::string rate2, std::string rate3)
Checks data rate subtraction.
void AdditionTest(std::string rate1, std::string rate2, std::string rate3)
Checks data rate addition.
~DataRateTestCase() override
void CheckTimesEqual(Time t1, Time t2, const std::string msg)
Checks if two time values are equal.
void CheckDataRateEqual(DataRate d1, DataRate d2, const std::string msg)
Checks if two data rates values are equal.
void DoRun() override=0
Implementation to actually run this TestCase.
DataRateTestCase(std::string name)
Constructor.
Class for representing data rates.
Time CalculateBitsTxTime(uint32_t bits) const
Calculate transmission time.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
int64_t GetFemtoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
High precision numerical type, implementing Q64.64 fixed precision.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time PicoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static DataRateTestSuite sDataRateTestSuite
Static variable for test initialization.