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  }
60  TestObject () {}
61 };
62 
68 {
69 public:
74  static TypeId GetTypeId (void)
75  {
76  static TypeId tid = TypeId ("AlternateTestObject")
77  .SetParent<Object> ()
78  .SetGroupName ("Core")
79  .HideFromDocumentation ()
80  .AddConstructor<AlternateTestObject> ();
81  return tid;
82  }
85 };
86 
99 class BasicAddTestCase : public TestCase
100 {
101 public:
103  BasicAddTestCase ();
105  virtual ~BasicAddTestCase ();
106 
107 private:
108  virtual void DoRun (void);
109  virtual void DoTeardown (void);
110 };
111 
113  : TestCase ("Check low level Names::Add and Names::FindName functionality")
114 {
115 }
116 
118 {
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 }
184 
186 {
187 }
188 
189 void
191 {
192  Names::Clear ();
193 }
194 
195 void
197 {
198  std::string found;
199 
200  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
201  Names::Add ("/Names", "Name One", objectOne);
202 
203  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
204  Names::Add ("/Names", "Name Two", objectTwo);
205 
206  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
207  Names::Add ("/Names/Name One", "Child", childOfObjectOne);
208 
209  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
210  Names::Add ("/Names/Name Two", "Child", childOfObjectTwo);
211 
212  found = Names::FindName (objectOne);
213  NS_TEST_ASSERT_MSG_EQ (found, "Name One", "Could not Names::Add and Names::FindName an Object");
214 
215  found = Names::FindName (objectTwo);
216  NS_TEST_ASSERT_MSG_EQ (found, "Name Two", "Could not Names::Add and Names::FindName a second Object");
217 
218  found = Names::FindName (childOfObjectOne);
219  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
220 
221  found = Names::FindName (childOfObjectTwo);
222  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
223 }
224 
234 {
235 public:
239  virtual ~FullyQualifiedAddTestCase ();
240 
241 private:
242  virtual void DoRun (void);
243  virtual void DoTeardown (void);
244 };
245 
247  : TestCase ("Check fully qualified path Names::Add and Names::FindName functionality")
248 
249 {
250 }
251 
253 {
254 }
255 
256 void
258 {
259  Names::Clear ();
260 }
261 
262 void
264 {
265  std::string found;
266 
267  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
268  Names::Add ("/Names/Name One", objectOne);
269 
270  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
271  Names::Add ("/Names/Name Two", objectTwo);
272 
273  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
274  Names::Add ("/Names/Name One/Child", childOfObjectOne);
275 
276  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
277  Names::Add ("/Names/Name Two/Child", childOfObjectTwo);
278 
279  found = Names::FindName (objectOne);
280  NS_TEST_ASSERT_MSG_EQ (found, "Name One", "Could not Names::Add and Names::FindName an Object");
281 
282  found = Names::FindName (objectTwo);
283  NS_TEST_ASSERT_MSG_EQ (found, "Name Two", "Could not Names::Add and Names::FindName a second Object");
284 
285  found = Names::FindName (childOfObjectOne);
286  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
287 
288  found = Names::FindName (childOfObjectTwo);
289  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
290 }
291 
305 {
306 public:
310  virtual ~RelativeAddTestCase ();
311 
312 private:
313  virtual void DoRun (void);
314  virtual void DoTeardown (void);
315 };
316 
318  : TestCase ("Check relative path Names::Add and Names::FindName functionality")
319 
320 {
321 }
322 
324 {
325 }
326 
327 void
329 {
330  Names::Clear ();
331 }
332 
333 void
335 {
336  std::string found;
337 
338  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
339  Names::Add ("Name One", objectOne);
340 
341  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
342  Names::Add ("Name Two", objectTwo);
343 
344  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
345  Names::Add ("Name One/Child", childOfObjectOne);
346 
347  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
348  Names::Add ("Name Two/Child", childOfObjectTwo);
349 
350  found = Names::FindName (objectOne);
351  NS_TEST_ASSERT_MSG_EQ (found, "Name One", "Could not Names::Add and Names::FindName an Object");
352 
353  found = Names::FindName (objectTwo);
354  NS_TEST_ASSERT_MSG_EQ (found, "Name Two", "Could not Names::Add and Names::FindName a second Object");
355 
356  found = Names::FindName (childOfObjectOne);
357  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
358 
359  found = Names::FindName (childOfObjectTwo);
360  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
361 }
362 
373 {
374 public:
378  virtual ~BasicRenameTestCase ();
379 
380 private:
381  virtual void DoRun (void);
382  virtual void DoTeardown (void);
383 };
384 
386  : TestCase ("Check low level Names::Rename functionality")
387 {
388 }
389 
391 {
392 }
393 
394 void
396 {
397  Names::Clear ();
398 }
399 
400 void
402 {
403  std::string found;
404 
405  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
406  Names::Add (Ptr<Object> (0, false), "Name", objectOne);
407 
408  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
409  Names::Add (objectOne, "Child", childOfObjectOne);
410 
411  found = Names::FindName (objectOne);
412  NS_TEST_ASSERT_MSG_EQ (found, "Name", "Could not Names::Add and Names::FindName an Object");
413 
414  Names::Rename (Ptr<Object> (0, false), "Name", "New Name");
415 
416  found = Names::FindName (objectOne);
417  NS_TEST_ASSERT_MSG_EQ (found, "New Name", "Could not Names::Rename an Object");
418 
419  found = Names::FindName (childOfObjectOne);
420  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
421 
422  Names::Rename (objectOne, "Child", "New Child");
423 
424  found = Names::FindName (childOfObjectOne);
425  NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
426 }
427 
437 {
438 public:
442  virtual ~StringContextRenameTestCase ();
443 
444 private:
445  virtual void DoRun (void);
446  virtual void DoTeardown (void);
447 };
448 
450  : TestCase ("Check string context-based Names::Rename functionality")
451 {
452 }
453 
455 {
456 }
457 
458 void
460 {
461  Names::Clear ();
462 }
463 
464 void
466 {
467  std::string found;
468 
469  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
470  Names::Add ("/Names", "Name", objectOne);
471 
472  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
473  Names::Add ("/Names/Name", "Child", childOfObjectOne);
474 
475  found = Names::FindName (objectOne);
476  NS_TEST_ASSERT_MSG_EQ (found, "Name", "Could not Names::Add and Names::FindName an Object");
477 
478  Names::Rename ("/Names", "Name", "New Name");
479 
480  found = Names::FindName (objectOne);
481  NS_TEST_ASSERT_MSG_EQ (found, "New Name", "Could not Names::Rename an Object");
482 
483  found = Names::FindName (childOfObjectOne);
484  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
485 
486  Names::Rename ("/Names/New Name", "Child", "New Child");
487 
488  found = Names::FindName (childOfObjectOne);
489  NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
490 }
491 
501 {
502 public:
507 
508 private:
509  virtual void DoRun (void);
510  virtual void DoTeardown (void);
511 };
512 
514  : TestCase ("Check fully qualified path Names::Rename functionality")
515 {
516 }
517 
519 {
520 }
521 
522 void
524 {
525  Names::Clear ();
526 }
527 
528 void
530 {
531  std::string found;
532 
533  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
534  Names::Add ("/Names/Name", objectOne);
535 
536  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
537  Names::Add ("/Names/Name/Child", childOfObjectOne);
538 
539  found = Names::FindName (objectOne);
540  NS_TEST_ASSERT_MSG_EQ (found, "Name", "Could not Names::Add and Names::FindName an Object");
541 
542  Names::Rename ("/Names/Name", "New Name");
543 
544  found = Names::FindName (objectOne);
545  NS_TEST_ASSERT_MSG_EQ (found, "New Name", "Could not Names::Rename an Object");
546 
547  found = Names::FindName (childOfObjectOne);
548  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
549 
550  Names::Rename ("/Names/New Name/Child", "New Child");
551 
552  found = Names::FindName (childOfObjectOne);
553  NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
554 }
555 
565 {
566 public:
570  virtual ~RelativeRenameTestCase ();
571 
572 private:
573  virtual void DoRun (void);
574  virtual void DoTeardown (void);
575 };
576 
578  : TestCase ("Check relative path Names::Rename functionality")
579 {
580 }
581 
583 {
584 }
585 
586 void
588 {
589  Names::Clear ();
590 }
591 
592 void
594 {
595  std::string found;
596 
597  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
598  Names::Add ("Name", objectOne);
599 
600  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
601  Names::Add ("Name/Child", childOfObjectOne);
602 
603  found = Names::FindName (objectOne);
604  NS_TEST_ASSERT_MSG_EQ (found, "Name", "Could not Names::Add and Names::FindName an Object");
605 
606  Names::Rename ("Name", "New Name");
607 
608  found = Names::FindName (objectOne);
609  NS_TEST_ASSERT_MSG_EQ (found, "New Name", "Could not Names::Rename an Object");
610 
611  found = Names::FindName (childOfObjectOne);
612  NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
613 
614  Names::Rename ("New Name/Child", "New Child");
615 
616  found = Names::FindName (childOfObjectOne);
617  NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
618 }
619 
629 {
630 public:
632  FindPathTestCase ();
634  virtual ~FindPathTestCase ();
635 
636 private:
637  virtual void DoRun (void);
638  virtual void DoTeardown (void);
639 };
640 
642  : TestCase ("Check Names::FindPath functionality")
643 {
644 }
645 
647 {
648 }
649 
650 void
652 {
653  Names::Clear ();
654 }
655 
656 void
658 {
659  std::string found;
660 
661  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
662  Names::Add ("Name", objectOne);
663 
664  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
665  Names::Add ("/Names/Name/Child", childOfObjectOne);
666 
667  found = Names::FindPath (objectOne);
668  NS_TEST_ASSERT_MSG_EQ (found, "/Names/Name", "Could not Names::Add and Names::FindPath an Object");
669 
670  found = Names::FindPath (childOfObjectOne);
671  NS_TEST_ASSERT_MSG_EQ (found, "/Names/Name/Child", "Could not Names::Add and Names::FindPath a child Object");
672 
673  Ptr<TestObject> objectNotThere = CreateObject<TestObject> ();
674  found = Names::FindPath (objectNotThere);
675  NS_TEST_ASSERT_MSG_EQ (found, "", "Unexpectedly found a non-existent Object");
676 }
677 
686 {
687 public:
691  virtual ~BasicFindTestCase ();
692 
693 private:
694  virtual void DoRun (void);
695  virtual void DoTeardown (void);
696 };
697 
699  : TestCase ("Check low level Names::Find functionality")
700 {
701 }
702 
704 {
705 }
706 
707 void
709 {
710  Names::Clear ();
711 }
712 
713 void
715 {
716  Ptr<TestObject> found;
717 
718  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
719  Names::Add ("Name One", objectOne);
720 
721  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
722  Names::Add ("Name Two", objectTwo);
723 
724  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
725  Names::Add ("Name One/Child", childOfObjectOne);
726 
727  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
728  Names::Add ("Name Two/Child", childOfObjectTwo);
729 
730  found = Names::Find<TestObject> (Ptr<Object> (0, false), "Name One");
731  NS_TEST_ASSERT_MSG_EQ (found, objectOne, "Could not find a previously named Object via object context");
732 
733  found = Names::Find<TestObject> (Ptr<Object> (0, false), "Name Two");
734  NS_TEST_ASSERT_MSG_EQ (found, objectTwo, "Could not find a previously named Object via object context");
735 
736  found = Names::Find<TestObject> (objectOne, "Child");
737  NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne, "Could not find a previously named child Object via object context");
738 
739  found = Names::Find<TestObject> (objectTwo, "Child");
740  NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo, "Could not find a previously named child Object via object context");
741 }
742 
752 {
753 public:
757  virtual ~StringContextFindTestCase ();
758 
759 private:
760  virtual void DoRun (void);
761  virtual void DoTeardown (void);
762 };
763 
765  : TestCase ("Check string context-based Names::Find functionality")
766 {
767 }
768 
770 {
771 }
772 
773 void
775 {
776  Names::Clear ();
777 }
778 
779 void
781 {
782  Ptr<TestObject> found;
783 
784  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
785  Names::Add ("Name One", objectOne);
786 
787  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
788  Names::Add ("Name Two", objectTwo);
789 
790  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
791  Names::Add ("Name One/Child", childOfObjectOne);
792 
793  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
794  Names::Add ("Name Two/Child", childOfObjectTwo);
795 
796  found = Names::Find<TestObject> ("/Names", "Name One");
797  NS_TEST_ASSERT_MSG_EQ (found, objectOne, "Could not find a previously named Object via string context");
798 
799  found = Names::Find<TestObject> ("/Names", "Name Two");
800  NS_TEST_ASSERT_MSG_EQ (found, objectTwo, "Could not find a previously named Object via stribng context");
801 
802  found = Names::Find<TestObject> ("/Names/Name One", "Child");
803  NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne, "Could not find a previously named child Object via string context");
804 
805  found = Names::Find<TestObject> ("/Names/Name Two", "Child");
806  NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo, "Could not find a previously named child Object via string context");
807 }
808 
818 {
819 public:
823  virtual ~FullyQualifiedFindTestCase ();
824 
825 private:
826  virtual void DoRun (void);
827  virtual void DoTeardown (void);
828 };
829 
831  : TestCase ("Check fully qualified path Names::Find functionality")
832 {
833 }
834 
836 {
837 }
838 
839 void
841 {
842  Names::Clear ();
843 }
844 
845 void
847 {
848  Ptr<TestObject> found;
849 
850  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
851  Names::Add ("/Names/Name One", objectOne);
852 
853  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
854  Names::Add ("/Names/Name Two", objectTwo);
855 
856  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
857  Names::Add ("/Names/Name One/Child", childOfObjectOne);
858 
859  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
860  Names::Add ("/Names/Name Two/Child", childOfObjectTwo);
861 
862  found = Names::Find<TestObject> ("/Names/Name One");
863  NS_TEST_ASSERT_MSG_EQ (found, objectOne, "Could not find a previously named Object via string context");
864 
865  found = Names::Find<TestObject> ("/Names/Name Two");
866  NS_TEST_ASSERT_MSG_EQ (found, objectTwo, "Could not find a previously named Object via stribng context");
867 
868  found = Names::Find<TestObject> ("/Names/Name One/Child");
869  NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne, "Could not find a previously named child Object via string context");
870 
871  found = Names::Find<TestObject> ("/Names/Name Two/Child");
872  NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo, "Could not find a previously named child Object via string context");
873 }
874 
884 {
885 public:
889  virtual ~RelativeFindTestCase ();
890 
891 private:
892  virtual void DoRun (void);
893  virtual void DoTeardown (void);
894 };
895 
897  : TestCase ("Check relative path Names::Find functionality")
898 {
899 }
900 
902 {
903 }
904 
905 void
907 {
908  Names::Clear ();
909 }
910 
911 void
913 {
914  Ptr<TestObject> found;
915 
916  Ptr<TestObject> objectOne = CreateObject<TestObject> ();
917  Names::Add ("Name One", objectOne);
918 
919  Ptr<TestObject> objectTwo = CreateObject<TestObject> ();
920  Names::Add ("Name Two", objectTwo);
921 
922  Ptr<TestObject> childOfObjectOne = CreateObject<TestObject> ();
923  Names::Add ("Name One/Child", childOfObjectOne);
924 
925  Ptr<TestObject> childOfObjectTwo = CreateObject<TestObject> ();
926  Names::Add ("Name Two/Child", childOfObjectTwo);
927 
928  found = Names::Find<TestObject> ("Name One");
929  NS_TEST_ASSERT_MSG_EQ (found, objectOne, "Could not find a previously named Object via string context");
930 
931  found = Names::Find<TestObject> ("Name Two");
932  NS_TEST_ASSERT_MSG_EQ (found, objectTwo, "Could not find a previously named Object via stribng context");
933 
934  found = Names::Find<TestObject> ("Name One/Child");
935  NS_TEST_ASSERT_MSG_EQ (found, childOfObjectOne, "Could not find a previously named child Object via string context");
936 
937  found = Names::Find<TestObject> ("Name Two/Child");
938  NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo, "Could not find a previously named child Object via string context");
939 }
940 
947 {
948 public:
952  virtual ~AlternateFindTestCase ();
953 
954 private:
955  virtual void DoRun (void);
956  virtual void DoTeardown (void);
957 };
958 
960  : TestCase ("Check GetObject operation in Names::Find")
961 {
962 }
963 
965 {
966 }
967 
968 void
970 {
971  Names::Clear ();
972 }
973 
974 void
976 {
977  Ptr<TestObject> testObject = CreateObject<TestObject> ();
978  Names::Add ("Test Object", testObject);
979 
980  Ptr<AlternateTestObject> alternateTestObject = CreateObject<AlternateTestObject> ();
981  Names::Add ("Alternate Test Object", alternateTestObject);
982 
983  Ptr<TestObject> foundTestObject;
984  Ptr<AlternateTestObject> foundAlternateTestObject;
985 
986  foundTestObject = Names::Find<TestObject> ("Test Object");
987  NS_TEST_ASSERT_MSG_EQ (foundTestObject, testObject,
988  "Could not find a previously named TestObject via GetObject");
989 
990  foundAlternateTestObject = Names::Find<AlternateTestObject> ("Alternate Test Object");
991  NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, alternateTestObject,
992  "Could not find a previously named AlternateTestObject via GetObject");
993 
994 
995  foundAlternateTestObject = Names::Find<AlternateTestObject> ("Test Object");
996  NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, 0,
997  "Unexpectedly able to GetObject<AlternateTestObject> on a TestObject");
998 
999  foundTestObject = Names::Find<TestObject> ("Alternate Test Object");
1000  NS_TEST_ASSERT_MSG_EQ (foundTestObject, 0,
1001  "Unexpectedly able to GetObject<TestObject> on an AlternateTestObject");
1002 }
1003 
1009 {
1010 public:
1012  NamesTestSuite ();
1013 };
1014 
1016  : TestSuite ("object-name-service")
1017 {
1032 }
1033 
1039 
1040 
1041  } // namespace tests
1042 
1043 } // namespace ns3
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Test the Object Name Service can correctly use a string context.
Test the Object Name Service can find Objects.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
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 DoTeardown(void)
Implementation to do any local setup required for this TestCase.
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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~RelativeAddTestCase()
Destructor.
virtual ~BasicAddTestCase()
Destructor.
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.
Test the Object Name Service can correctly use a fully qualified path to add associations.
A suite of tests to run.
Definition: test.h:1342
Alternate test object for the Name service.
static TypeId GetTypeId(void)
Register this type.
Test the Object Name Service can look up an object and return its fully qualified path name...
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 void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
encapsulates test code
Definition: test.h:1155
static TypeId GetTypeId(void)
Register this type.
virtual ~FullyQualifiedAddTestCase()
Destructor.
virtual ~BasicRenameTestCase()
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~StringContextRenameTestCase()
Destructor.
Test the Object Name Service can find Objects using a second type.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
Definition: names.cc:770
virtual ~AlternateFindTestCase()
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test the Object Name Service can correctly use a relative path to add associations.
static void Clear(void)
Clear the list of objects associated with names.
Definition: names.cc:833
Test the Object Name Service can do its most basic job.
Test the Object Name Service can rename objects using a relative path name.
Simple test object to exercise the Name service.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run 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.
Definition: test.h:168
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual ~FullyQualifiedRenameTestCase()
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~RelativeFindTestCase()
Destructor.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
static NamesTestSuite g_namesTestSuite
NamesTestSuite instance variable.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
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:826
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~RelativeRenameTestCase()
Destructor.
virtual ~BasicFindTestCase()
Destructor.
Test the Object Name Service can rename objects using a fully qualified path name.
Test the Object Name Service can find Objects using a fully qualified path name.
virtual ~FindPathTestCase()
Destructor.
static void Rename(std::string oldpath, std::string newname)
Rename a previously associated name.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FullyQualifiedFindTestCase()
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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:819
Test the Object Name Service can find Objects using a string context.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
A base class which provides memory management and object aggregation.
Definition: object.h:87
Test the Object Name Service can find Objects using a relative path name.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual ~StringContextAddTestCase()
Destructor.
a unique identifier for an interface.
Definition: type-id.h:58
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915