Remove and replace Callback unit test, add examples to test.py

This commit is contained in:
Craig Dowell
2009-09-25 14:10:28 -07:00
parent 58566fbb42
commit 8c2d2cb0dd
5 changed files with 619 additions and 328 deletions

View File

@@ -0,0 +1,602 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009 University of Washington
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "test.h"
#include "callback.h"
#include <stdint.h>
namespace ns3 {
class X : public ns3::Test
{
public:
X () : Test ("Callback") {}
void PublicParent (void) {}
protected:
static void StaticProtectedParent (void) {}
void ProtectedParent (void) {}
private:
void PrivateParent (void) {}
};
// ===========================================================================
// Test the basic Callback mechanism
// ===========================================================================
class BasicCallbackTestCase : public TestCase
{
public:
BasicCallbackTestCase ();
virtual ~BasicCallbackTestCase () {}
void Target1 (void) {m_test1 = true;}
int Target2 (void) {m_test2 = true; return 2;}
void Target3 (double a) {m_test3 = true;}
int Target4 (double a, int b) {m_test4 = true; return 4;}
private:
virtual bool DoRun (void);
virtual void DoSetup (void);
bool m_test1;
bool m_test2;
bool m_test3;
bool m_test4;
};
static bool gBasicCallbackTest5;
static bool gBasicCallbackTest6;
static bool gBasicCallbackTest7;
void
BasicCallbackTarget5 (void)
{
gBasicCallbackTest5 = true;
}
void
BasicCallbackTarget6 (int)
{
gBasicCallbackTest6 = true;
}
int
BasicCallbackTarget7 (int a)
{
gBasicCallbackTest7 = true;
return a;
}
BasicCallbackTestCase::BasicCallbackTestCase ()
: TestCase ("Check basic Callback mechansim")
{
}
void
BasicCallbackTestCase::DoSetup (void)
{
m_test1 = false;
m_test2 = false;
m_test3 = false;
m_test4 = false;
gBasicCallbackTest5 = false;
gBasicCallbackTest6 = false;
gBasicCallbackTest7 = false;
}
bool
BasicCallbackTestCase::DoRun (void)
{
//
// Make sure we can declare and compile a Callback pointing to a member
// function returning void and execute it.
//
Callback<void> target1 (this, &BasicCallbackTestCase::Target1);
target1 ();
NS_TEST_ASSERT_MSG_EQ (m_test1, true, "Callback did not fire");
//
// Make sure we can declare and compile a Callback pointing to a member
// function that returns an int and execute it.
//
Callback<int> target2;
target2 = Callback<int> (this, &BasicCallbackTestCase::Target2);
target2 ();
NS_TEST_ASSERT_MSG_EQ (m_test2, true, "Callback did not fire");
//
// Make sure we can declare and compile a Callback pointing to a member
// function that returns void, takes a double parameter, and execute it.
//
Callback<void, double> target3 = Callback<void, double> (this, &BasicCallbackTestCase::Target3);
target3 (0.0);
NS_TEST_ASSERT_MSG_EQ (m_test3, true, "Callback did not fire");
//
// Make sure we can declare and compile a Callback pointing to a member
// function that returns void, takes two parameters, and execute it.
//
Callback<int, double, int> target4 = Callback<int, double, int> (this, &BasicCallbackTestCase::Target4);
target4 (0.0, 1);
NS_TEST_ASSERT_MSG_EQ (m_test4, true, "Callback did not fire");
//
// Make sure we can declare and compile a Callback pointing to a non-member
// function that returns void, and execute it. This is a lower level call
// than MakeCallback so we have got to include at least two arguments to make
// sure that the constructor is properly disambiguated. If the arguments are
// not needed, we just pass in dummy values.
//
Callback<void> target5 = Callback<void> (&BasicCallbackTarget5, true, true);
target5 ();
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest5, true, "Callback did not fire");
//
// Make sure we can declare and compile a Callback pointing to a non-member
// function that returns void, takes one integer argument and execute it.
// We also need to provide two dummy arguments to the constructor here.
//
Callback<void, int> target6 = Callback<void, int> (&BasicCallbackTarget6, true, true);
target6 (1);
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest6, true, "Callback did not fire");
//
// Make sure we can declare and compile a Callback pointing to a non-member
// function that returns int, takes one integer argument and execute it.
// We also need to provide two dummy arguments to the constructor here.
//
Callback<int, int> target7 = Callback<int, int> (&BasicCallbackTarget7, true, true);
target7 (1);
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest7, true, "Callback did not fire");
return GetErrorStatus ();
}
// ===========================================================================
// Test the MakeCallback mechanism
// ===========================================================================
class MakeCallbackTestCase : public TestCase
{
public:
MakeCallbackTestCase ();
virtual ~MakeCallbackTestCase () {}
void Target1 (void) {m_test1 = true;}
int Target2 (void) {m_test2 = true; return 2;}
void Target3 (double a) {m_test3 = true;}
int Target4 (double a, int b) {m_test4 = true; return 4;}
private:
virtual bool DoRun (void);
virtual void DoSetup (void);
bool m_test1;
bool m_test2;
bool m_test3;
bool m_test4;
};
static bool gMakeCallbackTest5;
static bool gMakeCallbackTest6;
static bool gMakeCallbackTest7;
void
MakeCallbackTarget5 (void)
{
gMakeCallbackTest5 = true;
}
void
MakeCallbackTarget6 (int)
{
gMakeCallbackTest6 = true;
}
int
MakeCallbackTarget7 (int a)
{
gMakeCallbackTest7 = true;
return a;
}
MakeCallbackTestCase::MakeCallbackTestCase ()
: TestCase ("Check MakeCallback() mechanism")
{
}
void
MakeCallbackTestCase::DoSetup (void)
{
m_test1 = false;
m_test2 = false;
m_test3 = false;
m_test4 = false;
gMakeCallbackTest5 = false;
gMakeCallbackTest6 = false;
gMakeCallbackTest7 = false;
}
bool
MakeCallbackTestCase::DoRun (void)
{
//
// Make sure we can declare and make a Callback pointing to a member
// function returning void and execute it.
//
Callback<void> target1 = MakeCallback (&MakeCallbackTestCase::Target1, this);
target1 ();
NS_TEST_ASSERT_MSG_EQ (m_test1, true, "Callback did not fire");
//
// Make sure we can declare and make a Callback pointing to a member
// function that returns an int and execute it.
//
Callback<int> target2 = MakeCallback (&MakeCallbackTestCase::Target2, this);
target2 ();
NS_TEST_ASSERT_MSG_EQ (m_test2, true, "Callback did not fire");
//
// Make sure we can declare and make a Callback pointing to a member
// function that returns void, takes a double parameter, and execute it.
//
Callback<void, double> target3 = MakeCallback (&MakeCallbackTestCase::Target3, this);
target3 (0.0);
NS_TEST_ASSERT_MSG_EQ (m_test3, true, "Callback did not fire");
//
// Make sure we can declare and make a Callback pointing to a member
// function that returns void, takes two parameters, and execute it.
//
Callback<int, double, int> target4 = MakeCallback (&MakeCallbackTestCase::Target4, this);
target4 (0.0, 1);
NS_TEST_ASSERT_MSG_EQ (m_test4, true, "Callback did not fire");
//
// Make sure we can declare and make a Callback pointing to a non-member
// function that returns void, and execute it. This uses a higher level call
// than in the basic tests so we do not need to include any dummy arguments
// here.
//
Callback<void> target5 = MakeCallback (&MakeCallbackTarget5);
target5 ();
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest5, true, "Callback did not fire");
//
// Make sure we can declare and compile a Callback pointing to a non-member
// function that returns void, takes one integer argument and execute it.
// This uses a higher level call than in the basic tests so we do not need to
// include any dummy arguments here.
//
Callback<void, int> target6 = MakeCallback (&MakeCallbackTarget6);
target6 (1);
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest6, true, "Callback did not fire");
//
// Make sure we can declare and compile a Callback pointing to a non-member
// function that returns int, takes one integer argument and execute it.
// This uses a higher level call than in the basic tests so we do not need to
// include any dummy arguments here.
//
Callback<int, int> target7 = MakeCallback (&MakeCallbackTarget7);
target7 (1);
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest7, true, "Callback did not fire");
return GetErrorStatus ();
}
// ===========================================================================
// Test the MakeBoundCallback mechanism
// ===========================================================================
class MakeBoundCallbackTestCase : public TestCase
{
public:
MakeBoundCallbackTestCase ();
virtual ~MakeBoundCallbackTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoSetup (void);
};
static int gMakeBoundCallbackTest1;
static bool *gMakeBoundCallbackTest2;
static bool *gMakeBoundCallbackTest3a;
static int gMakeBoundCallbackTest3b;
void
MakeBoundCallbackTarget1 (int a)
{
gMakeBoundCallbackTest1 = a;
}
void
MakeBoundCallbackTarget2 (bool *a)
{
gMakeBoundCallbackTest2 = a;
}
int
MakeBoundCallbackTarget3 (bool *a, int b)
{
gMakeBoundCallbackTest3a = a;
gMakeBoundCallbackTest3b = b;
return 1234;
}
MakeBoundCallbackTestCase::MakeBoundCallbackTestCase ()
: TestCase ("Check MakeBoundCallback() mechanism")
{
}
void
MakeBoundCallbackTestCase::DoSetup (void)
{
gMakeBoundCallbackTest1 = 0;
gMakeBoundCallbackTest2 = 0;
gMakeBoundCallbackTest3a = 0;
gMakeBoundCallbackTest3b = 0;
}
bool
MakeBoundCallbackTestCase::DoRun (void)
{
//
// This is slightly tricky to explain. A bound Callback allows us to package
// up arguments for use later. The arguments are bound when the callback is
// created and the code that fires the Callback does not know they are there.
//
// Since the callback is *declared* according to the way it will be used, the
// arguments are not seen there. However, the target function of the callback
// will have the provided arguments present. The MakeBoundCallback template
// function is what connects the two together and where you provide the
// arguments to be bound.
//
// Here we declare a Callback that returns a void and takes no parameters.
// MakeBoundCallback connects this Callback to a target function that returns
// void and takes an integer argument. That integer argument is bound to the
// value 1234. When the Callback is fired, no integer argument is provided
// directly. The argument is provided by bound Callback mechanism.
//
Callback<void> target1 = MakeBoundCallback (&MakeBoundCallbackTarget1, 1234);
target1 ();
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest1, 1234, "Callback did not fire or binding not correct");
//
// Make sure we can bind a pointer value (a common use case).
//
bool a;
Callback<void> target2 = MakeBoundCallback (&MakeBoundCallbackTarget2, &a);
target2 ();
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest2, &a, "Callback did not fire or binding not correct");
//
// Make sure we can mix and match bound and unbound arguments. This callback
// returns an integer so we should see that appear.
//
Callback<int, int> target3 = MakeBoundCallback (&MakeBoundCallbackTarget3, &a);
int result = target3 (2468);
NS_TEST_ASSERT_MSG_EQ (result, 1234, "Return value of callback not correct");
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest3a, &a, "Callback did not fire or binding not correct");
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest3b, 2468, "Callback did not fire or argument not correct");
return GetErrorStatus ();
}
// ===========================================================================
// Test the Nullify mechanism
// ===========================================================================
class NullifyCallbackTestCase : public TestCase
{
public:
NullifyCallbackTestCase ();
virtual ~NullifyCallbackTestCase () {}
void Target1 (void) {m_test1 = true;}
private:
virtual bool DoRun (void);
virtual void DoSetup (void);
bool m_test1;
};
NullifyCallbackTestCase::NullifyCallbackTestCase ()
: TestCase ("Check Nullify() and IsNull()")
{
}
void
NullifyCallbackTestCase::DoSetup (void)
{
m_test1 = false;
}
bool
NullifyCallbackTestCase::DoRun (void)
{
//
// Make sure we can declare and make a Callback pointing to a member
// function returning void and execute it.
//
Callback<void> target1 = MakeCallback (&NullifyCallbackTestCase::Target1, this);
target1 ();
NS_TEST_ASSERT_MSG_EQ (m_test1, true, "Callback did not fire");
NS_TEST_ASSERT_MSG_EQ (target1.IsNull (), false, "Working Callback reports IsNull()");
target1.Nullify ();
NS_TEST_ASSERT_MSG_EQ (target1.IsNull (), true, "Nullified Callback reports not IsNull()");
return GetErrorStatus ();
}
// ===========================================================================
// Make sure that various MakeCallback template functions compile and execute.
// Doesn't check an results of the execution.
// ===========================================================================
class MakeCallbackTemplatesTestCase : public TestCase
{
public:
MakeCallbackTemplatesTestCase ();
virtual ~MakeCallbackTemplatesTestCase () {}
void Target1 (void) {m_test1 = true;}
private:
virtual bool DoRun (void);
bool m_test1;
};
void TestFZero (void) {}
void TestFOne (int) {}
void TestFTwo (int, int) {}
void TestFThree (int, int, int) {}
void TestFFour (int, int, int, int) {}
void TestFFive (int, int, int, int, int) {}
void TestFSix (int, int, int, int, int, int) {}
void TestFROne (int &) {}
void TestFRTwo (int &, int &) {}
void TestFRThree (int &, int &, int &) {}
void TestFRFour (int &, int &, int &, int &) {}
void TestFRFive (int &, int &, int &, int &, int &) {}
void TestFRSix (int &, int &, int &, int &, int &, int &) {}
class CallbackTestParent
{
public:
void PublicParent (void) {}
protected:
void ProtectedParent (void) {}
static void StaticProtectedParent (void) {}
private:
void PrivateParent (void) {}
};
class CallbackTestClass : public CallbackTestParent
{
public:
void TestZero (void) {}
void TestOne (int) {}
void TestTwo (int, int) {}
void TestThree (int, int, int) {}
void TestFour (int, int, int, int) {}
void TestFive (int, int, int, int, int) {}
void TestSix (int, int, int, int, int, int) {}
void TestCZero (void) const {}
void TestCOne (int) const {}
void TestCTwo (int, int) const {}
void TestCThree (int, int, int) const {}
void TestCFour (int, int, int, int) const {}
void TestCFive (int, int, int, int, int) const {}
void TestCSix (int, int, int, int, int, int) const {}
void CheckParentalRights (void)
{
MakeCallback (&CallbackTestParent::StaticProtectedParent);
MakeCallback (&CallbackTestParent::PublicParent, this);
MakeCallback (&CallbackTestClass::ProtectedParent, this);
// as expected, fails.
// MakeCallback (&CallbackTestParent::PrivateParent, this);
// unexpected, but fails too. It does fumble me.
// MakeCallback (&CallbackTestParent::ProtectedParent, this);
}
};
MakeCallbackTemplatesTestCase::MakeCallbackTemplatesTestCase ()
: TestCase ("Check various MakeCallback() template functions")
{
}
bool
MakeCallbackTemplatesTestCase::DoRun (void)
{
CallbackTestClass that;
MakeCallback (&CallbackTestClass::TestZero, &that);
MakeCallback (&CallbackTestClass::TestOne, &that);
MakeCallback (&CallbackTestClass::TestTwo, &that);
MakeCallback (&CallbackTestClass::TestThree, &that);
MakeCallback (&CallbackTestClass::TestFour, &that);
MakeCallback (&CallbackTestClass::TestFive, &that);
MakeCallback (&CallbackTestClass::TestSix, &that);
MakeCallback (&CallbackTestClass::TestCZero, &that);
MakeCallback (&CallbackTestClass::TestCOne, &that);
MakeCallback (&CallbackTestClass::TestCTwo, &that);
MakeCallback (&CallbackTestClass::TestCThree, &that);
MakeCallback (&CallbackTestClass::TestCFour, &that);
MakeCallback (&CallbackTestClass::TestCFive, &that);
MakeCallback (&CallbackTestClass::TestCSix, &that);
MakeCallback (&TestFZero);
MakeCallback (&TestFOne);
MakeCallback (&TestFTwo);
MakeCallback (&TestFThree);
MakeCallback (&TestFFour);
MakeCallback (&TestFFive);
MakeCallback (&TestFSix);
MakeCallback (&TestFROne);
MakeCallback (&TestFRTwo);
MakeCallback (&TestFRThree);
MakeCallback (&TestFRFour);
MakeCallback (&TestFRFive);
MakeCallback (&TestFRSix);
MakeBoundCallback (&TestFOne, 1);
MakeBoundCallback (&TestFTwo, 1);
MakeBoundCallback (&TestFThree, 1);
MakeBoundCallback (&TestFFour, 1);
MakeBoundCallback (&TestFFive, 1);
MakeBoundCallback (&TestFROne, 1);
MakeBoundCallback (&TestFRTwo, 1);
MakeBoundCallback (&TestFRThree, 1);
MakeBoundCallback (&TestFRFour, 1);
MakeBoundCallback (&TestFRFive, 1);
that.CheckParentalRights ();
return GetErrorStatus ();
}
// ===========================================================================
// The Test Suite that glues all of the Test Cases together.
// ===========================================================================
class CallbackTestSuite : public TestSuite
{
public:
CallbackTestSuite ();
};
CallbackTestSuite::CallbackTestSuite ()
: TestSuite ("callback", UNIT)
{
AddTestCase (new BasicCallbackTestCase);
AddTestCase (new MakeCallbackTestCase);
AddTestCase (new MakeBoundCallbackTestCase);
AddTestCase (new NullifyCallbackTestCase);
AddTestCase (new MakeCallbackTemplatesTestCase);
}
CallbackTestSuite CallbackTestSuite;
} // namespace

