A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
TracedCallback System Tests
+ Collaboration diagram for TracedCallback System Tests:

Files

file  traced-callback-typedef-test-suite.cc
 TracedCallback tests to verify if they are called with the right type and number of arguments.
 
file  traced-value-callback-typedef-test-suite.cc
 TracedValueCallback tests to verify that they work with different types of classes - it tests bool, double, various types of integers types, Time, and SequenceNumber32.
 

Classes

class  TracedCallbackTypedefTestCase
 TracedCallback Testcase. More...
 
class  TracedCallbackTypedefTestSuite
 TracedCallback typedef TestSuite. More...
 
class  anonymous_namespace{traced-callback-typedef-test-suite.cc}::TracedCbSink< Ts >
 Sink functions. More...
 
class  TracedValueCallbackTestCase
 TracedValueCallback Test Case. More...
 
class  TracedValueCallbackTestSuite
 TracedValueCallback TestSuite. More...
 

Macros

#define CHECK(U, ...)   CreateObject<Checker<__VA_ARGS__>>()->Invoke<U>()
 Check the TracedCallback by calling its Invoke function.
 
#define DUPE(U, T1)
 Check the TracedCallback duplicate by checking if it matches the TracedCallback it is supposed to be equal to.
 
#define TYPENAME(T)
 Returns a string representing the type of a class.
 

Functions

std::set< std::string > anonymous_namespace{traced-callback-typedef-test-suite.cc}::Duplicates ()
 Record typedefs which are identical to previously declared.
 
void anonymous_namespace{traced-callback-typedef-test-suite.cc}::SinkIt (std::size_t N)
 Log that a callback was invoked.
 
template<typename T >
void anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink (T oldValue, T newValue)
 Template for TracedValue sink functions.
 
template<>
void anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink< SequenceNumber32 > (SequenceNumber32 oldValue, SequenceNumber32 newValue)
 TracedValueCbSink specialization for SequenceNumber32.
 
template<>
void anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink< Time > (Time oldValue, Time newValue)
 TracedValueCbSink specialization for Time.
 
template<typename T >
std::string anonymous_namespace{traced-callback-typedef-test-suite.cc}::TypeName (int N)
 Stringify the known TracedCallback type names.
 

Variables

std::set< std::string > anonymous_namespace{traced-callback-typedef-test-suite.cc}::g_dupes = Duplicates()
 Container for duplicate types.
 
std::string anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::g_Result = ""
 Result of callback test.
 

Detailed Description

TracedCallback System Tests

Macro Definition Documentation

◆ CHECK

#define CHECK ( U,
... )   CreateObject<Checker<__VA_ARGS__>>()->Invoke<U>()

Check the TracedCallback by calling its Invoke function.

Definition at line 344 of file traced-callback-typedef-test-suite.cc.

Referenced by TracedCallbackTypedefTestCase::DoRun().

◆ DUPE

