A Discrete-Event Network Simulator
API
Classes | Macros
Testing Implementation

Internal implementation of the Testing system. More...

Classes

struct  ns3::TestCase::Result
 Container for results from a TestCase. More...
 
struct  ns3::TestCaseFailure
 Container for details of a test failure. More...
 
class  ns3::TestRunner
 A runner to execute tests. More...
 
class  ns3::TestRunnerImpl
 Container for all tests. More...
 

Macros

#define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)
 Test that an actual and expected (limit) value are equal and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line)
 Test that an actual and expected (limit) value are equal and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line)
 Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line)
 Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line)
 Test that an actual value is greater than a limit and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line)
 Test that an actual value is greater than or equal to a limit and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line)
 Test that an actual value is less than a limit and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line)
 Test that an actual value is less than or equal to a limit and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line)
 Test that an actual and expected (limit) value are not equal and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line)
 Test that an actual and expected (limit) value are not equal and report and abort if not. More...
 
#define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)
 Test that an actual and expected (limit) value are equal and report if not. More...
 
#define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line)
 Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if not. More...
 
#define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line)
 Test that an actual value is greater than a limit and report if not. More...
 
#define NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line)
 Test that an actual value is greater than or equal to limit and report if not. More...
 
#define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line)
 Test that an actual value is less than a limit and report if not. More...
 
#define NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line)
 Test that an actual value is less than or equal to a limit and report if not. More...
 
#define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line)
 Test that an actual and expected (limit) value are not equal and report if not. More...
 

Detailed Description

Internal implementation of the Testing system.

Macro Definition Documentation

◆ NS_TEST_ASSERT_MSG_EQ_INTERNAL

#define NS_TEST_ASSERT_MSG_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) == (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) == " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
CONTINUE_ON_FAILURE; \
} \
} while (false)

Test that an actual and expected (limit) value are equal and report and abort if not.

Definition at line 120 of file test.h.

Referenced by PacketMetadataTest::CheckHistory(), and BufferTest::EnsureWrittenBytes().

◆ NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL

#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) == (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) == " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
CONTINUE_ON_FAILURE_RETURNS_BOOL; \
} \
} while (false)

Test that an actual and expected (limit) value are equal and report and abort if not.

Definition at line 176 of file test.h.

◆ NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL

#define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (   actual,
  limit,
  tol,
  msg,
  file,
  line 
)
Value:
do { \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit << " +- " << tol; \
std::ostringstream condStream; \
condStream << #actual << " (actual) < " << #limit \
<< " (limit) + " << #tol << " (tol) && " \
<< #actual << " (actual) > " << #limit \
<< " (limit) - " << #tol << " (tol)"; \
ReportTestFailure (condStream.str (), actualStream.str (), \
limitStream.str (), msgStream.str (), \
file, line); \
CONTINUE_ON_FAILURE; \
} \
} while (false)

Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not.

Definition at line 298 of file test.h.

◆ NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL

#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL (   actual,
  limit,
  tol,
  msg,
  file,
  line 
)
Value:
do { \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit << " +- " << tol; \
std::ostringstream condStream; \
condStream << #actual << " (actual) < " << #limit \
<< " (limit) + " << #tol << " (tol) && " \
<< #actual << " (actual) > " << #limit \
<< " (limit) - " << #tol << " (tol)"; \
ReportTestFailure (condStream.str (), actualStream.str (), \
limitStream.str (), msgStream.str (), \
file, line); \
CONTINUE_ON_FAILURE_RETURNS_BOOL; \
} \
} while (false)

Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not.

Definition at line 388 of file test.h.

◆ NS_TEST_ASSERT_MSG_GT_INTERNAL

#define NS_TEST_ASSERT_MSG_GT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) > (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) > " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
CONTINUE_ON_FAILURE; \
} \
} while (false)

Test that an actual value is greater than a limit and report and abort if not.

Definition at line 936 of file test.h.

◆ NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL

#define NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) >= (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) > " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
CONTINUE_ON_FAILURE; \
} \
} while (false)

Test that an actual value is greater than or equal to a limit and report and abort if not.

Definition at line 960 of file test.h.

◆ NS_TEST_ASSERT_MSG_LT_INTERNAL