View File

@@ -1,324 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "test.h"
#include "callback.h"
#include <stdint.h>
#ifdef RUN_SELF_TESTS
namespace ns3 {
static bool gTest5 = false;
static bool gTest6 = false;
static bool gTest7 = false;
void Test5 (void)
{
gTest5 = true;
}
void Test6 (int)
{
gTest6 = true;
}
int Test7 (int a)
{
gTest7 = true;
return a;
}
void *Test9 (bool *a)
{
return a;
}
void *Test10 (bool *a, int const & b)
{
return a;
}
void TestFZero (void) {}
void TestFOne (int) {}
void TestFTwo (int, int) {}
void TestFThree (int, int, int) {}
void TestFFour (int, int, int, int) {}
void TestFFive (int, int, int, int, int) {}
void TestFSix (int, int, int, int, int, int) {}
void TestFROne (int &) {}
void TestFRTwo (int &, int &) {}
void TestFRThree (int &, int &, int &) {}
void TestFRFour (int &, int &, int &, int &) {}
void TestFRFive (int &, int &, int &, int &, int &) {}
void TestFRSix (int &, int &, int &, int &, int &, int &) {}
class X : public ns3::Test
{
public:
X () : Test ("Callback") {}
void PublicParent (void) {}
protected:
static void StaticProtectedParent (void) {}
void ProtectedParent (void) {}
private:
void PrivateParent (void) {}
};
class CallbackTest : public X
{
private:
bool m_test1;
bool m_test2;
bool m_test3;
bool m_test4;
public:
CallbackTest ();
virtual bool RunTests (void);
void Reset (void);
bool IsWrong (void);
void Test1 (void);
int Test2 (void);
void Test3 (double a);
int Test4 (double a, int b);
void Test8 (Callback<void, int> callback);
void TestZero (void) {}
void TestOne (int) {}
void TestTwo (int, int) {}
void TestThree (int, int, int) {}
void TestFour (int, int, int, int) {}
void TestFive (int, int, int, int, int) {}
void TestSix (int, int, int, int, int, int) {}
void TestCZero (void) const {}
void TestCOne (int) const {}
void TestCTwo (int, int) const {}
void TestCThree (int, int, int) const {}
void TestCFour (int, int, int, int) const {}
void TestCFive (int, int, int, int, int) const {}
void TestCSix (int, int, int, int, int, int) const {}
};
CallbackTest::CallbackTest ()
: m_test1 (false),
m_test2 (false),
m_test3 (false),
m_test4 (false)
{}
void
CallbackTest::Test1 (void)
{
m_test1 = true;
}
int
CallbackTest::Test2 (void)
{
m_test2 = true;
return 2;
}
void
CallbackTest::Test3 (double a)
{
m_test3 = true;
}
int
CallbackTest::Test4 (double a, int b)
{
m_test4 = true;
return 4;
}
void
CallbackTest::Test8 (Callback<void,int> callback)
{
callback (3);
}
bool
CallbackTest::IsWrong (void)
{
if (!m_test1 ||
!m_test2 ||
!m_test3 ||
!m_test4 ||
!gTest5 ||
!gTest6 ||
!gTest7)
{
return true;
}
return false;
}
void
CallbackTest::Reset (void)
{
m_test1 = false;
m_test2 = false;
m_test3 = false;
m_test4 = false;
gTest5 = false;
gTest6 = false;
gTest7 = false;
}
bool
CallbackTest::RunTests (void)
{
bool ok = true;
typedef ns3::Callback<void> A;
typedef ns3::Callback<int> B;
typedef ns3::Callback<void, double> C;
typedef ns3::Callback<int, double, int> D;
typedef ns3::Callback<void> E;
typedef ns3::Callback<void,int> F;
typedef ns3::Callback<int,int> G;
A a0 (this, &CallbackTest::Test1);
B b0;
b0 = B (this, &CallbackTest::Test2);
C c0 = C (this, &CallbackTest::Test3);
D d0 = D (this, &CallbackTest::Test4);
E e0 = E (&Test5, true, true);
F f0 = F (&Test6, true, true);
G g0 = G (&Test7, true, true);
a0 ();
b0 ();
c0 (0.0);
d0 (0.0, 1);
e0 ();
f0 (1);
g0 (1);
if (IsWrong ())
{
ok = false;
}
Reset ();
A a1 = ns3::MakeCallback (&CallbackTest::Test1, this);
B b1 = ns3::MakeCallback (&CallbackTest::Test2, this);
C c1 = ns3::MakeCallback (&CallbackTest::Test3, this);
D d1 = ns3::MakeCallback (&CallbackTest::Test4, this);
E e1 = ns3::MakeCallback (&Test5);
F f1 = ns3::MakeCallback (&Test6);
G g1 = ns3::MakeCallback (&Test7);
a1 ();
b1 ();
c1 (0.0);
d1 (0.0, 1);
e1 ();
f1 (1);
g1 (2);
a1.Nullify ();
b1.Nullify ();
c1.Nullify ();
d1.Nullify ();
e1.Nullify ();
g1.Nullify ();
Test8 (f1);
f1.Nullify ();
Callback<void, int64_t,int64_t> a2;
if (IsWrong ())
{
ok = false;
}
MakeBoundCallback (&Test7, 0);
bool v;
MakeBoundCallback (&Test9, &v);
MakeBoundCallback (&Test10, &v);
MakeCallback (&CallbackTest::TestZero, this);
MakeCallback (&CallbackTest::TestOne, this);
MakeCallback (&CallbackTest::TestTwo, this);
MakeCallback (&CallbackTest::TestThree, this);
MakeCallback (&CallbackTest::TestFour, this);
MakeCallback (&CallbackTest::TestFive, this);
MakeCallback (&CallbackTest::TestSix, this);
MakeCallback (&CallbackTest::TestCZero, this);
MakeCallback (&CallbackTest::TestCOne, this);
MakeCallback (&CallbackTest::TestCTwo, this);
MakeCallback (&CallbackTest::TestCThree, this);
MakeCallback (&CallbackTest::TestCFour, this);
MakeCallback (&CallbackTest::TestCFive, this);
MakeCallback (&CallbackTest::TestCSix, this);
MakeCallback (&TestFZero);
MakeCallback (&TestFOne);
MakeCallback (&TestFTwo);
MakeCallback (&TestFThree);
MakeCallback (&TestFFour);
MakeCallback (&TestFFive);
MakeCallback (&TestFSix);
MakeCallback (&TestFROne);
MakeCallback (&TestFRTwo);
MakeCallback (&TestFRThree);
MakeCallback (&TestFRFour);
MakeCallback (&TestFRFive);
MakeCallback (&TestFRSix);
MakeBoundCallback (&TestFOne, 1);
MakeBoundCallback (&TestFTwo, 1);
MakeBoundCallback (&TestFThree, 1);
MakeBoundCallback (&TestFFour, 1);
MakeBoundCallback (&TestFFive, 1);
MakeBoundCallback (&TestFROne, 1);
MakeBoundCallback (&TestFRTwo, 1);
MakeBoundCallback (&TestFRThree, 1);
MakeBoundCallback (&TestFRFour, 1);
MakeBoundCallback (&TestFRFive, 1);
MakeCallback (&X::StaticProtectedParent);
MakeCallback (&X::PublicParent, this);
MakeCallback (&CallbackTest::ProtectedParent, this);
// as expected, fails.
//MakeCallback (&X::PrivateParent, this);
// unexpected, but fails too.
// It does fumble me.
//MakeCallback (&X::ProtectedParent, this);
return ok;
}
static CallbackTest gCallbackTest;
}; // namespace
#endif /* RUN_SELF_TESTS */