#define DUPE ( U,
T1 )
Value:
if (g_dupes.find(#U) == g_dupes.end()) \
{ \
NS_TEST_ASSERT_MSG_NE(0, 1, "expected to find " << #U << " in dupes."); \
} \
if (TypeName<U>(0) == TypeName<T1>(0)) \
{ \
std::cout << #U << " matches " << #T1 << std::endl; \
} \
else \
{ \
NS_TEST_ASSERT_MSG_EQ(TypeName<U>(0), \
"the typedef " \
<< #U << " used to match the typedef " << #T1 \
<< " but no longer does. Please add a new CHECK call."); \
}
std::set< std::string > g_dupes
Container for duplicate types.
std::string TypeName(int N)
Stringify the known TracedCallback type names.

Check the TracedCallback duplicate by checking if it matches the TracedCallback it is supposed to be equal to.

Definition at line 321 of file traced-callback-typedef-test-suite.cc.

Referenced by TracedCallbackTypedefTestCase::DoRun().

◆ TYPENAME

#define TYPENAME ( T)
Value:
template <> \
inline std::string TypeName<T>(int N) \
{ \
std::stringstream ss; \
ss << #T << "(" << N << ")"; \
return ss.str(); \
}

Returns a string representing the type of a class.

Definition at line 138 of file traced-callback-typedef-test-suite.cc.

Function Documentation

◆ Duplicates()

std::set< std::string > anonymous_namespace{traced-callback-typedef-test-suite.cc}::Duplicates ( )

Record typedefs which are identical to previously declared.

Returns
a container of strings representing the duplicates.

Definition at line 97 of file traced-callback-typedef-test-suite.cc.

◆ SinkIt()

void anonymous_namespace{traced-callback-typedef-test-suite.cc}::SinkIt ( std::size_t N)

Log that a callback was invoked.

We can't actually do anything with any of the arguments, but the fact we got called is what's important.

Parameters
[in]NThe number of arguments passed to the callback.

Definition at line 225 of file traced-callback-typedef-test-suite.cc.

References TracedCallbackTypedefTestCase::m_nArgs.

Referenced by anonymous_namespace{traced-callback-typedef-test-suite.cc}::TracedCbSink< Ts >::Sink().

+ Here is the caller graph for this function:

◆ TracedValueCbSink()

template<typename T >
void anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink ( T oldValue,
T newValue )

Template for TracedValue sink functions.

This generates a sink function for any underlying type.

Template Parameters
T[explicit] The type of the value being traced. Since the point of this template is to create a sink function, the template type must be given explicitly.
Parameters
[in]oldValueThe original value
[in]newValueThe new value

Definition at line 61 of file traced-value-callback-typedef-test-suite.cc.

References anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::g_Result.

Referenced by TracedValueCallbackTestCase::CheckType(), anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink< SequenceNumber32 >(), and anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink< Time >().

+ Here is the caller graph for this function:

◆ TracedValueCbSink< SequenceNumber32 >()

template<>
void anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink< SequenceNumber32 > ( SequenceNumber32 oldValue,
SequenceNumber32 newValue )

TracedValueCbSink specialization for SequenceNumber32.

Parameters
oldValueThe old value
newValueThe new value

Definition at line 99 of file traced-value-callback-typedef-test-suite.cc.

References ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >::GetValue(), and anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink().

+ Here is the call graph for this function:

◆ TracedValueCbSink< Time >()

template<>
void anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink< Time > ( Time oldValue,
Time newValue )

TracedValueCbSink specialization for Time.

Parameters
oldValueThe old value
newValueThe new value

Definition at line 85 of file traced-value-callback-typedef-test-suite.cc.

References ns3::Time::GetInteger(), and anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink().

+ Here is the call graph for this function:

◆ TypeName()

template<typename T >
std::string anonymous_namespace{traced-callback-typedef-test-suite.cc}::TypeName ( int N)
inline

Stringify the known TracedCallback type names.

Template Parameters
T[explicit] The typedef name.
Parameters
[in]NThe number of arguments expected.
Returns
The TracedCallback type name.

Definition at line 128 of file traced-callback-typedef-test-suite.cc.

Variable Documentation

◆ g_dupes

std::set<std::string> anonymous_namespace{traced-callback-typedef-test-suite.cc}::g_dupes = Duplicates()

Container for duplicate types.

Definition at line 115 of file traced-callback-typedef-test-suite.cc.

◆ g_Result

std::string anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::g_Result = ""

Result of callback test.

Since the sink function is outside the invoking class, which in this case is TracedValueCallbackTestCase, we can't use the test macros directly. Instead, we cache the result in the g_Result global value, then inspect it in the TracedValueCallbackTestCase::CheckType method.

Definition at line 44 of file traced-value-callback-typedef-test-suite.cc.

Referenced by TracedValueCallbackTestCase::CheckType(), TracedValueCallbackTestCase::CheckTvCb< T >::Invoke(), and anonymous_namespace{traced-value-callback-typedef-test-suite.cc}::TracedValueCbSink().