A Discrete-Event Network Simulator
API
Testing Implementation

Internal implementation of the Testing system. More...

+ Collaboration diagram for Testing Implementation:

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

#define NS_TEST_ASSERT_MSG_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) == (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE
If we shouldn't continue on errors, return.
Definition: test.h:82

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

Definition at line 113 of file test.h.

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

#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) == (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
If we shouldn't continue on errors, return test status.
Definition: test.h:94

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

Definition at line 169 of file test.h.

#define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (   actual,
  limit,
  tol,
  msg,
  file,
  line 
)
Value:
do { \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE
If we shouldn't continue on errors, return.
Definition: test.h:82

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

Definition at line 291 of file test.h.

#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)) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
If we shouldn't continue on errors, return test status.
Definition: test.h:94

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

Definition at line 381 of file test.h.

#define NS_TEST_ASSERT_MSG_GT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) > (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE
If we shouldn't continue on errors, return.
Definition: test.h:82

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

Definition at line 929 of file test.h.

#define NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) >= (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE
If we shouldn't continue on errors, return.
Definition: test.h:82

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

Definition at line 953 of file test.h.

#define NS_TEST_ASSERT_MSG_LT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) < (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE
If we shouldn't continue on errors, return.
Definition: test.h:82

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

Definition at line 744 of file test.h.

#define NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) <= (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE
If we shouldn't continue on errors, return.
Definition: test.h:82

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

Definition at line 768 of file test.h.

#define NS_TEST_ASSERT_MSG_NE_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) != (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE
If we shouldn't continue on errors, return.
Definition: test.h:82

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

Definition at line 570 of file test.h.

#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) != (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
If we shouldn't continue on errors, return test status.
Definition: test.h:94

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

Definition at line 625 of file test.h.

#define NS_TEST_EXPECT_MSG_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) == (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70

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 231 of file test.h.

Referenced by PacketTest::DoCheck().

#define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (   actual,
  limit,
  tol,
  msg,
  file,
  line 
)
Value:
do { \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70

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 477 of file test.h.

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

#define NS_TEST_EXPECT_MSG_GT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) > (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70

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 1021 of file test.h.

#define NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) >= (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70

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 1047 of file test.h.

#define NS_TEST_EXPECT_MSG_LT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) < (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70

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 835 of file test.h.

#define NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) <= (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70

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 861 of file test.h.

#define NS_TEST_EXPECT_MSG_NE_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
Value:
do { \
if (!((actual) != (limit))) \
{ \
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)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition: test.h:70

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 686 of file test.h.