18 #include "ns3/names.h"
37 .SetGroupName (
"Core")
38 .HideFromDocumentation ()
57 .SetGroupName (
"Core")
58 .HideFromDocumentation ()
83 virtual void DoRun (
void);
84 virtual void DoTeardown (
void);
88 :
TestCase (
"Check low level Names::Add and Names::FindName functionality")
108 Names::Add (
Ptr<Object> (0,
false),
"Name One", objectOne);
111 Names::Add (
Ptr<Object> (0,
false),
"Name Two", objectTwo);
114 Names::Add (objectOne,
"Child", childOfObjectOne);
117 Names::Add (objectTwo,
"Child", childOfObjectTwo);
119 found = Names::FindName (objectOne);
122 found = Names::FindName (objectTwo);
123 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
125 found = Names::FindName (childOfObjectOne);
128 found = Names::FindName (childOfObjectTwo);
148 virtual void DoRun (
void);
153 :
TestCase (
"Check string context Names::Add and Names::FindName functionality")
174 Names::Add (
"/Names",
"Name One", objectOne);
177 Names::Add (
"/Names",
"Name Two", objectTwo);
180 Names::Add (
"/Names/Name One",
"Child", childOfObjectOne);
183 Names::Add (
"/Names/Name Two",
"Child", childOfObjectTwo);
185 found = Names::FindName (objectOne);
188 found = Names::FindName (objectTwo);
189 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
191 found = Names::FindName (childOfObjectOne);
194 found = Names::FindName (childOfObjectTwo);
211 virtual void DoRun (
void);
216 :
TestCase (
"Check fully qualified path Names::Add and Names::FindName functionality")
237 Names::Add (
"/Names/Name One", objectOne);
240 Names::Add (
"/Names/Name Two", objectTwo);
243 Names::Add (
"/Names/Name One/Child", childOfObjectOne);
246 Names::Add (
"/Names/Name Two/Child", childOfObjectTwo);
248 found = Names::FindName (objectOne);
251 found = Names::FindName (objectTwo);
252 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
254 found = Names::FindName (childOfObjectOne);
257 found = Names::FindName (childOfObjectTwo);
277 virtual void DoRun (
void);
282 :
TestCase (
"Check relative path Names::Add and Names::FindName functionality")
303 Names::Add (
"Name One", objectOne);
306 Names::Add (
"Name Two", objectTwo);
309 Names::Add (
"Name One/Child", childOfObjectOne);
312 Names::Add (
"Name Two/Child", childOfObjectTwo);
314 found = Names::FindName (objectOne);
317 found = Names::FindName (objectTwo);
318 NS_TEST_ASSERT_MSG_EQ (found,
"Name Two",
"Could not Names::Add and Names::FindName a second Object");
320 found = Names::FindName (childOfObjectOne);
323 found = Names::FindName (childOfObjectTwo);
343 virtual void DoRun (
void);
348 :
TestCase (
"Check low level Names::Rename functionality")
368 Names::Add (
Ptr<Object> (0,
false),
"Name", objectOne);
371 Names::Add (objectOne,
"Child", childOfObjectOne);
373 found = Names::FindName (objectOne);
376 Names::Rename (
Ptr<Object> (0,
false),
"Name",
"New Name");
378 found = Names::FindName (objectOne);
381 found = Names::FindName (childOfObjectOne);
384 Names::Rename (objectOne,
"Child",
"New Child");
386 found = Names::FindName (childOfObjectOne);
403 virtual void DoRun (
void);
408 :
TestCase (
"Check string context-based Names::Rename functionality")
428 Names::Add (
"/Names",
"Name", objectOne);
431 Names::Add (
"/Names/Name",
"Child", childOfObjectOne);
433 found = Names::FindName (objectOne);
436 Names::Rename (
"/Names",
"Name",
"New Name");
438 found = Names::FindName (objectOne);
441 found = Names::FindName (childOfObjectOne);
444 Names::Rename (
"/Names/New Name",
"Child",
"New Child");
446 found = Names::FindName (childOfObjectOne);
463 virtual void DoRun (
void);
468 :
TestCase (
"Check fully qualified path Names::Rename functionality")
488 Names::Add (
"/Names/Name", objectOne);
491 Names::Add (
"/Names/Name/Child", childOfObjectOne);
493 found = Names::FindName (objectOne);
496 Names::Rename (
"/Names/Name",
"New Name");
498 found = Names::FindName (objectOne);
501 found = Names::FindName (childOfObjectOne);
504 Names::Rename (
"/Names/New Name/Child",
"New Child");
506 found = Names::FindName (childOfObjectOne);
523 virtual void DoRun (
void);
528 :
TestCase (
"Check relative path Names::Rename functionality")
548 Names::Add (
"Name", objectOne);
551 Names::Add (
"Name/Child", childOfObjectOne);
553 found = Names::FindName (objectOne);
556 Names::Rename (
"Name",
"New Name");
558 found = Names::FindName (objectOne);
561 found = Names::FindName (childOfObjectOne);
564 Names::Rename (
"New Name/Child",
"New Child");
566 found = Names::FindName (childOfObjectOne);
583 virtual void DoRun (
void);
588 :
TestCase (
"Check Names::FindPath functionality")
608 Names::Add (
"Name", objectOne);
611 Names::Add (
"/Names/Name/Child", childOfObjectOne);
613 found = Names::FindPath (objectOne);
616 found = Names::FindPath (childOfObjectOne);
617 NS_TEST_ASSERT_MSG_EQ (found,
"/Names/Name/Child",
"Could not Names::Add and Names::FindPath a child Object");
620 found = Names::FindPath (objectNotThere);
637 virtual void DoRun (
void);
642 :
TestCase (
"Check low level Names::Find functionality")
662 Names::Add (
"Name One", objectOne);
665 Names::Add (
"Name Two", objectTwo);
668 Names::Add (
"Name One/Child", childOfObjectOne);
671 Names::Add (
"Name Two/Child", childOfObjectTwo);
673 found = Names::Find<TestObject> (
Ptr<Object> (0,
false),
"Name One");
674 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via object context");
676 found = Names::Find<TestObject> (Ptr<Object> (0,
false),
"Name Two");
677 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via object context");
679 found = Names::Find<TestObject> (objectOne,
"Child");
680 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via object context");
682 found = Names::Find<TestObject> (objectTwo,
"Child");
683 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via object context");
699 virtual void DoRun (
void);
704 :
TestCase (
"Check string context-based Names::Find functionality")
724 Names::Add (
"Name One", objectOne);
727 Names::Add (
"Name Two", objectTwo);
730 Names::Add (
"Name One/Child", childOfObjectOne);
733 Names::Add (
"Name Two/Child", childOfObjectTwo);
735 found = Names::Find<TestObject> (
"/Names",
"Name One");
736 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
738 found = Names::Find<TestObject> (
"/Names",
"Name Two");
739 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
741 found = Names::Find<TestObject> (
"/Names/Name One",
"Child");
742 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
744 found = Names::Find<TestObject> (
"/Names/Name Two",
"Child");
745 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
761 virtual void DoRun (
void);
766 :
TestCase (
"Check fully qualified path Names::Find functionality")
786 Names::Add (
"/Names/Name One", objectOne);
789 Names::Add (
"/Names/Name Two", objectTwo);
792 Names::Add (
"/Names/Name One/Child", childOfObjectOne);
795 Names::Add (
"/Names/Name Two/Child", childOfObjectTwo);
797 found = Names::Find<TestObject> (
"/Names/Name One");
798 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
800 found = Names::Find<TestObject> (
"/Names/Name Two");
801 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
803 found = Names::Find<TestObject> (
"/Names/Name One/Child");
804 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
806 found = Names::Find<TestObject> (
"/Names/Name Two/Child");
807 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
823 virtual void DoRun (
void);
828 :
TestCase (
"Check relative path Names::Find functionality")
848 Names::Add (
"Name One", objectOne);
851 Names::Add (
"Name Two", objectTwo);
854 Names::Add (
"Name One/Child", childOfObjectOne);
857 Names::Add (
"Name Two/Child", childOfObjectTwo);
859 found = Names::Find<TestObject> (
"Name One");
860 NS_TEST_ASSERT_MSG_EQ (found, objectOne,
"Could not find a previously named Object via string context");
862 found = Names::Find<TestObject> (
"Name Two");
863 NS_TEST_ASSERT_MSG_EQ (found, objectTwo,
"Could not find a previously named Object via stribng context");
865 found = Names::Find<TestObject> (
"Name One/Child");
866 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne,
"Could not find a previously named child Object via string context");
868 found = Names::Find<TestObject> (
"Name Two/Child");
869 NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo,
"Could not find a previously named child Object via string context");
883 virtual void DoRun (
void);
888 :
TestCase (
"Check GetObject operation in Names::Find")
906 Names::Add (
"Test Object", testObject);
909 Names::Add (
"Alternate Test Object", alternateTestObject);
914 foundTestObject = Names::Find<TestObject> (
"Test Object");
916 "Could not find a previously named TestObject via GetObject");
918 foundAlternateTestObject = Names::Find<AlternateTestObject> (
"Alternate Test Object");
920 "Could not find a previously named AlternateTestObject via GetObject");
923 foundAlternateTestObject = Names::Find<AlternateTestObject> (
"Test Object");
925 "Unexpectedly able to GetObject<AlternateTestObject> on a TestObject");
927 foundTestObject = Names::Find<TestObject> (
"Alternate Test Object");
929 "Unexpectedly able to GetObject<TestObject> on an AlternateTestObject");
939 :
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.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
static TypeId GetTypeId(void)
Register this type.
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()
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
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.
#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.
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.
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.
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)
Set the parent TypeId.
StringContextRenameTestCase()