16 #include "ns3/names.h"
54 .HideFromDocumentation()
81 .HideFromDocumentation()
113 void DoRun()
override;
118 :
TestCase(
"Check low level Names::Add and Names::FindName functionality")
144 Names::Add(objectOne,
"Child", childOfObjectOne);
147 Names::Add(objectTwo,
"Child", childOfObjectTwo);
155 "Could not Names::Add and Names::FindName a second Object");
160 "Could not Names::Add and Names::FindName a child Object");
165 "Could not Names::Add and Names::FindName a child Object");
186 void DoRun()
override;
191 :
TestCase(
"Check string context Names::Add and Names::FindName functionality")
218 Names::Add(
"/Names/Name One",
"Child", childOfObjectOne);
221 Names::Add(
"/Names/Name Two",
"Child", childOfObjectTwo);
229 "Could not Names::Add and Names::FindName a second Object");
234 "Could not Names::Add and Names::FindName a child Object");
239 "Could not Names::Add and Names::FindName a child Object");
259 void DoRun()
override;
264 :
TestCase(
"Check fully qualified path Names::Add and Names::FindName functionality")
291 Names::Add(
"/Names/Name One/Child", childOfObjectOne);
294 Names::Add(
"/Names/Name Two/Child", childOfObjectTwo);
302 "Could not Names::Add and Names::FindName a second Object");
307 "Could not Names::Add and Names::FindName a child Object");
312 "Could not Names::Add and Names::FindName a child Object");
336 void DoRun()
override;
341 :
TestCase(
"Check relative path Names::Add and Names::FindName functionality")
368 Names::Add(
"Name One/Child", childOfObjectOne);
371 Names::Add(
"Name Two/Child", childOfObjectTwo);
379 "Could not Names::Add and Names::FindName a second Object");
384 "Could not Names::Add and Names::FindName a child Object");
389 "Could not Names::Add and Names::FindName a child Object");
410 void DoRun()
override;
415 :
TestCase(
"Check low level Names::Rename functionality")
438 Names::Add(objectOne,
"Child", childOfObjectOne);
451 "Could not Names::Add and Names::FindName a child Object");
476 void DoRun()
override;
481 :
TestCase(
"Check string context-based Names::Rename functionality")
504 Names::Add(
"/Names/Name",
"Child", childOfObjectOne);
517 "Could not Names::Add and Names::FindName a child Object");
542 void DoRun()
override;
547 :
TestCase(
"Check fully qualified path Names::Rename functionality")
570 Names::Add(
"/Names/Name/Child", childOfObjectOne);
583 "Could not Names::Add and Names::FindName a child Object");
608 void DoRun()
override;
613 :
TestCase(
"Check relative path Names::Rename functionality")
649 "Could not Names::Add and Names::FindName a child Object");
674 void DoRun()
override;
679 :
TestCase(
"Check Names::FindPath functionality")
702 Names::Add(
"/Names/Name/Child", childOfObjectOne);
707 "Could not Names::Add and Names::FindPath an Object");
712 "Could not Names::Add and Names::FindPath a child Object");
735 void DoRun()
override;
740 :
TestCase(
"Check low level Names::Find functionality")
766 Names::Add(
"Name One/Child", childOfObjectOne);
769 Names::Add(
"Name Two/Child", childOfObjectTwo);
771 found = Names::Find<TestObject>(
Ptr<Object>(
nullptr,
false),
"Name One");
774 "Could not find a previously named Object via object context");
776 found = Names::Find<TestObject>(
Ptr<Object>(
nullptr,
false),
"Name Two");
779 "Could not find a previously named Object via object context");
781 found = Names::Find<TestObject>(objectOne,
"Child");
784 "Could not find a previously named child Object via object context");
786 found = Names::Find<TestObject>(objectTwo,
"Child");
789 "Could not find a previously named child Object via object context");
809 void DoRun()
override;
814 :
TestCase(
"Check string context-based Names::Find functionality")
840 Names::Add(
"Name One/Child", childOfObjectOne);
843 Names::Add(
"Name Two/Child", childOfObjectTwo);
845 found = Names::Find<TestObject>(
"/Names",
"Name One");
848 "Could not find a previously named Object via string context");
850 found = Names::Find<TestObject>(
"/Names",
"Name Two");
853 "Could not find a previously named Object via stribng context");
855 found = Names::Find<TestObject>(
"/Names/Name One",
"Child");
858 "Could not find a previously named child Object via string context");
860 found = Names::Find<TestObject>(
"/Names/Name Two",
"Child");
863 "Could not find a previously named child Object via string context");
883 void DoRun()
override;
888 :
TestCase(
"Check fully qualified path Names::Find functionality")
914 Names::Add(
"/Names/Name One/Child", childOfObjectOne);
917 Names::Add(
"/Names/Name Two/Child", childOfObjectTwo);
919 found = Names::Find<TestObject>(
"/Names/Name One");
922 "Could not find a previously named Object via string context");
924 found = Names::Find<TestObject>(
"/Names/Name Two");
927 "Could not find a previously named Object via stribng context");
929 found = Names::Find<TestObject>(
"/Names/Name One/Child");
932 "Could not find a previously named child Object via string context");
934 found = Names::Find<TestObject>(
"/Names/Name Two/Child");
937 "Could not find a previously named child Object via string context");
957 void DoRun()
override;
962 :
TestCase(
"Check relative path Names::Find functionality")
988 Names::Add(
"Name One/Child", childOfObjectOne);
991 Names::Add(
"Name Two/Child", childOfObjectTwo);
993 found = Names::Find<TestObject>(
"Name One");
996 "Could not find a previously named Object via string context");
998 found = Names::Find<TestObject>(
"Name Two");
1001 "Could not find a previously named Object via stribng context");
1003 found = Names::Find<TestObject>(
"Name One/Child");
1006 "Could not find a previously named child Object via string context");
1008 found = Names::Find<TestObject>(
"Name Two/Child");
1011 "Could not find a previously named child Object via string context");
1028 void DoRun()
override;
1033 :
TestCase(
"Check GetObject operation in Names::Find")
1054 Names::Add(
"Alternate Test Object", alternateTestObject);
1059 foundTestObject = Names::Find<TestObject>(
"Test Object");
1062 "Could not find a previously named TestObject via GetObject");
1064 foundAlternateTestObject = Names::Find<AlternateTestObject>(
"Alternate Test Object");
1066 alternateTestObject,
1067 "Could not find a previously named AlternateTestObject via GetObject");
1069 foundAlternateTestObject = Names::Find<AlternateTestObject>(
"Test Object");
1072 "Unexpectedly able to GetObject<AlternateTestObject> on a TestObject");
1074 foundTestObject = Names::Find<TestObject>(
"Alternate Test Object");
1077 "Unexpectedly able to GetObject<TestObject> on an AlternateTestObject");
static void Rename(std::string oldpath, std::string newname)
Rename a previously associated name.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
static void Clear()
Clear the list of objects associated with names.
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and,...
static std::string FindPath(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and return the...
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Test the Object Name Service can find Objects using a second type.
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
~AlternateFindTestCase() override
Destructor.
AlternateFindTestCase()
Constructor.
Alternate test object for the Name service.
static TypeId GetTypeId()
Register this type.
AlternateTestObject()
Constructor.
Test the Object Name Service can do its most basic job.
~BasicAddTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
BasicAddTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Test the Object Name Service can find Objects.
~BasicFindTestCase() override
Destructor.
BasicFindTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can rename objects.
void DoRun() override
Implementation to actually run this TestCase.
BasicRenameTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
~BasicRenameTestCase() override
Destructor.
Test the Object Name Service can look up an object and return its fully qualified path name.
FindPathTestCase()
Constructor.
~FindPathTestCase() override
Destructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can correctly use a fully qualified path to add associations.
FullyQualifiedAddTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
~FullyQualifiedAddTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can find Objects using a fully qualified path name.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
FullyQualifiedFindTestCase()
Constructor.
~FullyQualifiedFindTestCase() override
Destructor.
Test the Object Name Service can rename objects using a fully qualified path name.
~FullyQualifiedRenameTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
FullyQualifiedRenameTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
NamesTestSuite()
Constructor.
Test the Object Name Service can correctly use a relative path to add associations.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
RelativeAddTestCase()
Constructor.
~RelativeAddTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can find Objects using a relative path name.
RelativeFindTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
~RelativeFindTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can rename objects using a relative path name.
~RelativeRenameTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
RelativeRenameTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Test the Object Name Service can correctly use a string context.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
~StringContextAddTestCase() override
Destructor.
StringContextAddTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can find Objects using a string context.
~StringContextFindTestCase() override
Destructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
StringContextFindTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can rename objects using a string context.
StringContextRenameTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
~StringContextRenameTestCase() override
Destructor.
Simple test object to exercise the Name service.
static TypeId GetTypeId()
Register this type.
static NamesTestSuite g_namesTestSuite
NamesTestSuite instance variable.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.