remove, not ifdef out

This commit is contained in:
Craig Dowell
2009-09-25 17:39:44 -07:00
parent c1711788e0
commit 4e68f4c711

View File

@@ -1289,207 +1289,3 @@ ConfigTestSuite::ConfigTestSuite ()
ConfigTestSuite configTestSuite;
} // namespace ns3
#if 0
#ifdef RUN_SELF_TESTS
#include "test.h"
#include "integer.h"
#include "traced-value.h"
#include "trace-source-accessor.h"
#include "callback.h"
namespace ns3 {
class ConfigTest : public Test
{
public:
ConfigTest ();
virtual bool RunTests (void);
private:
void ChangeNotification (int16_t old, int16_t newValue);
void ChangeNotificationWithPath (std::string path, int16_t old, int16_t newValue);
int16_t m_traceNotification;
std::string m_tracePath;
};
static ConfigTest g_configTestUnique;
ConfigTest::ConfigTest ()
: Test ("Config")
{}
void
ConfigTest::ChangeNotification (int16_t oldValue, int16_t newValue)
{
m_traceNotification = newValue;
}
void
ConfigTest::ChangeNotificationWithPath (std::string path, int16_t old, int16_t newValue)
{
m_traceNotification = newValue;
m_tracePath = path;
}
bool
ConfigTest::RunTests (void)
{
bool result = true;
Ptr<MyNode> root = CreateObject<MyNode> ();
Config::RegisterRootNamespaceObject (root);
Config::Set ("/A", IntegerValue (1));
Config::Set ("/B", IntegerValue (-1));
IntegerValue v;
root->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), 1);
root->GetAttribute ("B", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -1);
Ptr<MyNode> a = CreateObject<MyNode> ();
root->SetNodeA (a);
Config::Set ("/NodeA/A", IntegerValue (2));
Config::Set ("/NodeA/B", IntegerValue (-2));
a->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), 2);
a->GetAttribute ("B", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -2);
Config::Set ("/NodeB/A", IntegerValue (3));
Config::Set ("/NodeB/B", IntegerValue (-3));
a->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), 2);
a->GetAttribute ("B", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -2);
Ptr<MyNode> b = CreateObject<MyNode> ();
a->SetNodeB (b);
Config::Set ("/NodeA/NodeB/A", IntegerValue (4));
Config::Set ("/NodeA/NodeB/B", IntegerValue (-4));
b->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), 4);
b->GetAttribute ("B", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -4);
Ptr<MyNode> c = CreateObject<MyNode> ();
root->SetNodeB (c);
Config::Set ("/NodeB/A", IntegerValue (5));
Config::Set ("/NodeB/B", IntegerValue (-5));
c->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), 5);
c->GetAttribute ("B", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -5);
Ptr<MyNode> d0 = CreateObject<MyNode> ();
Ptr<MyNode> d1 = CreateObject<MyNode> ();
Ptr<MyNode> d2 = CreateObject<MyNode> ();
Ptr<MyNode> d3 = CreateObject<MyNode> ();
b->AddNodeB (d0);
b->AddNodeB (d1);
b->AddNodeB (d2);
b->AddNodeB (d3);
Config::Set ("/NodeA/NodeB/NodesB/0/A", IntegerValue (-11));
d0->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -11);
d0->GetAttribute ("B", v);
NS_TEST_ASSERT_EQUAL (v.Get (), 9);
d1->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), 10);
d1->GetAttribute ("B", v);
NS_TEST_ASSERT_EQUAL (v.Get (), 9);
Config::Set ("/NodeA/NodeB/NodesB/0|1/A", IntegerValue (-12));
d0->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -12);
d1->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -12);
Config::Set ("/NodeA/NodeB/NodesB/|0|1|/A", IntegerValue (-13));
d0->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -13);
d1->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -13);
Config::Set ("/NodeA/NodeB/NodesB/[0-2]/A", IntegerValue (-14));
d0->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -14);
d1->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -14);
d2->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -14);
Config::Set ("/NodeA/NodeB/NodesB/[1-3]/A", IntegerValue (-15));
d0->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -14);
d1->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -15);
d2->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -15);
d3->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -15);
Config::Set ("/NodeA/NodeB/NodesB/[0-1]|3/A", IntegerValue (-16));
d0->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -16);
d1->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -16);
d2->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -15);
d3->GetAttribute ("A", v);
NS_TEST_ASSERT_EQUAL (v.Get (), -16);
Config::ConnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
MakeCallback (&ConfigTest::ChangeNotification, this));
m_traceNotification = 0;
// this should trigger no notification
d2->SetAttribute ("Source", IntegerValue (-2));
NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
m_traceNotification = 0;
// this should trigger a notification
d1->SetAttribute ("Source", IntegerValue (-3));
NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
Config::DisconnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
MakeCallback (&ConfigTest::ChangeNotification, this));
m_traceNotification = 0;
// this should _not_ trigger a notification
d1->SetAttribute ("Source", IntegerValue (-4));
NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
m_traceNotification = 0;
// this should trigger no notification
d2->SetAttribute ("Source", IntegerValue (-2));
NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
m_traceNotification = 0;
m_tracePath = "";
// this should trigger a notification
d1->SetAttribute ("Source", IntegerValue (-3));
NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
NS_TEST_ASSERT_EQUAL (m_tracePath, "/NodeA/NodeB/NodesB/1/Source");
m_traceNotification = 0;
m_tracePath = "";
// this should trigger a notification
d3->SetAttribute ("Source", IntegerValue (-3));
NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
NS_TEST_ASSERT_EQUAL (m_tracePath, "/NodeA/NodeB/NodesB/3/Source");
Config::Disconnect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
m_traceNotification = 0;
// this should _not_ trigger a notification
d1->SetAttribute ("Source", IntegerValue (-4));
NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
//
// The Config system is intertwined with the Names system. In the process
// of parsing the paths above, we also created a NamesPriv singleton. In
// order to get a valgrind-clean run we need to clean up that singleton.
//
Names::Delete ();
return result;
}
} // namespace ns3
#endif /* RUN_SELF_TEST */
#endif // 0