18 #include "ns3/names.h"
73 virtual void DoRun (
void);
74 virtual void DoTeardown (
void);
78 :
TestCase (
"Check low level Names::Add and Names::FindName functionality")
98 Names::Add (
Ptr<Object> (0,
false),
"Name One", objectOne);
101 Names::Add (
Ptr<Object> (0,
false),
"Name Two", objectTwo);
104 Names::Add (objectOne,
"Child", childOfObjectOne);
107 Names::Add (objectTwo,
"Child", childOfObjectTwo);
109 found = Names::FindName (objectOne);
112 found = Names::FindName (objectTwo);
113 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
115 found = Names::FindName (childOfObjectOne);
118 found = Names::FindName (childOfObjectTwo);
138 virtual void DoRun (
void);
143 :
TestCase (
"Check string context Names::Add and Names::FindName functionality")
164 Names::Add (
"/Names",
"Name One", objectOne);
167 Names::Add (
"/Names",
"Name Two", objectTwo);
170 Names::Add (
"/Names/Name One",
"Child", childOfObjectOne);
173 Names::Add (
"/Names/Name Two",
"Child", childOfObjectTwo);
175 found = Names::FindName (objectOne);
178 found = Names::FindName (objectTwo);
179 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
181 found = Names::FindName (childOfObjectOne);
184 found = Names::FindName (childOfObjectTwo);
201 virtual void DoRun (
void);
206 :
TestCase (
"Check fully qualified path Names::Add and Names::FindName functionality")
227 Names::Add (
"/Names/Name One", objectOne);
230 Names::Add (
"/Names/Name Two", objectTwo);
233 Names::Add (
"/Names/Name One/Child", childOfObjectOne);
236 Names::Add (
"/Names/Name Two/Child", childOfObjectTwo);
238 found = Names::FindName (objectOne);
241 found = Names::FindName (objectTwo);
242 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
244 found = Names::FindName (childOfObjectOne);
247 found = Names::FindName (childOfObjectTwo);
267 virtual void DoRun (
void);
272 :
TestCase (
"Check relative path Names::Add and Names::FindName functionality")
293 Names::Add (
"Name One", objectOne);
296 Names::Add (
"Name Two", objectTwo);
299 Names::Add (
"Name One/Child", childOfObjectOne);
302 Names::Add (
"Name Two/Child", childOfObjectTwo);
304 found = Names::FindName (objectOne);
307 found = Names::FindName (objectTwo);
308 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
310 found = Names::FindName (childOfObjectOne);
313 found = Names::FindName (childOfObjectTwo);
333 virtual void DoRun (
void);
338 :
TestCase (
"Check low level Names::Rename functionality")
358 Names::Add (
Ptr<Object> (0,
false),
"Name", objectOne);
361 Names::Add (objectOne,
"Child", childOfObjectOne);
363 found = Names::FindName (objectOne);
366 Names::Rename (
Ptr<Object> (0,
false),
"Name",
"New Name");
368 found = Names::FindName (objectOne);
371 found = Names::FindName (childOfObjectOne);
374 Names::Rename (objectOne,
"Child",
"New Child");
376 found = Names::FindName (childOfObjectOne);
393 virtual void DoRun (
void);
398 :
TestCase (
"Check string context-based Names::Rename functionality")
418 Names::Add (
"/Names",
"Name", objectOne);
421 Names::Add (
"/Names/Name",
"Child", childOfObjectOne);
423 found = Names::FindName (objectOne);
426 Names::Rename (
"/Names",
"Name",
"New Name");
428 found = Names::FindName (objectOne);
431 found = Names::FindName (childOfObjectOne);
434 Names::Rename (
"/Names/New Name",
"Child",
"New Child");
436 found = Names::FindName (childOfObjectOne);
453 virtual void DoRun (
void);
458 :
TestCase (
"Check fully qualified path Names::Rename functionality")
478 Names::Add (
"/Names/Name", objectOne);
481 Names::Add (
"/Names/Name/Child", childOfObjectOne);
483 found = Names::FindName (objectOne);
486 Names::Rename (
"/Names/Name",
"New Name");
488 found = Names::FindName (objectOne);
491 found = Names::FindName (childOfObjectOne);
494 Names::Rename (
"/Names/New Name/Child",
"New Child");
496 found = Names::FindName (childOfObjectOne);
513 virtual void DoRun (
void);
518 :
TestCase (
"Check relative path Names::Rename functionality")
538 Names::Add (
"Name", objectOne);
541 Names::Add (
"Name/Child", childOfObjectOne);
543 found = Names::FindName (objectOne);
546 Names::Rename (
"Name",
"New Name");
548 found = Names::FindName (objectOne);
551 found = Names::FindName (childOfObjectOne);
554 Names::Rename (
"New Name/Child",
"New Child");
556 found = Names::FindName (childOfObjectOne);
573 virtual void DoRun (
void);
578 :
TestCase (
"Check Names::FindPath functionality")
598 Names::Add (
"Name", objectOne);
601 Names::Add (
"/Names/Name/Child", childOfObjectOne);
603 found = Names::FindPath (objectOne);
606 found = Names::FindPath (childOfObjectOne);
607 NS_TEST_ASSERT_MSG_EQ (found,
"/Names/Name/Child",
"Could not Names::Add and Names::FindPath a child Object");
610 found = Names::FindPath (objectNotThere);
627 virtual void DoRun (
void);
632 :
TestCase (
"Check low level Names::Find functionality")
652 Names::Add (
"Name One", objectOne);
655 Names::Add (
"Name Two", objectTwo);
658 Names::Add (
"Name One/Child", childOfObjectOne);
661 Names::Add (
"Name Two/Child", childOfObjectTwo);
663 found = Names::Find<TestObject> (
Ptr<Object> (0,
false),
"Name One");
664 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via object context");
666 found = Names::Find<TestObject> (Ptr<Object> (0,
false),
"Name Two");
667 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via object context");
669 found = Names::Find<TestObject> (objectOne,
"Child");
670 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via object context");
672 found = Names::Find<TestObject> (objectTwo,
"Child");
673 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via object context");
689 virtual void DoRun (
void);
694 :
TestCase (
"Check string context-based Names::Find functionality")
714 Names::Add (
"Name One", objectOne);
717 Names::Add (
"Name Two", objectTwo);
720 Names::Add (
"Name One/Child", childOfObjectOne);
723 Names::Add (
"Name Two/Child", childOfObjectTwo);
725 found = Names::Find<TestObject> (
"/Names",
"Name One");
726 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
728 found = Names::Find<TestObject> (
"/Names",
"Name Two");
729 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
731 found = Names::Find<TestObject> (
"/Names/Name One",
"Child");
732 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
734 found = Names::Find<TestObject> (
"/Names/Name Two",
"Child");
735 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
751 virtual void DoRun (
void);
756 :
TestCase (
"Check fully qualified path Names::Find functionality")
776 Names::Add (
"/Names/Name One", objectOne);
779 Names::Add (
"/Names/Name Two", objectTwo);
782 Names::Add (
"/Names/Name One/Child", childOfObjectOne);
785 Names::Add (
"/Names/Name Two/Child", childOfObjectTwo);
787 found = Names::Find<TestObject> (
"/Names/Name One");
788 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
790 found = Names::Find<TestObject> (
"/Names/Name Two");
791 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
793 found = Names::Find<TestObject> (
"/Names/Name One/Child");
794 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
796 found = Names::Find<TestObject> (
"/Names/Name Two/Child");
797 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
813 virtual void DoRun (
void);
818 :
TestCase (
"Check relative path Names::Find functionality")
838 Names::Add (
"Name One", objectOne);
841 Names::Add (
"Name Two", objectTwo);
844 Names::Add (
"Name One/Child", childOfObjectOne);
847 Names::Add (
"Name Two/Child", childOfObjectTwo);
849 found = Names::Find<TestObject> (
"Name One");
850 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
852 found = Names::Find<TestObject> (
"Name Two");
853 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
855 found = Names::Find<TestObject> (
"Name One/Child");
856 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
858 found = Names::Find<TestObject> (
"Name Two/Child");
859 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
873 virtual void DoRun (
void);
878 :
TestCase (
"Check GetObject operation in Names::Find")
896 Names::Add (
"Test Object", testObject);
899 Names::Add (
"Alternate Test Object", alternateTestObject);
904 foundTestObject = Names::Find<TestObject> (
"Test Object");
906 "Could not find a previously named TestObject via GetObject");
908 foundAlternateTestObject = Names::Find<AlternateTestObject> (
"Alternate Test Object");
910 "Could not find a previously named AlternateTestObject via GetObject");
913 foundAlternateTestObject = Names::Find<AlternateTestObject> (
"Test Object");
915 "Unexpectedly able to GetObject<AlternateTestObject> on a TestObject");
917 foundTestObject = Names::Find<TestObject> (
"Alternate Test Object");
919 "Unexpectedly able to GetObject<TestObject> on an AlternateTestObject");
929 :
TestSuite (
"object-name-service", UNIT)
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()
smart pointer class similar to boost::intrusive_ptr
TypeId AddConstructor(void)
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
static TypeId GetTypeId(void)
virtual ~StringContextAddTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
FullyQualifiedRenameTestCase()
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 void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
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 ~BasicRenameTestCase()
virtual ~BasicFindTestCase()
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
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 ~AlternateFindTestCase()
FullyQualifiedFindTestCase()
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
static NamesTestSuite namesTestSuite
virtual ~RelativeFindTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void Dispose(void)
virtual ~FindPathTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
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 void DoRun(void)
Implementation to actually run this TestCase.
StringContextFindTestCase()
virtual ~FullyQualifiedFindTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FullyQualifiedRenameTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
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 void Dispose(void)
virtual ~FullyQualifiedAddTestCase()
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
static TypeId GetTypeId(void)
Register this type.
static TypeId GetTypeId(void)
virtual ~BasicAddTestCase()
virtual ~StringContextRenameTestCase()
FullyQualifiedAddTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~RelativeAddTestCase()
StringContextAddTestCase()
virtual ~StringContextFindTestCase()
a base class which provides memory management and object aggregation
virtual void DoRun(void)
Implementation to actually run this TestCase.
a unique identifier for an interface.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
TypeId SetParent(TypeId tid)
StringContextRenameTestCase()
#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.
TypeId HideFromDocumentation(void)