21 #include "ns3/data-rate.h"
24 #include "ns3/simulator.h"
51 void CheckTimesEqual (
Time t1,
Time t2,
const std::string msg);
105 void SingleTest (std::string rate,
size_t nBits,
Time correctTime);
108 virtual void DoRun (
void);
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 virtual void DoRun (
void);
237 CheckDataRateEqual(dr1 * factor, dr2,
"DataRate Multiplication with Int returned incorrect value");
240 CheckDataRateEqual(dr1, dr2,
"DataRate Multiplication with Int returned incorrect value");
249 CheckDataRateEqual(dr1 * factor, dr2,
"DataRate Multiplication with Double returned incorrect value");
252 CheckDataRateEqual(dr1, dr2,
"DataRate Multiplication with Double returned incorrect value");
virtual void DoRun(void)
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 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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AdditionTest(std::string rate1, std::string rate2, std::string rate3)
Checks data rate addition.
void CheckTimesEqual(Time t1, Time t2, const std::string msg)
Checks if two time values are equal.
virtual ~DataRateTestCase()
void CheckDataRateEqual(DataRate d1, DataRate d2, const std::string msg)
Checks if two data rates values are equal.
virtual void DoRun(void)=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(void) 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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static DataRateTestSuite sDataRateTestSuite
Static variable for test initialization.