A Discrete-Event Network Simulator
API
TracedCallback System Tests

TracedCallback System Tests. More...

+ 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. More...
 
#define DUPE(U, T1)
 Check the TracedCallback duplicate by checking if it matches the TracedCallback it is supposed to be equal to. More...
 
#define TYPENAME(T)
 Returns a string representing the type of a class. More...
 

Functions

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

Variables

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

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 354 of file traced-callback-typedef-test-suite.cc.

◆ 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), \
TypeName<T1>(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.

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

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

◆ 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 148 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 107 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 235 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 ( oldValue,
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 72 of file traced-value-callback-typedef-test-suite.cc.

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

◆ 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 110 of file traced-value-callback-typedef-test-suite.cc.

References ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >::GetValue().

+ 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 96 of file traced-value-callback-typedef-test-suite.cc.

References ns3::Time::GetInteger().

+ 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 138 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 125 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 55 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().