View File

@@ -475,7 +475,7 @@ public:
};
CommandLineTestSuite::CommandLineTestSuite ()
: TestSuite ("CommandLine", BVT)
: TestSuite ("command-line", BVT)
{
AddTestCase (new CommandLineBooleanTestCase);
AddTestCase (new CommandLineIntTestCase);

View File

@@ -46,7 +46,6 @@ int main ()
def build(bld):
core = bld.create_ns3_module('core')
core.source = [
'callback-test.cc',
'log.cc',
'breakpoint.cc',
'type-id.cc',
@@ -77,8 +76,9 @@ def build(bld):
'callback.cc',
'names.cc',
'vector.cc',
'names-test-suite.cc',
'attribute-test-suite.cc',
'callback-test-suite.cc',
'names-test-suite.cc',
'type-traits-test-suite.cc',
]

15
test.py
View File

@@ -65,7 +65,6 @@ interesting_config_items = [
# hardcoded.
#
example_tests = [
("run-tests", "False"),
("csma-bridge", "True"),
("csma-bridge-one-hop", "True"),
("csma-broadcast", "True"),
@@ -77,17 +76,28 @@ example_tests = [
("csma-star", "True"),
("dynamic-global-routing", "True"),
("first", "True"),
("global-injection-slash32", "True"),
("global-routing-slash32", "True"),
("hello-simulator", "True"),
("icmpv6-redirect", "True"),
("mesh", "True"),
("mixed-global-routing", "True"),
("mixed-wireless", "True"),
# ("multi-rate-first", "True"),
("multi-rate-second", "True"),
("nix-simple", "True"),
# ("nms-p2p-nix", "True"),
("object-names", "True"),
("ping6", "True"),
("radvd", "True"),
("radvd-two-prefix", "True"),
("realtime-udp-echo", "ENABLE_REAL_TIME == True"),
("second", "True"),
("simple-alternate-routing", "True"),
("simple-error-model", "True"),
("simple-global-routing", "True"),
("simple-point-to-point-olsr", "True"),
("simple-routing-ping6", "True"),
("simple-wifi-frame-aggregation", "True"),
("star", "True"),
("static-routing-slash32", "True"),
@@ -97,6 +107,9 @@ example_tests = [
("test-ipv6", "True"),
("third", "True"),
("udp-echo", "True"),
("virtual-net-device", "True"),
# ("wifi-adhoc", "True"),
("wifi-ap", "True"),
("wifi-wired-bridging", "True"),
]