20 #include "ns3/config.h" 
   22 #include "ns3/integer.h" 
   23 #include "ns3/traced-value.h" 
   24 #include "ns3/trace-source-accessor.h" 
   25 #include "ns3/callback.h" 
   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" 
   45   static TypeId GetTypeId (
void);
 
   53   int8_t GetA (
void) 
const;
 
   54   int8_t GetB (
void) 
const;
 
   57   std::vector<Ptr<ConfigTestObject> > m_nodesA;
 
   58   std::vector<Ptr<ConfigTestObject> > m_nodesB;
 
   67 ConfigTestObject::GetTypeId (
void)
 
   71     .AddAttribute (
"NodesA", 
"",
 
   73                    MakeObjectVectorAccessor (&ConfigTestObject::m_nodesA),
 
   74                    MakeObjectVectorChecker<ConfigTestObject> ())
 
   75     .AddAttribute (
"NodesB", 
"",
 
   77                    MakeObjectVectorAccessor (&ConfigTestObject::m_nodesB),
 
   78                    MakeObjectVectorChecker<ConfigTestObject> ())
 
   79     .AddAttribute (
"NodeA", 
"",
 
   81                    MakePointerAccessor (&ConfigTestObject::m_nodeA),
 
   82                    MakePointerChecker<ConfigTestObject> ())
 
   83     .AddAttribute (
"NodeB", 
"",
 
   85                    MakePointerAccessor (&ConfigTestObject::m_nodeB),
 
   86                    MakePointerChecker<ConfigTestObject> ())
 
   87     .AddAttribute (
"A", 
"",
 
   89                    MakeIntegerAccessor (&ConfigTestObject::m_a),
 
   90                    MakeIntegerChecker<int8_t> ())
 
   91     .AddAttribute (
"B", 
"",
 
   93                    MakeIntegerAccessor (&ConfigTestObject::m_b),
 
   94                    MakeIntegerChecker<int8_t> ())
 
   95     .AddAttribute (
"Source", 
"XX",
 
   97                    MakeIntegerAccessor (&ConfigTestObject::m_trace),
 
   98                    MakeIntegerChecker<int16_t> ())
 
   99     .AddTraceSource (
"Source", 
"XX",
 
  120   m_nodesA.push_back (a);
 
  126   m_nodesB.push_back (b);
 
  130 ConfigTestObject::GetA (
void)
 const 
  136 ConfigTestObject::GetB (
void)
 const 
  151   virtual void DoRun (
void);
 
  154 RootNamespaceConfigTestCase::RootNamespaceConfigTestCase ()
 
  155   : 
TestCase (
"Check ability to register a root namespace and use it")
 
  168   Config::RegisterRootNamespaceObject (root);
 
  174   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" not initialized as expected");
 
  182   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, 
"Object Attribute \"A\" not set correctly");
 
  188   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, 
"Object Attribute \"B\" not initialized as expected");
 
  196   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, 
"Object Attribute \"B\" not set correctly");
 
  209   virtual void DoRun (
void);
 
  212 UnderRootNamespaceConfigTestCase::UnderRootNamespaceConfigTestCase ()
 
  213   : 
TestCase (
"Check ability to register an object under the root namespace and use it")
 
  226   Config::RegisterRootNamespaceObject (root);
 
  235   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" not initialized as expected");
 
  243   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, 
"Object Attribute \"A\" not set correctly");
 
  250   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, 
"Object Attribute \"B\" not initialized as expected");
 
  258   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, 
"Object Attribute \"B\" not set correctly");
 
  265   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, 
"Object Attribute \"A\" unexpectedly set via bad path");
 
  269   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, 
"Object Attribute \"B\" unexpectedly set via bad path");
 
  280   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" not initialized as expected");
 
  281   b->GetAttribute (
"B", iv);
 
  282   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, 
"Object Attribute \"B\" not initialized as expected");
 
  292   b->GetAttribute (
"A", iv);
 
  293   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, 
"Object Attribute \"A\" not set as expected");
 
  294   b->GetAttribute (
"B", iv);
 
  295   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -4, 
"Object Attribute \"B\" not set as expected");
 
  303   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 2, 
"Object Attribute \"A\" not set correctly");
 
  304   b->GetAttribute (
"A", iv);
 
  305   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, 
"Object Attribute \"A\" not set correctly");
 
  318   virtual void DoRun (
void);
 
  321 ObjectVectorConfigTestCase::ObjectVectorConfigTestCase ()
 
  322   : 
TestCase (
"Check ability to configure vectors of Object using regular expressions")
 
  335   Config::RegisterRootNamespaceObject (root);
 
  367   Config::Set (
"/NodeA/NodeB/NodesB/0/A", 
IntegerValue (-11));
 
  369   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -11, 
"Object Attribute \"A\" not set as expected");
 
  371   obj1->GetAttribute (
"A", iv);
 
  372   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" unexpectedly set");
 
  374   obj2->GetAttribute (
"A", iv);
 
  375   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" unexpectedly set");
 
  377   obj3->GetAttribute (
"A", iv);
 
  378   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" unexpectedly set");
 
  384   Config::Set (
"/NodeA/NodeB/NodesB/0|1/A", 
IntegerValue (-12));
 
  386   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -12, 
"Object Attribute \"A\" not set as expected");
 
  388   obj1->GetAttribute (
"A", iv);
 
  389   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -12, 
