A Discrete-Event Network Simulator
API
config-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "ns3/config.h"
21 #include "ns3/test.h"
22 #include "ns3/integer.h"
23 #include "ns3/traced-value.h"
24 #include "ns3/trace-source-accessor.h"
25 #include "ns3/callback.h"
26 
27 #include "ns3/singleton.h"
28 #include "ns3/object.h"
29 #include "ns3/object-vector.h"
30 #include "ns3/names.h"
31 #include "ns3/pointer.h"
32 #include "ns3/log.h"
33 #include "ns3/unused.h"
34 
35 
36 #include <sstream>
37 
51 namespace ns3 {
52 
53 namespace tests {
54 
55 
60 class ConfigTestObject : public Object
61 {
62 public:
67  static TypeId GetTypeId (void);
68 
79 
90 
95  int8_t GetA (void) const;
100  int8_t GetB (void) const;
101 
102 private:
103  std::vector<Ptr<ConfigTestObject> > m_nodesA;
104  std::vector<Ptr<ConfigTestObject> > m_nodesB;
107  int8_t m_a;
108  int8_t m_b;
110 };
111 
112 TypeId
114 {
115  static TypeId tid = TypeId ("ConfigTestObject")
116  .SetParent<Object> ()
117  .AddAttribute ("NodesA", "",
120  MakeObjectVectorChecker<ConfigTestObject> ())
121  .AddAttribute ("NodesB", "",
124  MakeObjectVectorChecker<ConfigTestObject> ())
125  .AddAttribute ("NodeA", "",
126  PointerValue (),
128  MakePointerChecker<ConfigTestObject> ())
129  .AddAttribute ("NodeB", "",
130  PointerValue (),
132  MakePointerChecker<ConfigTestObject> ())
133  .AddAttribute ("A", "",
134  IntegerValue (10),
136  MakeIntegerChecker<int8_t> ())
137  .AddAttribute ("B", "",
138  IntegerValue (9),
140  MakeIntegerChecker<int8_t> ())
141  .AddAttribute ("Source", "XX",
142  IntegerValue (-1),
144  MakeIntegerChecker<int16_t> ())
145  .AddTraceSource ("Source", "XX",
147  "ns3::TracedValueCallback::Int16")
148  ;
149  return tid;
150 }
151 
152 void
154 {
155  m_nodeA = a;
156 }
157 
158 void
160 {
161  m_nodeB = b;
162 }
163 
164 void
166 {
167  m_nodesA.push_back (a);
168 }
169 
170 void
172 {
173  m_nodesB.push_back (b);
174 }
175 
176 int8_t
178 {
179  return m_a;
180 }
181 
182 int8_t
184 {
185  return m_b;
186 }
187 
193 {
194 public:
199  static TypeId GetTypeId (void);
202  {}
205  {}
206 };
207 
208 TypeId
210 {
211  static TypeId tid = TypeId ("DerivedConfigTestObject")
213  ;
214  return tid;
215 }
216 
221 class BaseConfigObject : public Object
222 {
223 public:
228  static TypeId GetTypeId (void);
230  BaseConfigObject (void) : m_x (15)
231  {}
233  virtual ~BaseConfigObject (void)
234  {}
235 
236 private:
237  int8_t m_x;
238 
239  void Increment (void)
240  {
241  m_x++;
242  }
243 };
244 
245 TypeId
247 {
248  static TypeId tid = TypeId ("BaseConfigObject")
249  .SetParent<Object> ()
250  .AddAttribute ("X", "",
251  IntegerValue (10),
253  MakeIntegerChecker<int8_t> ())
254  ;
255  return tid;
256 }
257 
263 {
264 public:
269  static TypeId GetTypeId (void);
272  {}
274  virtual ~DerivedConfigObject (void)
275  {}
276 };
277 
278 TypeId
280 {
281  static TypeId tid = TypeId ("DerivedConfigObject")
283  ;
284  return tid;
285 }
286 
287 
293 {
294 public:
299  {}
300 
301 private:
302  virtual void DoRun (void);
303 };
304 
306  : TestCase ("Check ability to register a root namespace and use it")
307 {}
308 
309 void
311 {
312  IntegerValue iv;
313  //
314  // Create an object and register its attributes directly in the root
315  // namespace.
316  //
317  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
319 
320  //
321  // We should find the default values there.
322  //
323  root->GetAttribute ("A", iv);
324  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
325 
326  //
327  // Now use the config mechanism to set the attribute; and we should find the
328  // new value.
329  //
330  Config::Set ("/A", IntegerValue (1));
331  root->GetAttribute ("A", iv);
332  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" not set correctly");
333 
334  //
335  // We should find the default values of "B" too.
336  //
337  root->GetAttribute ("B", iv);
338  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
339 
340  //
341  // Now use the config mechanism to set the attribute; and we should find the
342  // new value.
343  //
344  Config::Set ("/B", IntegerValue (-1));
345  root->GetAttribute ("B", iv);
346  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" not set correctly");
347 }
348 
354 {
355 public:
360  {}
361 
362 private:
363  virtual void DoRun (void);
364 };
365 
367  : TestCase ("Check ability to register an object under the root namespace and use it")
368 {}
369 
370 void
372 {
373  IntegerValue iv;
374  //
375  // Create an object and register its attributes directly in the root
376  // namespace.
377  //
378  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
380 
381  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
382  root->SetNodeA (a);
383 
384  //
385  // We should find the default values there.
386  //
387  a->GetAttribute ("A", iv);
388  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
389 
390  //
391  // Now use the config mechanism to set the attribute; and we should find the
392  // new value.
393  //
394  Config::Set ("/NodeA/A", IntegerValue (1));
395  a->GetAttribute ("A", iv);
396  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" not set correctly");
397 
398 
399  //
400  // We should find the default values of "B" too.
401  //
402  a->GetAttribute ("B", iv);
403  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
404 
405  //
406  // Now use the config mechanism to set the attribute; and we should find the
407  // new value.
408  //
409  Config::Set ("/NodeA/B", IntegerValue (-1));
410  a->GetAttribute ("B", iv);
411  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" not set correctly");
412 
413  //
414  // Try and set through a nonexistent path. Should do nothing.
415  //
416  Config::Set ("/NodeB/A", IntegerValue (1234));
417  a->GetAttribute ("A", iv);
418  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" unexpectedly set via bad path");
419 
420  Config::Set ("/NodeB/B", IntegerValue (1234));
421  a->GetAttribute ("B", iv);
422  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" unexpectedly set via bad path");
423 
424  //
425  // Step down one level of recursion and try again
426  //
427  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
428 
429  //
430  // We should find the default values there.
431  //
432  b->GetAttribute ("A", iv);
433  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
434  b->GetAttribute ("B", iv);
435  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
436 
437  //
438  // Now tell A that it has a B; and we should be able to set this new object's
439  // Attributes.
440  //
441  a->SetNodeB (b);
442 
443  Config::Set ("/NodeA/NodeB/A", IntegerValue (4));
444  Config::Set ("/NodeA/NodeB/B", IntegerValue (-4));
445  b->GetAttribute ("A", iv);
446  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set as expected");
447  b->GetAttribute ("B", iv);
448  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -4, "Object Attribute \"B\" not set as expected");
449 
450 
451  //
452  // Try '*' for attributes
453  //
454  Config::Set ("/*/A", IntegerValue (2));
455  a->GetAttribute ("A", iv);
456  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 2, "Object Attribute \"A\" not set correctly");
457  b->GetAttribute ("A", iv);
458  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set correctly");
459 }
460 
466 {
467 public:
472  {}
473 
474 private:
475  virtual void DoRun (void);
476 };
477 
479  : TestCase ("Check ability to configure vectors of Object using regular expressions")
480 {}
481 
482 void
484 {
485  IntegerValue iv;
486 
487  //
488  // Create a root namespace object
489  //
490  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
492 
493  //
494  // Create an object under the root.
495  //
496  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
497  root->SetNodeA (a);
498 
499  //
500  // Create an object one level down.
501  //
502  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
503  a->SetNodeB (b);
504 
505  //
506  // Add four objects to the ObjectVector Attribute at the bottom of the
507  // object hierarchy. By this point, we believe that the Attributes
508  // will be initialized correctly.
509  //
510  Ptr<ConfigTestObject> obj0 = CreateObject<ConfigTestObject> ();
511  Ptr<ConfigTestObject> obj1 = CreateObject<ConfigTestObject> ();
512  Ptr<ConfigTestObject> obj2 = CreateObject<ConfigTestObject> ();
513  Ptr<ConfigTestObject> obj3 = CreateObject<ConfigTestObject> ();
514  b->AddNodeB (obj0);
515  b->AddNodeB (obj1);
516  b->AddNodeB (obj2);
517  b->AddNodeB (obj3);
518 
519  //
520  // Set an Attribute of the zeroth Object in the vector by explicitly writing
521  // the '0' and make sure that only the one thing changed.
522  //
523  Config::Set ("/NodeA/NodeB/NodesB/0/A", IntegerValue (-11));
524  obj0->GetAttribute ("A", iv);
525  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -11, "Object Attribute \"A\" not set as expected");
526 
527  obj1->GetAttribute ("A", iv);
528  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
529 
530  obj2->GetAttribute ("A", iv);
531  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
532 
533  obj3->GetAttribute ("A", iv);
534  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
535 
536  //
537  // Start using regular expression-like syntax to set Attributes. First try
538  // the OR syntax. Make sure that the two objects changed and nothing else
539  //
540  Config::Set ("/NodeA/NodeB/NodesB/0|1/A", IntegerValue (-12));
541  obj0->GetAttribute ("A", iv);
542  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -12, "Object Attribute \"A\" not set as expected");
543 
544  obj1->GetAttribute ("A", iv);
545  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -12, "Object Attribute \"A\" not set as expected");
546 
547  obj2->GetAttribute ("A", iv);
548  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
549 
550  obj3->GetAttribute ("A", iv);
551  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
552 
553  //
554  // Make sure that extra '|' are allowed at the start and end of the regular expression
555  //
556  Config::Set ("/NodeA/NodeB/NodesB/|0|1|/A", IntegerValue (-13));
557  obj0->GetAttribute ("A", iv);
558  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -13, "Object Attribute \"A\" not set as expected");
559 
560  obj1->GetAttribute ("A", iv);
561  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -13, "Object Attribute \"A\" not set as expected");
562 
563  obj2->GetAttribute ("A", iv);
564  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
565 
566  obj3->GetAttribute ("A", iv);
567  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
568 
569  //
570  // Try the [x-y] syntax
571  //
572  Config::Set ("/NodeA/NodeB/NodesB/[0-2]/A", IntegerValue (-14));
573  obj0->GetAttribute ("A", iv);
574  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
575 
576  obj1->GetAttribute ("A", iv);
577  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
578 
579  obj2->GetAttribute ("A", iv);
580  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
581 
582  obj3->GetAttribute ("A", iv);
583  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
584 
585  //
586  // Try the [x-y] syntax at the other limit
587  //
588  Config::Set ("/NodeA/NodeB/NodesB/[1-3]/A", IntegerValue (-15));
589  obj0->GetAttribute ("A", iv);
590  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" unexpectedly set");
591 
592  obj1->GetAttribute ("A", iv);
593  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
594 
595  obj2->GetAttribute ("A", iv);
596  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
597 
598  obj3->GetAttribute ("A", iv);
599  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
600 
601  //
602  // Combine the [x-y] syntax and the OR sntax
603  //
604  Config::Set ("/NodeA/NodeB/NodesB/[0-1]|3/A", IntegerValue (-16));
605  obj0->GetAttribute ("A", iv);
606  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
607 
608  obj1->GetAttribute ("A", iv);
609  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
610 
611  obj2->GetAttribute ("A", iv);
612  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" unexpectedly set");
613 
614  obj3->GetAttribute ("A", iv);
615  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
616 }
617 
623 {
624 public:
629  {}
630 
636  void Trace (int16_t oldValue, int16_t newValue)
637  {
638  NS_UNUSED (oldValue);
639  m_newValue = newValue;
640  }
647  void TraceWithPath (std::string path, int16_t old, int16_t newValue)
648  {
649  NS_UNUSED (old);
650  m_newValue = newValue;
651  m_path = path;
652  }
653 
654 private:
655  virtual void DoRun (void);
656 
657  int16_t m_newValue;
658  std::string m_path;
659 };
660 
662  : TestCase ("Check ability to trace connect through vectors of Object using regular expressions")
663 {}
664 
665 void
667 {
668  IntegerValue iv;
669 
670  //
671  // Create a root namespace object
672  //
673  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
675 
676  //
677  // Create an object under the root.
678  //
679  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
680  root->SetNodeA (a);
681 
682  //
683  // Create an object one level down.
684  //
685  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
686  a->SetNodeB (b);
687 
688  //
689  // Add four objects to the ObjectVector Attribute at the bottom of the
690  // object hierarchy. By this point, we believe that the Attributes
691  // will be initialized correctly.
692  //
693  Ptr<ConfigTestObject> obj0 = CreateObject<ConfigTestObject> ();
694  Ptr<ConfigTestObject> obj1 = CreateObject<ConfigTestObject> ();
695  Ptr<ConfigTestObject> obj2 = CreateObject<ConfigTestObject> ();
696  Ptr<ConfigTestObject> obj3 = CreateObject<ConfigTestObject> ();
697  b->AddNodeB (obj0);
698  b->AddNodeB (obj1);
699  b->AddNodeB (obj2);
700  b->AddNodeB (obj3);
701 
702  //
703  // Do a trace connect to some of the sources. We already checked parsing of
704  // the regular expressions, so we'll concentrate on the tracing part of the
705  // puzzle here.
706  //
707  Config::ConnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
709 
710  //
711  // If we bug the trace source referred to by index '0' above, we should see
712  // the trace fire.
713  //
714  m_newValue = 0;
715  obj0->SetAttribute ("Source", IntegerValue (-1));
716  NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, "Trace 0 did not fire as expected");
717 
718  //
719  // If we bug the trace source referred to by index '1' above, we should see
720  // the trace fire.
721  //
722  m_newValue = 0;
723  obj1->SetAttribute ("Source", IntegerValue (-2));
724  NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, "Trace 1 did not fire as expected");
725 
726  //
727  // If we bug the trace source referred to by index '2' which is skipped above,
728  // we should not see the trace fire.
729  //
730  m_newValue = 0;
731  obj2->SetAttribute ("Source", IntegerValue (-3));
732  NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, "Trace 2 fired unexpectedly");
733 
734  //
735  // If we bug the trace source referred to by index '3' above, we should see
736  // the trace fire.
737  //
738  m_newValue = 0;
739  obj3->SetAttribute ("Source", IntegerValue (-4));
740  NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, "Trace 3 did not fire as expected");
741 
742  //
743  // Do a trace connect (with context) to some of the sources.
744  //
745  Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
747 
748  //
749  // If we bug the trace source referred to by index '0' above, we should see
750  // the trace fire with the expected context path.
751  //
752  m_newValue = 0;
753  m_path = "";
754  obj0->SetAttribute ("Source", IntegerValue (-1));
755  NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, "Trace 0 did not fire as expected");
756  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/0/Source", "Trace 0 did not provide expected context");
757 
758  //
759  // If we bug the trace source referred to by index '1' above, we should see
760  // the trace fire with the expected context path.
761  //
762  m_newValue = 0;
763  m_path = "";
764  obj1->SetAttribute ("Source", IntegerValue (-2));
765  NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, "Trace 1 did not fire as expected");
766  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/1/Source", "Trace 1 did not provide expected context");
767 
768  //
769  // If we bug the trace source referred to by index '2' which is skipped above,
770  // we should not see the trace fire.
771  //
772  m_newValue = 0;
773  m_path = "";
774  obj2->SetAttribute ("Source", IntegerValue (-3));
775  NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, "Trace 2 fired unexpectedly");
776 
777  //
778  // If we bug the trace source referred to by index '3' above, we should see
779  // the trace fire with the expected context path.
780  //
781  m_newValue = 0;
782  m_path = "";
783  obj3->SetAttribute ("Source", IntegerValue (-4));
784  NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, "Trace 3 did not fire as expected");
785  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/1/Source", "Trace 1 did not provide expected context");
786 }
787 
797 {
798 public:
803  {}
804 
805 private:
806  virtual void DoRun (void);
807 
808 };
809 
811  : TestCase ("Check that attributes of base class are searchable from paths including objects of derived class")
812 {}
813 
814 void
816 {
817  IntegerValue iv;
818  //
819  // Create a root namespace object that doesn't have attributes but
820  // whose parent class has 'NodeA' attribute
821  //
822  Ptr<DerivedConfigTestObject> root = CreateObject<DerivedConfigTestObject> ();
824 
825  //
826  // Instantiate /NodeA
827  //
828  Ptr<DerivedConfigTestObject> a = CreateObject<DerivedConfigTestObject> ();
829  root->SetNodeA (a);
830 
831  //
832  // BaseConfigObject has attribute X, but we aggregate DerivedConfigObject
833  // instead
834  //
835  Ptr<DerivedConfigObject> derived = CreateObject<DerivedConfigObject> ();
836  a->AggregateObject (derived);
837  Config::Set ("/NodeA/$DerivedConfigObject/X", IntegerValue (42));
838  derived->GetAttribute ("X", iv);
839  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 42, "Object Attribute \"X\" not settable in derived class");
840 
841 }
842 
848 {
849 public:
851  ConfigTestSuite ();
852 };
853 
855  : TestSuite ("config")
856 {
861 }
862 
868 
869 
870 } // namespace tests
871 
872 } // namespace ns3
873 
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
void TraceWithPath(std::string path, int16_t old, int16_t newValue)
Trace callback with context path.
Test for the ability to register and use a root namespace.
void AddNodeA(Ptr< ConfigTestObject > a)
Add node A function.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
BaseConfigObject(void)
Constructor.
virtual ~BaseConfigObject(void)
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~RootNamespaceConfigTestCase()
Destructor.
static TypeId GetTypeId(void)
Get the type ID.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:839
A suite of tests to run.
Definition: test.h:1343
static TypeId GetTypeId(void)
Get the type ID.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-vector.h:81
static ConfigTestSuite g_configTestSuite
ConfigTestSuite instance variable.
Hold a signed integer type.
Definition: integer.h:44
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
void SetNodeA(Ptr< ConfigTestObject > a)
Set node A function.
Test for the ability to search attributes of parent classes when Resolver searches for attributes in ...
Test for the ability to trace configure with vectors of objects.
encapsulates test code
Definition: test.h:1153
virtual ~ObjectVectorConfigTestCase()
Destructor.
void RegisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:944
Ptr< ConfigTestObject > m_nodeB
NodeB attribute target.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
int8_t m_a
A attribute target.
The Test Suite that glues all of the Test Cases together.
Test for the ability to add an object under the root namespace.
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: integer.h:45
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:227
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::vector< Ptr< ConfigTestObject > > m_nodesA
NodesA attribute target.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ptr< ConfigTestObject > m_nodeA
NodeA attribute target.
TracedValue< int16_t > m_trace
Source TraceSource target.
#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:166
void SetNodeB(Ptr< ConfigTestObject > b)
Set node b function.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:899
virtual ~DerivedConfigObject(void)
Destructor.
void AddNodeB(Ptr< ConfigTestObject > b)
Add node B function.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:918
An object with some attributes that we can play with using config.
void Increment(void)
Silence unused variable warning.
int8_t m_b
B attribute target.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
std::vector< Ptr< ConfigTestObject > > m_nodesB
NodesB attribute target.
int8_t m_x
X attribute target.
int8_t GetB(void) const
Get node b function.
int16_t m_newValue
Flag to detect tracing result.
int8_t GetA(void) const
Get node A function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~DerivedConfigTestObject(void)
Destructor.
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void DoRun(void)
Implementation to actually run this TestCase.
Container for a set of ns3::Object pointers.
Test for the ability to deal configure with vectors of objects.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
void Trace(int16_t oldValue, int16_t newValue)
Trace callback without context.
int64_t Get(void) const
Definition: integer.cc:35