10#include "ns3/object-factory.h"
11#include "ns3/object.h"
73 .HideFromDocumentation()
105 .SetGroupName(
"Core")
132 .SetGroupName(
"Core")
133 .HideFromDocumentation()
176 void DoRun()
override;
180 :
TestCase(
"Check CreateObject<Type> template function")
199 "GetObject() of same type returns different Ptr");
206 "GetObject() of unrelated type returns nonzero pointer");
214 "GetObject() of unrelated returns nonzero Ptr");
219 "Unable to CreateObject<DerivedA> with implicit cast to BaseA");
233 "GetObject() of the original type returns different Ptr");
241 "GetObject returns different Ptr");
257 void DoRun()
override;
261 :
TestCase(
"Check Object aggregation functionality")
284 baseA->AggregateObject(baseB);
292 "Cannot GetObject (through baseA) for BaseA Object");
300 "Unexpectedly found a DerivedA through baseA");
307 "Cannot GetObject (through baseA) for BaseB Object");
315 "Unexpectedly found a DerivedB through baseA");
322 "Cannot GetObject (through baseB) for BaseB Object");
330 "Unexpectedly found a DerivedB through baseB");
338 "Cannot GetObject (through baseB) for BaseA Object");
346 "Unexpectedly found a DerivedA through baseB");
356 "Cannot GetObject (through baseBCopy) for a BaseA Object");
364 "Unable to CreateObject<DerivedA> with implicit cast to BaseA");
369 "Unable to CreateObject<DerivedB> with implicit cast to BaseB");
376 baseA->AggregateObject(baseB);
383 "Cannot GetObject (through baseA) for DerivedB Object");
391 "Cannot GetObject (through baseA) for BaseB Object");
398 "Cannot GetObject (through baseB) for DerivedA Object");
406 "Cannot GetObject (through baseB) for BaseA Object");
417 "Cannot GetObject (through baseBCopy) for a BaseA Object");
420 "Cannot GetObject (through baseBCopy) for a BaseA Object");
428 "Cannot GetObject (through baseB) for DerivedB Object");
436 "Cannot GetObject (through baseB) for BaseB Object");
449 baseA->AggregateObject(baseB);
452 baseA = baseB->GetObject<BaseA>();
469 void DoRun()
override;
473 :
TestCase(
"Check Object unidirectional aggregation functionality")
495 baseAOne->UnidirectionalAggregateObject(baseB);
496 baseATwo->UnidirectionalAggregateObject(baseB);
504 "Cannot GetObject (through baseAOne) for BaseB Object");
508 "Cannot GetObject (through baseATwo) for BaseB Object");
511 baseAOne->GetObject<BaseB>(),
512 baseATwo->GetObject<BaseB>(),
513 "GetObject (through baseAOne and baseATwo) for BaseB Object are not equal");
521 "Can GetObject (through baseB) for BaseA Object");
537 void DoRun()
override;
541 :
TestCase(
"Check ObjectFactory functionality")
566 "BaseA is unexpectedly a DerivedA also");
573 "BaseA unexpectedly responds to GetObject for DerivedA");
588 "Unable to use GetObject as dynamic_cast<BaseA>()");
597 "GetObject with implied cast returns different Ptr");
606 "Unexpectedly able to work around C++ type system");
static ns3::TypeId GetTypeId()
Register this type.
static ns3::TypeId GetTypeId()
Register this type.
static ns3::TypeId GetTypeId()
Register this type.
void DoDispose() override
Destructor implementation.
void DoDispose() override
Destructor implementation.
static ns3::TypeId GetTypeId()
Register this type.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
A base class which provides memory management and object aggregation.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
a unique identifier for an interface.
TypeId HideFromDocumentation()
Hide this TypeId from documentation.
TypeId AddConstructor()
Record in this TypeId the fact that the default constructor is accessible.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Test we can aggregate Objects.
AggregateObjectTestCase()
Constructor.
~AggregateObjectTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
Test we can make Objects using CreateObject.
CreateObjectTestCase()
Constructor.
~CreateObjectTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
Test an Object factory can create Objects.
ObjectFactoryTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
~ObjectFactoryTestCase() override
Destructor.
The Test Suite that glues the Test Cases together.
ObjectTestSuite()
Constructor.
Test we can aggregate Objects.
void DoRun() override
Implementation to actually run this TestCase.
UnidirectionalAggregateObjectTestCase()
Constructor.
~UnidirectionalAggregateObjectTestCase() override
Destructor.
static ObjectTestSuite g_objectTestSuite
ObjectTestSuite instance variable.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.