A Discrete-Event Network Simulator
API
names-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  */
16 
17 #include "ns3/test.h"
18 #include "ns3/names.h"
19 
20 
34 namespace ns3 {
35 
36 namespace tests {
37 
38 
43 class TestObject : public Object
44 {
45 public:
50  static TypeId GetTypeId (void)
51  {
52  static TypeId tid = TypeId ("TestObject")
53  .SetParent<Object> ()
54  .SetGroupName ("Core")
55  .HideFromDocumentation ()
56  .AddConstructor<TestObject> ();
57  return tid;
58  }
61  {}
62 };
63 
69 {
70 public:
75  static TypeId GetTypeId (void)
76  {
77  static TypeId tid = TypeId ("AlternateTestObject")
78  .SetParent<Object> ()
79  .SetGroupName ("Core")
80  .HideFromDocumentation ()
81  .AddConstructor<AlternateTestObject> ();
82  return tid;
83  }
86  {}
87 };
88 
102 {
103 public:
105  BasicAddTestCase ();
107  virtual ~BasicAddTestCase ();
108 
109 private:
110  virtual void DoRun (void);
111  virtual void DoTeardown (void);
112 };
113 
115  : TestCase ("Check low level Names::Add and Names::FindName functionality")
116 {}
117 
119 {}
120 
121 void
123 {
124  Names::Clear ();
125 }
126 
127 void
129 {
130  std::string found;
131 
132  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
133  Names::Add (Ptr<Object> (0, false), "Name One", objectOne);
134 
135  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
136  Names::Add (Ptr<Object> (0, false), "Name Two", objectTwo);
137 
138  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
139  Names::Add (objectOne, "Child", childOfObjectOne);
140 
141  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
142  Names::Add (objectTwo, "Child", childOfObjectTwo);
143 
144  found = Names::FindName (objectOne);
145  NS_TEST_ASSERT_MSG_EQ (found, "Name One", "Could not Names::Add and Names::FindName an Object");
146 
147  found = Names::FindName (objectTwo);
148  NS_TEST_ASSERT_MSG_EQ (found, "Name Two", "Could not Names::Add and Names::FindName a second Object");
149 
150  found = Names::FindName (childOfObjectOne);
151  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
152 
153  found = Names::FindName (childOfObjectTwo);
154  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
155 }
156 
167 {
168 public:
172  virtual ~StringContextAddTestCase ();
173 
174 private:
175  virtual void DoRun (void);
176  virtual void DoTeardown (void);
177 };
178 
180  : TestCase ("Check string context Names::Add and Names::FindName functionality")
181 
182 {}
183 
185 {}
186 
187 void
189 {
190  Names::Clear ();
191 }
192 
193 void
195 {
196  std::string found;
197 
198  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
199  Names::Add ("/Names", "Name One", objectOne);
200 
201  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
202  Names::Add ("/Names", "Name Two", objectTwo);
203 
204  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
205  Names::Add ("/Names/Name One", "Child", childOfObjectOne);
206 
207  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
208  Names::Add ("/Names/Name Two", "Child", childOfObjectTwo);
209 
210  found = Names::FindName (objectOne);
211  NS_TEST_ASSERT_MSG_EQ (found, "Name One", "Could not Names::Add and Names::FindName an Object");
212 
213  found = Names::FindName (objectTwo);
214  NS_TEST_ASSERT_MSG_EQ (found, "Name Two", "Could not Names::Add and Names::FindName a second Object");
215 
216  found = Names::FindName (childOfObjectOne);
217  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
218 
219  found = Names::FindName (childOfObjectTwo);
220  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
221 }
222 
232 {
233 public:
237  virtual ~FullyQualifiedAddTestCase ();
238 
239 private:
240  virtual void DoRun (void);
241  virtual void DoTeardown (void);
242 };
243 
245  : TestCase ("Check fully qualified path Names::Add and Names::FindName functionality")
246 
247 {}
248 
250 {}
251 
252 void
254 {
255  Names::Clear ();
256 }
257 
258 void
260 {
261  std::string found;
262 
263  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
264  Names::Add ("/Names/Name One", objectOne);
265 
266  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
267  Names::Add ("/Names/Name Two", objectTwo);
268 
269  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
270  Names::Add ("/Names/Name One/Child", childOfObjectOne);
271 
272  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
273  Names::Add ("/Names/Name Two/Child", childOfObjectTwo);
274 
275  found = Names::FindName (objectOne);
276  NS_TEST_ASSERT_MSG_EQ (found, "Name One", "Could not Names::Add and Names::FindName an Object");
277 
278  found = Names::FindName (objectTwo);
279  NS_TEST_ASSERT_MSG_EQ (found, "Name Two", "Could not Names::Add and Names::FindName a second Object");
280 
281  found = Names::FindName (childOfObjectOne);
282  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
283 
284  found = Names::FindName (childOfObjectTwo);
285  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
286 }
287 
301 {
302 public:
306  virtual ~RelativeAddTestCase ();
307 
308 private:
309  virtual void DoRun (void);
310  virtual void DoTeardown (void);
311 };
312 
314  : TestCase ("Check relative path Names::Add and Names::FindName functionality")
315 
316 {}
317 
319 {}
320 
321 void
323 {
324  Names::Clear ();
325 }
326 
327 void
329 {
330  std::string found;
331 
332  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
333  Names::Add ("Name One", objectOne);
334 
335  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
336  Names::Add ("Name Two", objectTwo);
337 
338  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
339  Names::Add ("Name One/Child", childOfObjectOne);
340 
341  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
342  Names::Add ("Name Two/Child", childOfObjectTwo);
343 
344  found = Names::FindName (objectOne);
345  NS_TEST_ASSERT_MSG_EQ (found, "Name One", "Could not Names::Add and Names::FindName an Object");
346 
347  found = Names::FindName (objectTwo);
348  NS_TEST_ASSERT_MSG_EQ (found, "Name Two", "Could not Names::Add and Names::FindName a second Object");
349 
350  found = Names::FindName (childOfObjectOne);
351  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
352 
353  found = Names::FindName (childOfObjectTwo);
354  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
355 }
356 
367 {
368 public:
372  virtual ~BasicRenameTestCase ();
373 
374 private:
375  virtual void DoRun (void);
376  virtual void DoTeardown (void);
377 };
378 
380  : TestCase ("Check low level Names::Rename functionality")
381 {}
382 
384 {}
385 
386 void
388 {
389  Names::Clear ();
390 }
391 
392 void
394 {
395  std::string found;
396 
397  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
398  Names::Add (Ptr<Object> (0, false), "Name", objectOne);
399 
400  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
401  Names::Add (objectOne, "Child", childOfObjectOne);
402 
403  found = Names::FindName (objectOne);
404  NS_TEST_ASSERT_MSG_EQ (found, "Name", "Could not Names::Add and Names::FindName an Object");
405 
406  Names::Rename (Ptr<Object> (0, false), "Name", "New Name");
407 
408  found = Names::FindName (objectOne);
409  NS_TEST_ASSERT_MSG_EQ (found, "New Name", "Could not Names::Rename an Object");
410 
411  found = Names::FindName (childOfObjectOne);
412  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
413 
414  Names::Rename (objectOne, "Child", "New Child");
415 
416  found = Names::FindName (childOfObjectOne);
417  NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
418 }
419 
429 {
430 public:
434  virtual ~StringContextRenameTestCase ();
435 
436 private:
437  virtual void DoRun (void);
438  virtual void DoTeardown (void);
439 };
440 
442  : TestCase ("Check string context-based Names::Rename functionality")
443 {}
444 
446 {}
447 
448 void
450 {
451  Names::Clear ();
452 }
453 
454 void
456 {
457  std::string found;
458 
459  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
460  Names::Add ("/Names", "Name", objectOne);
461 
462  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
463  Names::Add ("/Names/Name", "Child", childOfObjectOne);
464 
465  found = Names::FindName (objectOne);
466  NS_TEST_ASSERT_MSG_EQ (found, "Name", "Could not Names::Add and Names::FindName an Object");
467 
468  Names::Rename ("/Names", "Name", "New Name");
469 
470  found = Names::FindName (objectOne);
471  NS_TEST_ASSERT_MSG_EQ (found, "New Name", "Could not Names::Rename an Object");
472 
473  found = Names::FindName (childOfObjectOne);
474  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
475 
476  Names::Rename ("/Names/New Name", "Child", "New Child");
477 
478  found = Names::FindName (childOfObjectOne);
479  NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
480 }
481 
491 {
492 public:
497 
498 private:
499  virtual void DoRun (void);
500  virtual void DoTeardown (void);
501 };
502 
504  : TestCase ("Check fully qualified path Names::Rename functionality")
505 {}
506 
508 {}
509 
510 void
512 {
513  Names::Clear ();
514 }
515 
516 void
518 {
519  std::string found;
520 
521  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
522  Names::Add ("/Names/Name", objectOne);
523 
524  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
525  Names::Add ("/Names/Name/Child", childOfObjectOne);
526 
527  found = Names::FindName (objectOne);
528  NS_TEST_ASSERT_MSG_EQ (found, "Name", "Could not Names::Add and Names::FindName an Object");
529 
530  Names::Rename ("/Names/Name", "New Name");
531 
532  found = Names::FindName (objectOne);
533  NS_TEST_ASSERT_MSG_EQ (found, "New Name", "Could not Names::Rename an Object");
534 
535  found = Names::FindName (childOfObjectOne);
536  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
537 
538  Names::Rename ("/Names/New Name/Child", "New Child");
539 
540  found = Names::FindName (childOfObjectOne);
541  NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
542 }
543 
553 {
554 public:
558  virtual ~RelativeRenameTestCase ();
559 
560 private:
561  virtual void DoRun (void);
562  virtual void DoTeardown (void);
563 };
564 
566  : TestCase ("Check relative path Names::Rename functionality")
567 {}
568 
570 {}
571 
572 void
574 {
575  Names::Clear ();
576 }
577 
578 void
580 {
581  std::string found;
582 
583  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
584  Names::Add ("Name", objectOne);
585 
586  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
587  Names::Add ("Name/Child", childOfObjectOne);
588 
589  found = Names::FindName (objectOne);
590  NS_TEST_ASSERT_MSG_EQ (found, "Name", "Could not Names::Add and Names::FindName an Object");
591 
592  Names::Rename ("Name", "New Name");
593 
594  found = Names::FindName (objectOne);
595  NS_TEST_ASSERT_MSG_EQ (found, "New Name", "Could not Names::Rename an Object");
596 
597  found = Names::FindName (childOfObjectOne);
598  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
599 
600  Names::Rename ("New Name/Child", "New Child");
601 
602  found = Names::FindName (childOfObjectOne);
603  NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
604 }
605 
615 {
616 public:
618  FindPathTestCase ();
620  virtual ~FindPathTestCase ();
621 
622 private:
623  virtual void DoRun (void);
624  virtual void DoTeardown (void);
625 };
626 
628  : TestCase ("Check Names::FindPath functionality")
629 {}
630 
632 {}
633 
634 void
636 {
637  Names::Clear ();
638 }
639 
640 void
642 {
643  std::string found;
644 
645  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
646  Names::Add ("Name", objectOne);
647 
648  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
649  Names::Add ("/Names/Name/Child", childOfObjectOne);
650 
651  found = Names::FindPath (objectOne);
652  NS_TEST_ASSERT_MSG_EQ (found, "/Names/Name", "Could not Names::Add and Names::FindPath an Object");
653 
654  found = Names::FindPath (childOfObjectOne);
655  NS_TEST_ASSERT_MSG_EQ (found, "/Names/Name/Child", "Could not Names::Add and Names::FindPath a child Object");
656 
657  Ptr<TestObject> objectNotThere = CreateObject<TestObject> ();
658  found = Names::FindPath (objectNotThere);
659  NS_TEST_ASSERT_MSG_EQ (found, "", "Unexpectedly found a non-existent Object");
660 }
661 
670 {
671 public:
675  virtual ~BasicFindTestCase ();
676 
677 private:
678  virtual void DoRun (void);
679  virtual void DoTeardown (void);
680 };
681 
683  : TestCase ("Check low level Names::Find functionality")
684 {}
685 
687 {}
688 
689 void
691 {
692  Names::Clear ();
693 }
694 
695 void
697 {
698  Ptr<TestObject> found;
699 
700  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
701  Names::Add ("Name One", objectOne);
702 
703  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
704  Names::Add ("Name Two", objectTwo);
705 
706  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
707  Names::Add ("Name One/Child", childOfObjectOne);
708 
709  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
710  Names::Add ("Name Two/Child", childOfObjectTwo);
711 
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");
714 
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");
717 
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");
720 
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");
723 }
724 
734 {
735 public:
739  virtual ~StringContextFindTestCase ();
740 
741 private:
742  virtual void DoRun (void);
743  virtual void DoTeardown (void);
744 };
745 
747  : TestCase ("Check string context-based Names::Find functionality")
748 {}
749 
751 {}
752 
753 void
755 {
756  Names::Clear ();
757 }
758 
759 void
761 {
762  Ptr<TestObject> found;
763 
764  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
765  Names::Add ("Name One", objectOne);
766 
767  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
768  Names::Add ("Name Two", objectTwo);
769 
770  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
771  Names::Add ("Name One/Child", childOfObjectOne);
772 
773  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
774  Names::Add ("Name Two/Child", childOfObjectTwo);
775 
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");
778 
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");
781 
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");
784 
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");
787 }
788 
798 {
799 public:
803  virtual ~FullyQualifiedFindTestCase ();
804 
805 private:
806  virtual void DoRun (void);
807  virtual void DoTeardown (void);
808 };
809 
811  : TestCase ("Check fully qualified path Names::Find functionality")
812 {}
813 
815 {}
816 
817 void
819 {
820  Names::Clear ();
821 }
822 
823 void
825 {
826  Ptr<TestObject> found;
827 
828  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
829  Names::Add ("/Names/Name One", objectOne);
830 
831  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
832  Names::Add ("/Names/Name Two", objectTwo);
833 
834  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
835  Names::Add ("/Names/Name One/Child", childOfObjectOne);
836 
837  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
838  Names::Add ("/Names/Name Two/Child", childOfObjectTwo);
839 
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");
842 
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");
845 
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");
848 
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");
851 }
852 
862 {
863 public:
867  virtual ~RelativeFindTestCase ();
868 
869 private:
870  virtual void DoRun (void);
871  virtual void DoTeardown (void);
872 };
873 
875  : TestCase ("Check relative path Names::Find functionality")
876 {}
877 
879 {}
880 
881 void
883 {
884  Names::Clear ();
885 }
886 
887 void
889 {
890  Ptr<TestObject> found;
891 
892  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
893  Names::Add ("Name One", objectOne);
894 
895  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
896  Names::Add ("Name Two", objectTwo);
897 
898  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
899  Names::Add ("Name One/Child", childOfObjectOne);
900 
901  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
902  Names::Add ("Name Two/Child", childOfObjectTwo);
903 
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");
906 
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");
909 
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");
912 
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");
915 }
916 
923 {
924 public:
928  virtual ~AlternateFindTestCase ();
929 
930 private:
931  virtual void DoRun (void);
932  virtual void DoTeardown (void);
933 };
934 
936  : TestCase ("Check GetObject operation in Names::Find")
937 {}
938 
940 {}
941 
942 void
944 {
945  Names::Clear ();
946 }
947 
948 void
950 {
951  Ptr<TestObject> testObject = CreateObject<TestObject> ();
952  Names::Add ("Test Object", testObject);
953 
954  Ptr<AlternateTestObject> alternateTestObject = CreateObject<AlternateTestObject> ();
955  Names::Add ("Alternate Test Object", alternateTestObject);
956 
957  Ptr<TestObject> foundTestObject;
958  Ptr<AlternateTestObject> foundAlternateTestObject;
959 
960  foundTestObject = Names::Find<TestObject> ("Test Object");
961  NS_TEST_ASSERT_MSG_EQ (foundTestObject, testObject,
962  "Could not find a previously named TestObject via GetObject");
963 
964  foundAlternateTestObject = Names::Find<AlternateTestObject> ("Alternate Test Object");
965  NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, alternateTestObject,
966  "Could not find a previously named AlternateTestObject via GetObject");
967 
968 
969  foundAlternateTestObject = Names::Find<AlternateTestObject> ("Test Object");
970  NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, 0,
971  "Unexpectedly able to GetObject<AlternateTestObject> on a TestObject");
972 
973  foundTestObject = Names::Find<TestObject> ("Alternate Test Object");
974  NS_TEST_ASSERT_MSG_EQ (foundTestObject, 0,
975  "Unexpectedly able to GetObject<TestObject> on an AlternateTestObject");
976 }
977 
982 class NamesTestSuite : public TestSuite
983 {
984 public:
986  NamesTestSuite ();
987 };
988 
990  : TestSuite ("object-name-service")
991 {
1006 }
1007 
1013 
1014 
1015 } // namespace tests
1016 
1017 } // namespace ns3
static void Rename(std::string oldpath, std::string newname)
Rename a previously associated name.
Definition: names.cc:776
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
Definition: names.cc:768
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,...
Definition: names.cc:817
static void Clear(void)
Clear the list of objects associated with names.
Definition: names.cc:831
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...
Definition: names.cc:824
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
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.
Alternate test object for the Name service.
static TypeId GetTypeId(void)
Register this type.
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.
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.
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.
virtual ~BasicRenameTestCase()
Destructor.
Test the Object Name Service can look up an object and return its 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.
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.
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.
virtual ~FullyQualifiedFindTestCase()
Destructor.
Test the Object Name Service can rename 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.
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.
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.
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.
Test the Object Name Service can correctly use a string context.
virtual ~StringContextAddTestCase()
Destructor.
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.
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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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.
Definition: test.h:141
Every class exported by the ns3 library is enclosed in the ns3 namespace.