18 #include "ns3/callback.h"
83 int Target4(
double a [[maybe_unused]],
int b [[maybe_unused]])
90 void DoRun()
override;
91 void DoSetup()
override;
141 :
TestCase(
"Check basic Callback mechanism")
280 int Target4(
double a [[maybe_unused]],
int b [[maybe_unused]])
287 void DoRun()
override;
337 :
TestCase(
"Check MakeCallback() mechanism")
447 void DoRun()
override;
607 :
TestCase(
"Check MakeBoundCallback() mechanism")
662 "Callback did not fire or binding not correct");
672 "Callback did not fire or binding not correct");
679 int result = target3(2468);
683 "Callback did not fire or binding not correct");
686 "Callback did not fire or argument not correct");
695 "Callback did not fire or binding not correct");
698 "Callback did not fire or binding not correct");
701 int resultTwoA = target5();
705 "Callback did not fire or binding not correct");
708 "Callback did not fire or binding not correct");
711 int resultTwoB = target6(6789);
715 "Callback did not fire or binding not correct");
718 "Callback did not fire or binding not correct");
721 "Callback did not fire or argument not correct");
730 "Callback did not fire or binding not correct");
733 "Callback did not fire or binding not correct");
736 "Callback did not fire or binding not correct");
739 int resultThreeA = target8();
743 "Callback did not fire or binding not correct");
746 "Callback did not fire or binding not correct");
749 "Callback did not fire or binding not correct");
752 int resultThreeB = target9(5678);
756 "Callback did not fire or binding not correct");
759 "Callback did not fire or binding not correct");
762 "Callback did not fire or binding not correct");
765 "Callback did not fire or binding not correct");
802 return static_cast<int>(a) + b;
806 void DoRun()
override;
820 return static_cast<int>(a) + b;
824 :
TestCase(
"Check Callback equality test")
959 void DoRun()
override;
966 :
TestCase(
"Check Nullify() and IsNull()")
1018 void DoRun()
override;
1126 :
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.
void Target3(double a[[maybe_unused]])
Callback 3 target function.
~BasicCallbackTestCase() override
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[[maybe_unused]], int b[[maybe_unused]])
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.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
int Target4(double a[[maybe_unused]], int b[[maybe_unused]])
Callback 4 target function.
bool m_test1
true if Target1 has been called, false otherwise.
void Target1()
Callback 1 target function.
void Target3(double a[[maybe_unused]])
Callback 3 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.
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, TestDuration 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...