#define NS_TEST_ASSERT_MSG_LT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) < (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) < " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
CONTINUE_ON_FAILURE; \
} \
} while (false)

Test that an actual value is less than a limit and report and abort if not.

Definition at line 751 of file test.h.

◆ NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL

#define NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) <= (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) < " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
CONTINUE_ON_FAILURE; \
} \
} while (false)

Test that an actual value is less than or equal to a limit and report and abort if not.

Definition at line 775 of file test.h.

◆ NS_TEST_ASSERT_MSG_NE_INTERNAL

#define NS_TEST_ASSERT_MSG_NE_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) != (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) != " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
CONTINUE_ON_FAILURE; \
} \
} while (false)

Test that an actual and expected (limit) value are not equal and report and abort if not.

Definition at line 577 of file test.h.

◆ NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL

#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) != (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) != " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
CONTINUE_ON_FAILURE_RETURNS_BOOL; \
} \
} while (false)

Test that an actual and expected (limit) value are not equal and report and abort if not.

Definition at line 632 of file test.h.

◆ NS_TEST_EXPECT_MSG_EQ_INTERNAL

#define NS_TEST_EXPECT_MSG_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) == (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) == " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
} \
} while (false)

Test that an actual and expected (limit) value are equal and report if not.

Required to avoid use of return statement which allows use in methods (esp. callbacks) returning void.

Definition at line 238 of file test.h.

Referenced by PacketTest::DoCheck().

◆ NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL

#define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (   actual,
  limit,
  tol,
  msg,
  file,
  line 
)
Value:
do { \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit << " +- " << tol; \
std::ostringstream condStream; \
condStream << #actual << " (actual) < " << #limit \
<< " (limit) + " << #tol << " (tol) && " \
<< #actual << " (actual) > " << #limit \
<< " (limit) - " << #tol << " (tol)"; \
ReportTestFailure (condStream.str (), actualStream.str (), \
limitStream.str (), msgStream.str (), \
file, line); \
} \
} while (false)

Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if not.

Required to avoid use of return statement which allows use in methods (esp. callbacks) returning void.

Definition at line 484 of file test.h.

Referenced by WaypointLazyNotifyFalse::CourseChangeCallback(), WaypointLazyNotifyTrue::CourseChangeCallback(), WaypointLazyNotifyFalse::TestXPosition(), WaypointLazyNotifyTrue::TestXPosition(), WaypointInitialPositionIsWaypoint::TestXPosition(), and WaypointMobilityModelViaHelper::TestXPosition().

◆ NS_TEST_EXPECT_MSG_GT_INTERNAL

#define NS_TEST_EXPECT_MSG_GT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) > (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) > " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
} \
} while (false)

Test that an actual value is greater than a limit and report if not.

Required to avoid use of return statement which allows use in methods (callbacks) returning void.

Definition at line 1028 of file test.h.

◆ NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL

#define NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) >= (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) > " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
} \
} while (false)

Test that an actual value is greater than or equal to limit and report if not.

Required to avoid use of return statement which allows use in methods (callbacks) returning void.

Definition at line 1054 of file test.h.

◆ NS_TEST_EXPECT_MSG_LT_INTERNAL

#define NS_TEST_EXPECT_MSG_LT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) < (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) < " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
} \
} while (false)

Test that an actual value is less than a limit and report if not.

Required to avoid use of return statement which allows use in methods (callbacks) returning void.

Definition at line 842 of file test.h.

◆ NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL

#define NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) <= (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) < " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
} \
} while (false)

Test that an actual value is less than or equal to a limit and report if not.

Required to avoid use of return statement which allows use in methods (callbacks) returning void.

Definition at line 868 of file test.h.

◆ NS_TEST_EXPECT_MSG_NE_INTERNAL

#define NS_TEST_EXPECT_MSG_NE_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) != (limit))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure (std::string (#actual) + " (actual) != " + \
std::string (#limit) + " (limit)", \
actualStream.str (), limitStream.str (), \
msgStream.str (), file, line); \
} \
} while (false)

Test that an actual and expected (limit) value are not equal and report if not.

Required to avoid use of return statement which allows use in methods (callbacks) returning void.

Definition at line 693 of file test.h.