A Discrete-Event Network Simulator
API
names-test-suite.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License version 2 as
4  * published by the Free Software Foundation;
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  */
15 
16 #include "ns3/names.h"
17 #include "ns3/test.h"
18 
32 namespace ns3
33 {
34 
35 namespace tests
36 {
37 
42 class TestObject : public Object
43 {
44  public:
49  static TypeId GetTypeId()
50  {
51  static TypeId tid = TypeId("TestObject")
52  .SetParent<Object>()
53  .SetGroupName("Core")
54  .HideFromDocumentation()
55  .AddConstructor<TestObject>();
56  return tid;
57  }
58 
61  {
62  }
63 };
64 
70 {
71  public:
76  static TypeId GetTypeId()
77  {
78  static TypeId tid = TypeId("AlternateTestObject")
79  .SetParent<Object>()
80  .SetGroupName("Core")
81  .HideFromDocumentation()
82  .AddConstructor<AlternateTestObject>();
83  return tid;
84  }
85 
88  {
89  }
90 };
91 
105 {
106  public:
110  ~BasicAddTestCase() override;
111 
112  private:
113  void DoRun() override;
114  void DoTeardown() override;
115 };
116 
118  : TestCase("Check low level Names::Add and Names::FindName functionality")
119 {
120 }
121 
123 {
124 }
125 
126 void
128 {
129  Names::Clear();
130 }
131 
132 void
134 {
135  std::string found;
136 
137  Ptr<TestObject> objectOne = CreateObject<TestObject>();
138  Names::Add(Ptr<Object>(nullptr, false), "Name One", objectOne);
139 
140  Ptr<TestObject> objectTwo = CreateObject<TestObject>();
141  Names::Add(Ptr<Object>(nullptr, false), "Name Two", objectTwo);
142 
143  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
144  Names::Add(objectOne, "Child", childOfObjectOne);
145 
146  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject>();
147  Names::Add(objectTwo, "Child", childOfObjectTwo);
148 
149  found = Names::FindName(objectOne);
150  NS_TEST_ASSERT_MSG_EQ(found, "Name One", "Could not Names::Add and Names::FindName an Object");
151 
152  found = Names::FindName(objectTwo);
153  NS_TEST_ASSERT_MSG_EQ(found,
154  "Name Two",
155  "Could not Names::Add and Names::FindName a second Object");
156 
157  found = Names::FindName(childOfObjectOne);
158  NS_TEST_ASSERT_MSG_EQ(found,
159  "Child",
160  "Could not Names::Add and Names::FindName a child Object");
161 
162  found = Names::FindName(childOfObjectTwo);
163  NS_TEST_ASSERT_MSG_EQ(found,
164  "Child",
165  "Could not Names::Add and Names::FindName a child Object");
166 }
167 
178 {
179  public:
183  ~StringContextAddTestCase() override;
184 
185  private:
186  void DoRun() override;
187  void DoTeardown() override;
188 };
189 
191  : TestCase("Check string context Names::Add and Names::FindName functionality")
192 
193 {
194 }
195 
197 {
198 }
199 
200 void
202 {
203  Names::Clear();
204 }
205 
206 void
208 {
209  std::string found;
210 
211  Ptr<TestObject> objectOne = CreateObject<TestObject>();
212  Names::Add("/Names", "Name One", objectOne);
213 
214  Ptr<TestObject> objectTwo = CreateObject<TestObject>();
215  Names::Add("/Names", "Name Two", objectTwo);
216 
217  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
218  Names::Add("/Names/Name One", "Child", childOfObjectOne);
219 
220  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject>();
221  Names::Add("/Names/Name Two", "Child", childOfObjectTwo);
222 
223  found = Names::FindName(objectOne);
224  NS_TEST_ASSERT_MSG_EQ(found, "Name One", "Could not Names::Add and Names::FindName an Object");
225 
226  found = Names::FindName(objectTwo);
227  NS_TEST_ASSERT_MSG_EQ(found,
228  "Name Two",
229  "Could not Names::Add and Names::FindName a second Object");
230 
231  found = Names::FindName(childOfObjectOne);
232  NS_TEST_ASSERT_MSG_EQ(found,
233  "Child",
234  "Could not Names::Add and Names::FindName a child Object");
235 
236  found = Names::FindName(childOfObjectTwo);
237  NS_TEST_ASSERT_MSG_EQ(found,
238  "Child",
239  "Could not Names::Add and Names::FindName a child Object");
240 }
241 
251 {
252  public:
256  ~FullyQualifiedAddTestCase() override;
257 
258  private:
259  void DoRun() override;
260  void DoTeardown() override;
261 };
262 
264  : TestCase("Check fully qualified path Names::Add and Names::FindName functionality")
265 
266 {
267 }
268 
270 {
271 }
272 
273 void
275 {
276  Names::Clear();
277 }
278 
279 void
281 {
282  std::string found;
283 
284  Ptr<TestObject> objectOne = CreateObject<TestObject>();
285  Names::Add("/Names/Name One", objectOne);
286 
287  Ptr<TestObject> objectTwo = CreateObject<TestObject>();
288  Names::Add("/Names/Name Two", objectTwo);
289 
290  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
291  Names::Add("/Names/Name One/Child", childOfObjectOne);
292 
293  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject>();
294  Names::Add("/Names/Name Two/Child", childOfObjectTwo);
295 
296  found = Names::FindName(objectOne);
297  NS_TEST_ASSERT_MSG_EQ(found, "Name One", "Could not Names::Add and Names::FindName an Object");
298 
299  found = Names::FindName(objectTwo);
300  NS_TEST_ASSERT_MSG_EQ(found,
301  "Name Two",
302  "Could not Names::Add and Names::FindName a second Object");
303 
304  found = Names::FindName(childOfObjectOne);
305  NS_TEST_ASSERT_MSG_EQ(found,
306  "Child",
307  "Could not Names::Add and Names::FindName a child Object");
308 
309  found = Names::FindName(childOfObjectTwo);
310  NS_TEST_ASSERT_MSG_EQ(found,
311  "Child",
312  "Could not Names::Add and Names::FindName a child Object");
313 }
314 
328 {
329  public:
333  ~RelativeAddTestCase() override;
334 
335  private:
336  void DoRun() override;
337  void DoTeardown() override;
338 };
339 
341  : TestCase("Check relative path Names::Add and Names::FindName functionality")
342 
343 {
344 }
345 
347 {
348 }
349 
350 void
352 {
353  Names::Clear();
354 }
355 
356 void
358 {
359  std::string found;
360 
361  Ptr<TestObject> objectOne = CreateObject<TestObject>();
362  Names::Add("Name One", objectOne);
363 
364  Ptr<TestObject> objectTwo = CreateObject<TestObject>();
365  Names::Add("Name Two", objectTwo);
366 
367  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
368  Names::Add("Name One/Child", childOfObjectOne);
369 
370  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject>();
371  Names::Add("Name Two/Child", childOfObjectTwo);
372 
373  found = Names::FindName(objectOne);
374  NS_TEST_ASSERT_MSG_EQ(found, "Name One", "Could not Names::Add and Names::FindName an Object");
375 
376  found = Names::FindName(objectTwo);
377  NS_TEST_ASSERT_MSG_EQ(found,
378  "Name Two",
379  "Could not Names::Add and Names::FindName a second Object");
380 
381  found = Names::FindName(childOfObjectOne);
382  NS_TEST_ASSERT_MSG_EQ(found,
383  "Child",
384  "Could not Names::Add and Names::FindName a child Object");
385 
386  found = Names::FindName(childOfObjectTwo);
387  NS_TEST_ASSERT_MSG_EQ(found,
388  "Child",
389  "Could not Names::Add and Names::FindName a child Object");
390 }
391 
402 {
403  public:
407  ~BasicRenameTestCase() override;
408 
409  private:
410  void DoRun() override;
411  void DoTeardown() override;
412 };
413 
415  : TestCase("Check low level Names::Rename functionality")
416 {
417 }
418 
420 {
421 }
422 
423 void
425 {
426  Names::Clear();
427 }
428 
429 void
431 {
432  std::string found;
433 
434  Ptr<TestObject> objectOne = CreateObject<TestObject>();
435  Names::Add(Ptr<Object>(nullptr, false), "Name", objectOne);
436 
437  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
438  Names::Add(objectOne, "Child", childOfObjectOne);
439 
440  found = Names::FindName(objectOne);
441  NS_TEST_ASSERT_MSG_EQ(found, "Name", "Could not Names::Add and Names::FindName an Object");
442 
443  Names::Rename(Ptr<Object>(nullptr, false), "Name", "New Name");
444 
445  found = Names::FindName(objectOne);
446  NS_TEST_ASSERT_MSG_EQ(found, "New Name", "Could not Names::Rename an Object");
447 
448  found = Names::FindName(childOfObjectOne);
449  NS_TEST_ASSERT_MSG_EQ(found,
450  "Child",
451  "Could not Names::Add and Names::FindName a child Object");
452 
453  Names::Rename(objectOne, "Child", "New Child");
454 
455  found = Names::FindName(childOfObjectOne);
456  NS_TEST_ASSERT_MSG_EQ(found, "New Child", "Could not Names::Rename a child Object");
457 }
458 
468 {
469  public:
473  ~StringContextRenameTestCase() override;
474 
475  private:
476  void DoRun() override;
477  void DoTeardown() override;
478 };
479 
481  : TestCase("Check string context-based Names::Rename functionality")
482 {
483 }
484 
486 {
487 }
488 
489 void
491 {
492  Names::Clear();
493 }
494 
495 void
497 {
498  std::string found;
499 
500  Ptr<TestObject> objectOne = CreateObject<TestObject>();
501  Names::Add("/Names", "Name", objectOne);
502 
503  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
504  Names::Add("/Names/Name", "Child", childOfObjectOne);
505 
506  found = Names::FindName(objectOne);
507  NS_TEST_ASSERT_MSG_EQ(found, "Name", "Could not Names::Add and Names::FindName an Object");
508 
509  Names::Rename("/Names", "Name", "New Name");
510 
511  found = Names::FindName(objectOne);
512  NS_TEST_ASSERT_MSG_EQ(found, "New Name", "Could not Names::Rename an Object");
513 
514  found = Names::FindName(childOfObjectOne);
515  NS_TEST_ASSERT_MSG_EQ(found,
516  "Child",
517  "Could not Names::Add and Names::FindName a child Object");
518 
519  Names::Rename("/Names/New Name", "Child", "New Child");
520 
521  found = Names::FindName(childOfObjectOne);
522  NS_TEST_ASSERT_MSG_EQ(found, "New Child", "Could not Names::Rename a child Object");
523 }
524 
534 {
535  public:
540 
541  private:
542  void DoRun() override;
543  void DoTeardown() override;
544 };
545 
547  : TestCase("Check fully qualified path Names::Rename functionality")
548 {
549 }
550 
552 {
553 }
554 
555 void
557 {
558  Names::Clear();
559 }
560 
561 void
563 {
564  std::string found;
565 
566  Ptr<TestObject> objectOne = CreateObject<TestObject>();
567  Names::Add("/Names/Name", objectOne);
568 
569  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
570  Names::Add("/Names/Name/Child", childOfObjectOne);
571 
572  found = Names::FindName(objectOne);
573  NS_TEST_ASSERT_MSG_EQ(found, "Name", "Could not Names::Add and Names::FindName an Object");
574 
575  Names::Rename("/Names/Name", "New Name");
576 
577  found = Names::FindName(objectOne);
578  NS_TEST_ASSERT_MSG_EQ(found, "New Name", "Could not Names::Rename an Object");
579 
580  found = Names::FindName(childOfObjectOne);
581  NS_TEST_ASSERT_MSG_EQ(found,
582  "Child",
583  "Could not Names::Add and Names::FindName a child Object");
584 
585  Names::Rename("/Names/New Name/Child", "New Child");
586 
587  found = Names::FindName(childOfObjectOne);
588  NS_TEST_ASSERT_MSG_EQ(found, "New Child", "Could not Names::Rename a child Object");
589 }
590 
600 {
601  public:
605  ~RelativeRenameTestCase() override;
606 
607  private:
608  void DoRun() override;
609  void DoTeardown() override;
610 };
611 
613  : TestCase("Check relative path Names::Rename functionality")
614 {
615 }
616 
618 {
619 }
620 
621 void
623 {
624  Names::Clear();
625 }
626 
627 void
629 {
630  std::string found;
631 
632  Ptr<TestObject> objectOne = CreateObject<TestObject>();
633  Names::Add("Name", objectOne);
634 
635  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
636  Names::Add("Name/Child", childOfObjectOne);
637 
638  found = Names::FindName(objectOne);
639  NS_TEST_ASSERT_MSG_EQ(found, "Name", "Could not Names::Add and Names::FindName an Object");
640 
641  Names::Rename("Name", "New Name");
642 
643  found = Names::FindName(objectOne);
644  NS_TEST_ASSERT_MSG_EQ(found, "New Name", "Could not Names::Rename an Object");
645 
646  found = Names::FindName(childOfObjectOne);
647  NS_TEST_ASSERT_MSG_EQ(found,
648  "Child",
649  "Could not Names::Add and Names::FindName a child Object");
650 
651  Names::Rename("New Name/Child", "New Child");
652 
653  found = Names::FindName(childOfObjectOne);
654  NS_TEST_ASSERT_MSG_EQ(found, "New Child", "Could not Names::Rename a child Object");
655 }
656 
666 {
667  public:
671  ~FindPathTestCase() override;
672 
673  private:
674  void DoRun() override;
675  void DoTeardown() override;
676 };
677 
679  : TestCase("Check Names::FindPath functionality")
680 {
681 }
682 
684 {
685 }
686 
687 void
689 {
690  Names::Clear();
691 }
692 
693 void
695 {
696  std::string found;
697 
698  Ptr<TestObject> objectOne = CreateObject<TestObject>();
699  Names::Add("Name", objectOne);
700 
701  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
702  Names::Add("/Names/Name/Child", childOfObjectOne);
703 
704  found = Names::FindPath(objectOne);
705  NS_TEST_ASSERT_MSG_EQ(found,
706  "/Names/Name",
707  "Could not Names::Add and Names::FindPath an Object");
708 
709  found = Names::FindPath(childOfObjectOne);
710  NS_TEST_ASSERT_MSG_EQ(found,
711  "/Names/Name/Child",
712  "Could not Names::Add and Names::FindPath a child Object");
713 
714  Ptr<TestObject> objectNotThere = CreateObject<TestObject>();
715  found = Names::FindPath(objectNotThere);
716  NS_TEST_ASSERT_MSG_EQ(found.empty(), true, "Unexpectedly found a non-existent Object");
717 }
718 
727 {
728  public:
732  ~BasicFindTestCase() override;
733 
734  private:
735  void DoRun() override;
736  void DoTeardown() override;
737 };
738 
740  : TestCase("Check low level Names::Find functionality")
741 {
742 }
743 
745 {
746 }
747 
748 void
750 {
751  Names::Clear();
752 }
753 
754 void
756 {
757  Ptr<TestObject> found;
758 
759  Ptr<TestObject> objectOne = CreateObject<TestObject>();
760  Names::Add("Name One", objectOne);
761 
762  Ptr<TestObject> objectTwo = CreateObject<TestObject>();
763  Names::Add("Name Two", objectTwo);
764 
765  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
766  Names::Add("Name One/Child", childOfObjectOne);
767 
768  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject>();
769  Names::Add("Name Two/Child", childOfObjectTwo);
770 
771  found = Names::Find<TestObject>(Ptr<Object>(nullptr, false), "Name One");
772  NS_TEST_ASSERT_MSG_EQ(found,
773  objectOne,
774  "Could not find a previously named Object via object context");
775 
776  found = Names::Find<TestObject>(Ptr<Object>(nullptr, false), "Name Two");
777  NS_TEST_ASSERT_MSG_EQ(found,
778  objectTwo,
779  "Could not find a previously named Object via object context");
780 
781  found = Names::Find<TestObject>(objectOne, "Child");
782  NS_TEST_ASSERT_MSG_EQ(found,
783  childOfObjectOne,
784  "Could not find a previously named child Object via object context");
785 
786  found = Names::Find<TestObject>(objectTwo, "Child");
787  NS_TEST_ASSERT_MSG_EQ(found,
788  childOfObjectTwo,
789  "Could not find a previously named child Object via object context");
790 }
791 
801 {
802  public:
806  ~StringContextFindTestCase() override;
807 
808  private:
809  void DoRun() override;
810  void DoTeardown() override;
811 };
812 
814  : TestCase("Check string context-based Names::Find functionality")
815 {
816 }
817 
819 {
820 }
821 
822 void
824 {
825  Names::Clear();
826 }
827 
828 void
830 {
831  Ptr<TestObject> found;
832 
833  Ptr<TestObject> objectOne = CreateObject<TestObject>();
834  Names::Add("Name One", objectOne);
835 
836  Ptr<TestObject> objectTwo = CreateObject<TestObject>();
837  Names::Add("Name Two", objectTwo);
838 
839  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
840  Names::Add("Name One/Child", childOfObjectOne);
841 
842  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject>();
843  Names::Add("Name Two/Child", childOfObjectTwo);
844 
845  found = Names::Find<TestObject>("/Names", "Name One");
846  NS_TEST_ASSERT_MSG_EQ(found,
847  objectOne,
848  "Could not find a previously named Object via string context");
849 
850  found = Names::Find<TestObject>("/Names", "Name Two");
851  NS_TEST_ASSERT_MSG_EQ(found,
852  objectTwo,
853  "Could not find a previously named Object via stribng context");
854 
855  found = Names::Find<TestObject>("/Names/Name One", "Child");
856  NS_TEST_ASSERT_MSG_EQ(found,
857  childOfObjectOne,
858  "Could not find a previously named child Object via string context");
859 
860  found = Names::Find<TestObject>("/Names/Name Two", "Child");
861  NS_TEST_ASSERT_MSG_EQ(found,
862  childOfObjectTwo,
863  "Could not find a previously named child Object via string context");
864 }
865 
875 {
876  public:
880  ~FullyQualifiedFindTestCase() override;
881 
882  private:
883  void DoRun() override;
884  void DoTeardown() override;
885 };
886 
888  : TestCase("Check fully qualified path Names::Find functionality")
889 {
890 }
891 
893 {
894 }
895 
896 void
898 {
899  Names::Clear();
900 }
901 
902 void
904 {
905  Ptr<TestObject> found;
906 
907  Ptr<TestObject> objectOne = CreateObject<TestObject>();
908  Names::Add("/Names/Name One", objectOne);
909 
910  Ptr<TestObject> objectTwo = CreateObject<TestObject>();
911  Names::Add("/Names/Name Two", objectTwo);
912 
913  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
914  Names::Add("/Names/Name One/Child", childOfObjectOne);
915 
916  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject>();
917  Names::Add("/Names/Name Two/Child", childOfObjectTwo);
918 
919  found = Names::Find<TestObject>("/Names/Name One");
920  NS_TEST_ASSERT_MSG_EQ(found,
921  objectOne,
922  "Could not find a previously named Object via string context");
923 
924  found = Names::Find<TestObject>("/Names/Name Two");
925  NS_TEST_ASSERT_MSG_EQ(found,
926  objectTwo,
927  "Could not find a previously named Object via stribng context");
928 
929  found = Names::Find<TestObject>("/Names/Name One/Child");
930  NS_TEST_ASSERT_MSG_EQ(found,
931  childOfObjectOne,
932  "Could not find a previously named child Object via string context");
933 
934  found = Names::Find<TestObject>("/Names/Name Two/Child");
935  NS_TEST_ASSERT_MSG_EQ(found,
936  childOfObjectTwo,
937  "Could not find a previously named child Object via string context");
938 }
939 
949 {
950  public:
954  ~RelativeFindTestCase() override;
955 
956  private:
957  void DoRun() override;
958  void DoTeardown() override;
959 };
960 
962  : TestCase("Check relative path Names::Find functionality")
963 {
964 }
965 
967 {
968 }
969 
970 void
972 {
973  Names::Clear();
974 }
975 
976 void
978 {
979  Ptr<TestObject> found;
980 
981  Ptr<TestObject> objectOne = CreateObject<TestObject>();
982  Names::Add("Name One", objectOne);
983 
984  Ptr<TestObject> objectTwo = CreateObject<TestObject>();
985  Names::Add("Name Two", objectTwo);
986 
987  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject>();
988  Names::Add("Name One/Child", childOfObjectOne);
989 
990  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject>();
991  Names::Add("Name Two/Child", childOfObjectTwo);
992 
993  found = Names::Find<TestObject>("Name One");
994  NS_TEST_ASSERT_MSG_EQ(found,
995  objectOne,
996  "Could not find a previously named Object via string context");
997 
998  found = Names::Find<TestObject>("Name Two");
999  NS_TEST_ASSERT_MSG_EQ(found,
1000  objectTwo,
1001  "Could not find a previously named Object via stribng context");
1002 
1003  found = Names::Find<TestObject>("Name One/Child");
1004  NS_TEST_ASSERT_MSG_EQ(found,
1005  childOfObjectOne,
1006  "Could not find a previously named child Object via string context");
1007 
1008  found = Names::Find<TestObject>("Name Two/Child");
1009  NS_TEST_ASSERT_MSG_EQ(found,
1010  childOfObjectTwo,
1011  "Could not find a previously named child Object via string context");
1012 }
1013 
1020 {
1021  public:
1025  ~AlternateFindTestCase() override;
1026 
1027  private:
1028  void DoRun() override;
1029  void DoTeardown() override;
1030 };
1031 
1033  : TestCase("Check GetObject operation in Names::Find")
1034 {
1035 }
1036 
1038 {
1039 }
1040 
1041 void
1043 {
1044  Names::Clear();
1045 }
1046 
1047 void
1049 {
1050  Ptr<TestObject> testObject = CreateObject<TestObject>();
1051  Names::Add("Test Object", testObject);
1052 
1053  Ptr<AlternateTestObject> alternateTestObject = CreateObject<AlternateTestObject>();
1054  Names::Add("Alternate Test Object", alternateTestObject);
1055 
1056  Ptr<TestObject> foundTestObject;
1057  Ptr<AlternateTestObject> foundAlternateTestObject;
1058 
1059  foundTestObject = Names::Find<TestObject>("Test Object");
1060  NS_TEST_ASSERT_MSG_EQ(foundTestObject,
1061  testObject,
1062  "Could not find a previously named TestObject via GetObject");
1063 
1064  foundAlternateTestObject = Names::Find<AlternateTestObject>("Alternate Test Object");
1065  NS_TEST_ASSERT_MSG_EQ(foundAlternateTestObject,
1066  alternateTestObject,
1067  "Could not find a previously named AlternateTestObject via GetObject");
1068 
1069  foundAlternateTestObject = Names::Find<AlternateTestObject>("Test Object");
1070  NS_TEST_ASSERT_MSG_EQ(foundAlternateTestObject,
1071  nullptr,
1072  "Unexpectedly able to GetObject<AlternateTestObject> on a TestObject");
1073 
1074  foundTestObject = Names::Find<TestObject>("Alternate Test Object");
1075  NS_TEST_ASSERT_MSG_EQ(foundTestObject,
1076  nullptr,
1077  "Unexpectedly able to GetObject<TestObject> on an AlternateTestObject");
1078 }
1079 
1085 {
1086  public:
1088  NamesTestSuite();
1089 };
1090 
1092  : TestSuite("object-name-service")
1093 {
1108 }
1109 
1115 
1116 } // namespace tests
1117 
1118 } // namespace ns3
static void Rename(std::string oldpath, std::string newname)
Rename a previously associated name.
Definition: names.cc:783
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
Definition: names.cc:775
static void Clear()
Clear the list of objects associated with names.
Definition: names.cc:843
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:829
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:836
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
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.
Alternate test object for the Name service.
static TypeId GetTypeId()
Register this type.
Test the Object Name Service can do its most basic job.
~BasicAddTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Test the Object Name Service can find Objects.
~BasicFindTestCase() 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 rename objects.
void DoRun() override
Implementation to actually run this TestCase.
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() 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.
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() 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.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
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() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can find Objects using a relative path name.
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.
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.
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.
void DoRun() override
Implementation to actually run this TestCase.
Test the Object Name Service can rename objects using a string context.
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.
Definition: test.h:144
Every class exported by the ns3 library is enclosed in the ns3 namespace.