18 #include "ns3/names.h"
54 .SetGroupName (
"Core")
55 .HideFromDocumentation ()
79 .SetGroupName (
"Core")
80 .HideFromDocumentation ()
110 virtual void DoRun (
void);
115 :
TestCase (
"Check low level Names::Add and Names::FindName functionality")
139 Names::Add (objectOne,
"Child", childOfObjectOne);
142 Names::Add (objectTwo,
"Child", childOfObjectTwo);
148 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
175 virtual void DoRun (
void);
180 :
TestCase (
"Check string context Names::Add and Names::FindName functionality")
205 Names::Add (
"/Names/Name One",
"Child", childOfObjectOne);
208 Names::Add (
"/Names/Name Two",
"Child", childOfObjectTwo);
214 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
240 virtual void DoRun (
void);
245 :
TestCase (
"Check fully qualified path Names::Add and Names::FindName functionality")
270 Names::Add (
"/Names/Name One/Child", childOfObjectOne);
273 Names::Add (
"/Names/Name Two/Child", childOfObjectTwo);
279 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
309 virtual void DoRun (
void);
314 :
TestCase (
"Check relative path Names::Add and Names::FindName functionality")
339 Names::Add (
"Name One/Child", childOfObjectOne);
342 Names::Add (
"Name Two/Child", childOfObjectTwo);
348 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
375 virtual void DoRun (
void);
380 :
TestCase (
"Check low level Names::Rename functionality")
401 Names::Add (objectOne,
"Child", childOfObjectOne);
437 virtual void DoRun (
void);
442 :
TestCase (
"Check string context-based Names::Rename functionality")
463 Names::Add (
"/Names/Name",
"Child", childOfObjectOne);
499 virtual void DoRun (
void);
504 :
TestCase (
"Check fully qualified path Names::Rename functionality")
525 Names::Add (
"/Names/Name/Child", childOfObjectOne);
561 virtual void DoRun (
void);
566 :
TestCase (
"Check relative path Names::Rename functionality")
623 virtual void DoRun (
void);
628 :
TestCase (
"Check Names::FindPath functionality")
649 Names::Add (
"/Names/Name/Child", childOfObjectOne);
655 NS_TEST_ASSERT_MSG_EQ (found,
"/Names/Name/Child",
"Could not Names::Add and Names::FindPath a child Object");
678 virtual void DoRun (
void);
683 :
TestCase (
"Check low level Names::Find functionality")
707 Names::Add (
"Name One/Child", childOfObjectOne);
710 Names::Add (
"Name Two/Child", childOfObjectTwo);
712 found = Names::Find<TestObject> (
Ptr<Object> (0,
false),
"Name One");
713 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via object context");
715 found = Names::Find<TestObject> (
Ptr<Object> (0,
false),
"Name Two");
716 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via object context");
718 found = Names::Find<TestObject> (objectOne,
"Child");
719 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via object context");
721 found = Names::Find<TestObject> (objectTwo,
"Child");
722 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via object context");
742 virtual void DoRun (
void);
747 :
TestCase (
"Check string context-based Names::Find functionality")
771 Names::Add (
"Name One/Child", childOfObjectOne);
774 Names::Add (
"Name Two/Child", childOfObjectTwo);
776 found = Names::Find<TestObject> (
"/Names",
"Name One");
777 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
779 found = Names::Find<TestObject> (
"/Names",
"Name Two");
780 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
782 found = Names::Find<TestObject> (
"/Names/Name One",
"Child");
783 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
785 found = Names::Find<TestObject> (
"/Names/Name Two",
"Child");
786 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
806 virtual void DoRun (
void);
811 :
TestCase (
"Check fully qualified path Names::Find functionality")
835 Names::Add (
"/Names/Name One/Child", childOfObjectOne);
838 Names::Add (
"/Names/Name Two/Child", childOfObjectTwo);
840 found = Names::Find<TestObject> (
"/Names/Name One");
841 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
843 found = Names::Find<TestObject> (
"/Names/Name Two");
844 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
846 found = Names::Find<TestObject> (
"/Names/Name One/Child");
847 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
849 found = Names::Find<TestObject> (
"/Names/Name Two/Child");
850 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
870 virtual void DoRun (
void);
875 :
TestCase (
"Check relative path Names::Find functionality")
899 Names::Add (
"Name One/Child", childOfObjectOne);
902 Names::Add (
"Name Two/Child", childOfObjectTwo);
904 found = Names::Find<TestObject> (
"Name One");
905 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
907 found = Names::Find<TestObject> (
"Name Two");
908 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
910 found = Names::Find<TestObject> (
"Name One/Child");
911 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
913 found = Names::Find<TestObject> (
"Name Two/Child");
914 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
931 virtual void DoRun (
void);
936 :
TestCase (
"Check GetObject operation in Names::Find")
955 Names::Add (
"Alternate Test Object", alternateTestObject);
960 foundTestObject = Names::Find<TestObject> (
"Test Object");
962 "Could not find a previously named TestObject via GetObject");
964 foundAlternateTestObject = Names::Find<AlternateTestObject> (
"Alternate Test Object");
966 "Could not find a previously named AlternateTestObject via GetObject");
969 foundAlternateTestObject = Names::Find<AlternateTestObject> (
"Test Object");
971 "Unexpectedly able to GetObject<AlternateTestObject> on a TestObject");
973 foundTestObject = Names::Find<TestObject> (
"Alternate Test Object");
975 "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 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 void Clear(void)
Clear the list of objects associated with names.
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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~AlternateFindTestCase()
Destructor.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
AlternateFindTestCase()
Constructor.
Alternate test object for the Name service.
static TypeId GetTypeId(void)
Register this type.
AlternateTestObject()
Constructor.
Test the Object Name Service can do its most basic job.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~BasicAddTestCase()
Destructor.
BasicAddTestCase()
Constructor.
Test the Object Name Service can find Objects.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~BasicFindTestCase()
Destructor.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
BasicFindTestCase()
Constructor.
Test the Object Name Service can rename objects.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
BasicRenameTestCase()
Constructor.
virtual ~BasicRenameTestCase()
Destructor.
Test the Object Name Service can look up an object and return its fully qualified path name.
FindPathTestCase()
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual ~FindPathTestCase()
Destructor.
Test the Object Name Service can correctly use a fully qualified path to add associations.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual ~FullyQualifiedAddTestCase()
Destructor.
FullyQualifiedAddTestCase()
Constructor.
Test the Object Name Service can find Objects using a fully qualified path name.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
FullyQualifiedFindTestCase()
Constructor.
virtual ~FullyQualifiedFindTestCase()
Destructor.
Test the Object Name Service can rename objects using a fully qualified path name.
FullyQualifiedRenameTestCase()
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FullyQualifiedRenameTestCase()
Destructor.
virtual void DoTeardown(void)
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.
virtual ~RelativeAddTestCase()
Destructor.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
RelativeAddTestCase()
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test the Object Name Service can find Objects using a relative path name.
virtual ~RelativeFindTestCase()
Destructor.
RelativeFindTestCase()
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Test the Object Name Service can rename objects using a relative path name.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual ~RelativeRenameTestCase()
Destructor.
RelativeRenameTestCase()
Constructor.
Test the Object Name Service can correctly use a string context.
virtual ~StringContextAddTestCase()
Destructor.
StringContextAddTestCase()
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Test the Object Name Service can find Objects using a string context.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~StringContextFindTestCase()
Destructor.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
StringContextFindTestCase()
Constructor.
Test the Object Name Service can rename objects using a string context.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
StringContextRenameTestCase()
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~StringContextRenameTestCase()
Destructor.
Simple test object to exercise the Name service.
static TypeId GetTypeId(void)
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.