7#include "ns3/callback.h"
72 int Target4(
double a [[maybe_unused]],
int b [[maybe_unused]])
79 void DoRun()
override;
130 :
TestCase(
"Check basic Callback mechanism")
269 int Target4(
double a [[maybe_unused]],
int b [[maybe_unused]])
276 void DoRun()
override;
326 :
TestCase(
"Check MakeCallback() mechanism")
436 void DoRun()
override;
596 :
TestCase(
"Check MakeBoundCallback() mechanism")
651 "Callback did not fire or binding not correct");
661 "Callback did not fire or binding not correct");
668 int result = target3(2468);
672 "Callback did not fire or binding not correct");
675 "Callback did not fire or argument not correct");
684 "Callback did not fire or binding not correct");
687 "Callback did not fire or binding not correct");
690 int resultTwoA = target5();
694 "Callback did not fire or binding not correct");
697 "Callback did not fire or binding not correct");
700 int resultTwoB = target6(6789);
704 "Callback did not fire or binding not correct");
707 "Callback did not fire or binding not correct");
710 "Callback did not fire or argument not correct");
719 "Callback did not fire or binding not correct");
722 "Callback did not fire or binding not correct");
725 "Callback did not fire or binding not correct");
728 int resultThreeA = target8();
732 "Callback did not fire or binding not correct");
735 "Callback did not fire or binding not correct");
738 "Callback did not fire or binding not correct");
741 int resultThreeB = target9(5678);
745 "Callback did not fire or binding not correct");
748 "Callback did not fire or binding not correct");
751 "Callback did not fire or binding not correct");
754 "Callback did not fire or binding not correct");
791 return static_cast<int>(a) + b;
795 void DoRun()
override;
809 return static_cast<int>(a) + b;
813 :
TestCase(
"Check Callback equality test")
948 void DoRun()
override;
955 :
TestCase(
"Check Nullify() and IsNull()")
1007 void DoRun()
override;
1115 :
TestCase(
"Check various MakeCallback() template functions")
static bool gBasicCallbackTest7
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest5a
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest7c
Variable to verify that a callback has been called.
int MakeBoundCallbackTarget5(int a, int b)
MakeBoundCallback 5 target function.
static bool * gMakeBoundCallbackTest2
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest6b
Variable to verify that a callback has been called.
void TestFSix(int, int, int, int, int, int)
Test function - does nothing.
int MakeCallbackTarget7(int a)
MakeCallback 7 target function.
int CallbackEqualityTarget(double a, int b)
Non-member function used to test equality of callbacks.
static int gMakeBoundCallbackTest7b
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest9a
Variable to verify that a callback has been called.
static CallbackTestSuite g_gallbackTestSuite
Static variable for test initialization.
int MakeBoundCallbackTarget8(int a, int b, int c)
MakeBoundCallback 8 target function.
static bool gMakeCallbackTest5
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest1
Variable to verify that a callback has been called.
static bool gBasicCallbackTest5
Variable to verify that a callback has been called.
void MakeCallbackTarget5()
MakeCallback 5 target function.
static bool * gMakeBoundCallbackTest3a
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest6c
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest9b
Variable to verify that a callback has been called.
int BasicCallbackTarget7(int a)
Callback 6 target function.
void MakeBoundCallbackTarget2(bool *a)
MakeBoundCallback 2 target function.
void BasicCallbackTarget5()
Callback 5 target function.
void MakeBoundCallbackTarget7(int a, int b, int c)
MakeBoundCallback 7 target function.
static int gMakeBoundCallbackTest7a
Variable to verify that a callback has been called.
void BasicCallbackTarget6(int)
Callback 6 target function.
void TestFROne(int &)
Test function - does nothing.
void TestFRTwo(int &, int &)
Test function - does nothing.
static int gMakeBoundCallbackTest4b
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest5b
Variable to verify that a callback has been called.
int MakeBoundCallbackTarget6(int a, int b, int c)
MakeBoundCallback 5 target function.
static int gMakeBoundCallbackTest6a
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest5c
Variable to verify that a callback has been called.
void TestFFive(int, int, int, int, int)
Test function - does nothing.
static bool gMakeCallbackTest7
Variable to verify that a callback has been called.
int MakeBoundCallbackTarget3(bool *a, int b)
MakeBoundCallback 3 target function.
void MakeBoundCallbackTarget4(int a, int b)
MakeBoundCallback 4 target function.
static int gMakeBoundCallbackTest3b
Variable to verify that a callback has been called.
void TestFRFive(int &, int &, int &, int &, int &)
Test function - does nothing.
void TestFFour(int, int, int, int)
Test function - does nothing.
void TestFRThree(int &, int &, int &)
Test function - does nothing.
static int gMakeBoundCallbackTest8b
Variable to verify that a callback has been called.
void TestFOne(int)
Test function - does nothing.
int MakeBoundCallbackTarget9(int a, int b, int c, int d)
MakeBoundCallback 5 target function.
void TestFThree(int, int, int)
Test function - does nothing.
static bool gBasicCallbackTest8
Variable to verify that a callback has been called.
void TestFTwo(int, int)
Test function - does nothing.
static int gMakeBoundCallbackTest9d
Variable to verify that a callback has been called.
void TestFZero()
Test function - does nothing.
static int gMakeBoundCallbackTest4a
Variable to verify that a callback has been called.
static bool gMakeCallbackTest6
Variable to verify that a callback has been called.
void TestFRSix(int &, int &, int &, int &, int &, int &)
Test function - does nothing.
void TestFRFour(int &, int &, int &, int &)
Test function - does nothing.
static int gMakeBoundCallbackTest8c
Variable to verify that a callback has been called.
void MakeCallbackTarget6(int)
MakeCallback 6 target function.
void MakeBoundCallbackTarget1(int a)
MakeBoundCallback 1 target function.
static int gMakeBoundCallbackTest9c
Variable to verify that a callback has been called.
static int gMakeBoundCallbackTest8a
Variable to verify that a callback has been called.
static bool gBasicCallbackTest6
Variable to verify that a callback has been called.
Test the basic Callback mechanism.
bool m_test2
true if Target2 has been called, false otherwise.
bool m_test3
true if Target3 has been called, false otherwise.
bool m_test1
true if Target1 has been called, false otherwise.
~BasicCallbackTestCase() override
void Target3(double a)
Callback 3 target function.
void Target1()
Callback 1 target function.
bool m_test4
true if Target4 has been called, false otherwise.
void DoRun() override
Implementation to actually run this TestCase.
int Target2()
Callback 2 target function.
int Target4(double a, int b)
Callback 4 target function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
Test the callback equality implementation.
CallbackEqualityTestCase()
~CallbackEqualityTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
int TargetMember(double a, int b)
Member function used to test equality of callbacks.
Derived class used to check the capability of callbacks to call public, protected,...
void TestSix(int, int, int, int, int, int)
Test function - does nothing.
void CheckParentalRights()
Tries to make a callback to public and protected functions of a class.
void TestCThree(int, int, int) const
Test function - does nothing.
void TestCSix(int, int, int, int, int, int) const
Test function - does nothing.
void TestZero()
Test function - does nothing.
void TestOne(int)
Test function - does nothing.
void TestThree(int, int, int)
Test function - does nothing.
void TestCFour(int, int, int, int) const
Test function - does nothing.
void TestCOne(int) const
Test function - does nothing.
void TestCFive(int, int, int, int, int) const
Test function - does nothing.
void TestFour(int, int, int, int)
Test function - does nothing.
void TestCZero() const
Test function - does nothing.
void TestCTwo(int, int) const
Test function - does nothing.
void TestFive(int, int, int, int, int)
Test function - does nothing.
void TestTwo(int, int)
Test function - does nothing.
Class used to check the capability of callbacks to call public, protected, and private functions.
void PrivateParent()
A private function.
void PublicParent()
A public function.
void ProtectedParent()
A protected function.
static void StaticProtectedParent()
A static protected function.
Test the MakeBoundCallback mechanism.
~MakeBoundCallbackTestCase() override
MakeBoundCallbackTestCase()
void DoRun() override
Implementation to actually run this TestCase.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
int BoundTarget(int a, int b, int c)
Member function to test the creation of a bound callback pointing to a member function.
Make sure that various MakeCallback template functions compile and execute; doesn't check an results ...
MakeCallbackTemplatesTestCase()
~MakeCallbackTemplatesTestCase() override
bool m_test1
true if Target1 has been called, false otherwise.
void DoRun() override
Implementation to actually run this TestCase.
void Target1()
Callback 1 target function.
Test the MakeCallback mechanism.
int Target4(double a, int b)
Callback 4 target function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
bool m_test1
true if Target1 has been called, false otherwise.
void Target1()
Callback 1 target function.
bool m_test2
true if Target2 has been called, false otherwise.
bool m_test4
true if Target4 has been called, false otherwise.
~MakeCallbackTestCase() override
int Target2()
Callback 2 target function.
void Target3(double a)
Callback 3 target function.
bool m_test3
true if Target3 has been called, false otherwise.
void DoRun() override
Implementation to actually run this TestCase.
Test the Nullify mechanism.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void Target1()
Callback 1 target function.
NullifyCallbackTestCase()
bool m_test1
true if Target1 has been called, false otherwise.
void DoRun() override
Implementation to actually run this TestCase.
~NullifyCallbackTestCase() override
bool IsEqual(const CallbackBase &other) const
Equality test.
void Nullify()
Discard the implementation, set it to null.
bool IsNull() const
Check for null implementation.
auto Bind(BoundArgs &&... bargs)
Bind a variable number of arguments.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...