"Object Attribute \"A\" not set as expected");
 
  391   obj2->GetAttribute (
"A", iv);
 
  392   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" unexpectedly set");
 
  394   obj3->GetAttribute (
"A", iv);
 
  395   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" unexpectedly set");
 
  400   Config::Set (
"/NodeA/NodeB/NodesB/|0|1|/A", 
IntegerValue (-13));
 
  402   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -13, 
"Object Attribute \"A\" not set as expected");
 
  404   obj1->GetAttribute (
"A", iv);
 
  405   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -13, 
"Object Attribute \"A\" not set as expected");
 
  407   obj2->GetAttribute (
"A", iv);
 
  408   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" unexpectedly set");
 
  410   obj3->GetAttribute (
"A", iv);
 
  411   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" unexpectedly set");
 
  416   Config::Set (
"/NodeA/NodeB/NodesB/[0-2]/A", 
IntegerValue (-14));
 
  418   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, 
"Object Attribute \"A\" not set as expected");
 
  420   obj1->GetAttribute (
"A", iv);
 
  421   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, 
"Object Attribute \"A\" not set as expected");
 
  423   obj2->GetAttribute (
"A", iv);
 
  424   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, 
"Object Attribute \"A\" not set as expected");
 
  426   obj3->GetAttribute (
"A", iv);
 
  427   NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, 
"Object Attribute \"A\" unexpectedly set");
 
  432   Config::Set (
"/NodeA/NodeB/NodesB/[1-3]/A", 
IntegerValue (-15));
 
  434   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, 
"Object Attribute \"A\" unexpectedly set");
 
  436   obj1->GetAttribute (
"A", iv);
 
  437   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, 
"Object Attribute \"A\" not set as expected");
 
  439   obj2->GetAttribute (
"A", iv);
 
  440   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, 
"Object Attribute \"A\" not set as expected");
 
  442   obj3->GetAttribute (
"A", iv);
 
  443   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, 
"Object Attribute \"A\" not set as expected");
 
  448   Config::Set (
"/NodeA/NodeB/NodesB/[0-1]|3/A", 
IntegerValue (-16));
 
  450   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, 
"Object Attribute \"A\" not set as expected");
 
  452   obj1->GetAttribute (
"A", iv);
 
  453   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, 
"Object Attribute \"A\" not set as expected");
 
  455   obj2->GetAttribute (
"A", iv);
 
  456   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, 
"Object Attribute \"A\" unexpectedly set");
 
  458   obj3->GetAttribute (
"A", iv);
 
  459   NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, 
"Object Attribute \"A\" not set as expected");
 
  471   void Trace (int16_t oldValue, int16_t newValue) { m_newValue = newValue; }
 
  472   void TraceWithPath (std::string path, int16_t old, int16_t newValue) { m_newValue = newValue; m_path = path; }
 
  475   virtual void DoRun (
void);
 
  481 ObjectVectorTraceConfigTestCase::ObjectVectorTraceConfigTestCase ()
 
  482   : 
TestCase (
"Check ability to trace connect through vectors of Object using regular expressions")
 
  495   Config::RegisterRootNamespaceObject (root);
 
  528   Config::ConnectWithoutContext (
"/NodeA/NodeB/NodesB/[0-1]|3/Source", 
 
  529                                  MakeCallback (&ObjectVectorTraceConfigTestCase::Trace, 
this));
 
  537   NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, 
"Trace 0 did not fire as expected");
 
  545   NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, 
"Trace 1 did not fire as expected");
 
  553   NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, 
"Trace 2 fired unexpectedly");
 
  561   NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, 
"Trace 3 did not fire as expected");
 
  566   Config::Connect (
"/NodeA/NodeB/NodesB/[0-1]|3/Source", 
 
  567                    MakeCallback (&ObjectVectorTraceConfigTestCase::TraceWithPath, 
this));
 
  576   NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, 
"Trace 0 did not fire as expected");
 
  577   NS_TEST_ASSERT_MSG_EQ (m_path, 
"/NodeA/NodeB/NodesB/0/Source", 
"Trace 0 did not provide expected context");
 
  586   NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, 
"Trace 1 did not fire as expected");
 
  587   NS_TEST_ASSERT_MSG_EQ (m_path, 
"/NodeA/NodeB/NodesB/1/Source", 
"Trace 1 did not provide expected context");
 
  596   NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, 
"Trace 2 fired unexpectedly");
 
  605   NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, 
"Trace 3 did not fire as expected");
 
  606   NS_TEST_ASSERT_MSG_EQ (m_path, 
"/NodeA/NodeB/NodesB/1/Source", 
"Trace 1 did not provide expected context");
 
  618 ConfigTestSuite::ConfigTestSuite ()
 
Hold a signed integer type. 
virtual void DoRun(void)
Implementation to actually run this test case. 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
hold objects of type Ptr<T> 
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void GetAttribute(std::string name, AttributeValue &value) const 
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite. 
virtual void DoRun(void)
Implementation to actually run this test case. 
virtual void DoRun(void)
Implementation to actually run this test case. 
a base class which provides memory management and object aggregation 
contain a set of ns3::Object pointers. 
void SetAttribute(std::string name, const AttributeValue &value)
a unique identifier for an interface. 
TypeId SetParent(TypeId tid)
virtual void DoRun(void)
Implementation to actually run this test case.