9#include "ns3/data-rate.h"
11#include "ns3/simulator.h"
98 void DoRun()
override;
111 CheckTimesEqual(bitsTime, correctTime,
"CalculateBitsTxTime returned incorrect value");
112 if ((nBits % 8) == 0)
115 CheckTimesEqual(bytesTime, correctTime,
"CalculateBytesTxTime returned incorrect value");
131 for (nBits = 0; nBits <= 512; nBits++)
163 void AdditionTest(std::string rate1, std::string rate2, std::string rate3);
170 void SubtractionTest(std::string rate1, std::string rate2, std::string rate3);
187 void DoRun()
override;
229 "DataRate Multiplication with Int returned incorrect value");
232 CheckDataRateEqual(dr1, dr2,
"DataRate Multiplication with Int returned incorrect value");
243 "DataRate Multiplication with Double returned incorrect value");
246 CheckDataRateEqual(dr1, dr2,
"DataRate Multiplication with Double returned incorrect value");
287 TypeId(
"ns3::DataRateTupleObject")
289 .SetGroupName(
"Test")
293 "An example of tuple of two data rates (comprising value and unit, possibly "
294 "separated by a white space) and a string (possibly containing a white space).",
317 void DoRun()
override;
321 :
TestCase(
"test attribute set and get")
333 "Unexpected value for the first data rate");
336 "Unexpected value for the second data rate");
339 "Unexpected value for the string");
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.
Object with an attribute that is a tuple of data rates and a string.
~DataRateTupleObject() override=default
static TypeId GetTypeId()
Get the type ID.
std::tuple< DataRate, DataRate, std::string > m_tupleRatesString
tuple of two data rates and a string
Attribute set and get TestCase.
~DataRateTupleSetGetTestCase() override=default
DataRateTupleSetGetTestCase()
void DoRun() override
Implementation to actually run this TestCase.
Class for representing data rates.
Time CalculateBitsTxTime(uint32_t bits) const
Calculate transmission time.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=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.
static Unit GetResolution()
static void SetResolution(Unit resolution)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
High precision numerical type, implementing Q64.64 fixed precision.
Ptr< const AttributeChecker > MakeDataRateChecker()
Ptr< const AttributeChecker > MakeStringChecker()
Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1)
Create an AttributeAccessor for a class data member of type tuple, or a lone class get functor or set...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.