77 #define ASSERT_ON_FAILURE                       \    79     if (MustAssertOnFailure ())                 \    81         *(volatile int *)0 = 0;                 \    89 #define CONTINUE_ON_FAILURE                                             \    91     if (!MustContinueOnFailure ())                                      \   101 #define CONTINUE_ON_FAILURE_RETURNS_BOOL                                \   103     if (!MustContinueOnFailure ())                                      \   105         return IsStatusFailure ();                                      \   120 #define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)  \   122     if (!((actual) == (limit)))                                         \   125         std::ostringstream msgStream;                                   \   127         std::ostringstream actualStream;                                \   128         actualStream << actual;                                         \   129         std::ostringstream limitStream;                                 \   130         limitStream << limit;                                           \   131         ReportTestFailure (std::string (#actual) + " (actual) == " +    \   132                            std::string (#limit) + " (limit)",           \   133                            actualStream.str (), limitStream.str (),     \   134                            msgStream.str (), file, line);               \   135         CONTINUE_ON_FAILURE;                                            \   168 #define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg) \   169   NS_TEST_ASSERT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   176 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \   178     if (!((actual) == (limit)))                                         \   181         std::ostringstream msgStream;                                   \   183         std::ostringstream actualStream;                                \   184         actualStream << actual;                                         \   185         std::ostringstream limitStream;                                 \   186         limitStream << limit;                                           \   187         ReportTestFailure (std::string (#actual) + " (actual) == " +    \   188                        std::string (#limit) + " (limit)",               \   189                        actualStream.str (), limitStream.str (),         \   190                        msgStream.str (), file, line);                   \   191         CONTINUE_ON_FAILURE_RETURNS_BOOL;                               \   227 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg) \   228   NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   238 #define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)  \   240     if (!((actual) == (limit)))                                         \   243         std::ostringstream msgStream;                                   \   245         std::ostringstream actualStream;                                \   246         actualStream << actual;                                         \   247         std::ostringstream limitStream;                                 \   248         limitStream << limit;                                           \   249         ReportTestFailure (std::string (#actual) + " (actual) == " +    \   250                        std::string (#limit) + " (limit)",               \   251                        actualStream.str (), limitStream.str (),         \   252                        msgStream.str (), file, line);                   \   285 #define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg) \   286   NS_TEST_EXPECT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   298 #define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \   300     if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol))       \   303         std::ostringstream msgStream;                                   \   305         std::ostringstream actualStream;                                \   306         actualStream << actual;                                         \   307         std::ostringstream limitStream;                                 \   308         limitStream << limit << " +- " << tol;                          \   309         std::ostringstream condStream;                                  \   310         condStream << #actual << " (actual) < " << #limit               \   311                    << " (limit) + " << #tol << " (tol) && "             \   312                    << #actual << " (actual) > " << #limit               \   313                    << " (limit) - " << #tol << " (tol)";                \   314         ReportTestFailure (condStream.str (), actualStream.str (),      \   315                        limitStream.str (), msgStream.str (),            \   317         CONTINUE_ON_FAILURE;                                            \   380 #define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)                 \   381   NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)   388 #define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line) \   390     if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol))       \   393         std::ostringstream msgStream;                                   \   395         std::ostringstream actualStream;                                \   396         actualStream << actual;                                         \   397         std::ostringstream limitStream;                                 \   398         limitStream << limit << " +- " << tol;                          \   399         std::ostringstream condStream;                                  \   400         condStream << #actual << " (actual) < " << #limit               \   401                    << " (limit) + " << #tol << " (tol) && "             \   402                    << #actual << " (actual) > " << #limit               \   403                    << " (limit) - " << #tol << " (tol)";                \   404         ReportTestFailure (condStream.str (), actualStream.str (),      \   405                        limitStream.str (), msgStream.str (),            \   407         CONTINUE_ON_FAILURE_RETURNS_BOOL;                               \   473 #define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL(actual, limit, tol, msg)  \   474   NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)   484 #define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \   486     if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol))       \   489         std::ostringstream msgStream;                                   \   491         std::ostringstream actualStream;                                \   492         actualStream << actual;                                         \   493         std::ostringstream limitStream;                                 \   494         limitStream << limit << " +- " << tol;                          \   495         std::ostringstream condStream;                                  \   496         condStream << #actual << " (actual) < " << #limit               \   497                    << " (limit) + " << #tol << " (tol) && "             \   498                    << #actual << " (actual) > " << #limit               \   499                    << " (limit) - " << #tol << " (tol)";                \   500         ReportTestFailure (condStream.str (), actualStream.str (),      \   501                        limitStream.str (), msgStream.str (),            \   565 #define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg) \   566   NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)   577 #define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line)  \   579     if (!((actual) != (limit)))                                         \   582         std::ostringstream msgStream;                                   \   584         std::ostringstream actualStream;                                \   585         actualStream << actual;                                         \   586         std::ostringstream limitStream;                                 \   587         limitStream << limit;                                           \   588         ReportTestFailure (std::string (#actual) + " (actual) != " +    \   589                        std::string (#limit) + " (limit)",               \   590                        actualStream.str (), limitStream.str (),         \   591                        msgStream.str (), file, line);                   \   592         CONTINUE_ON_FAILURE;                                            \   624 #define NS_TEST_ASSERT_MSG_NE(actual, limit, msg) \   625   NS_TEST_ASSERT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   632 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \   634     if (!((actual) != (limit)))                                         \   637         std::ostringstream msgStream;                                   \   639         std::ostringstream actualStream;                                \   640         actualStream << actual;                                         \   641         std::ostringstream limitStream;                                 \   642         limitStream << limit;                                           \   643         ReportTestFailure (std::string (#actual) + " (actual) != " +    \   644                        std::string (#limit) + " (limit)",               \   645                        actualStream.str (), limitStream.str (),         \   646                        msgStream.str (), file, line);                   \   647         CONTINUE_ON_FAILURE_RETURNS_BOOL;                               \   682 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg) \   683   NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   693 #define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line)  \   695     if (!((actual) != (limit)))                                         \   698         std::ostringstream msgStream;                                   \   700         std::ostringstream actualStream;                                \   701         actualStream << actual;                                         \   702         std::ostringstream limitStream;                                 \   703         limitStream << limit;                                           \   704         ReportTestFailure (std::string (#actual) + " (actual) != " +    \   705                        std::string (#limit) + " (limit)",               \   706                        actualStream.str (), limitStream.str (),         \   707                        msgStream.str (), file, line);                   \   739 #define NS_TEST_EXPECT_MSG_NE(actual, limit, msg) \   740   NS_TEST_EXPECT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   751 #define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line)  \   753     if (!((actual) < (limit)))                                          \   756         std::ostringstream msgStream;                                   \   758         std::ostringstream actualStream;                                \   759         actualStream << actual;                                         \   760         std::ostringstream limitStream;                                 \   761         limitStream << limit;                                           \   762         ReportTestFailure (std::string (#actual) + " (actual) < " +     \   763                        std::string (#limit) + " (limit)",               \   764                        actualStream.str (), limitStream.str (),         \   765                        msgStream.str (), file, line);                   \   766         CONTINUE_ON_FAILURE;                                            \   775 #define NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line)  \   777     if (!((actual) <= (limit)))                                         \   780         std::ostringstream msgStream;                                   \   782         std::ostringstream actualStream;                                \   783         actualStream << actual;                                         \   784         std::ostringstream limitStream;                                 \   785         limitStream << limit;                                           \   786         ReportTestFailure (std::string (#actual) + " (actual) < " +     \   787                        std::string (#limit) + " (limit)",               \   788                        actualStream.str (), limitStream.str (),         \   789                        msgStream.str (), file, line);                   \   790         CONTINUE_ON_FAILURE;                                            \   811 #define NS_TEST_ASSERT_MSG_LT(actual, limit, msg) \   812   NS_TEST_ASSERT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   832 #define NS_TEST_ASSERT_MSG_LT_OR_EQ(actual, limit, msg) \   833   NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   842 #define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line)  \   844     if (!((actual) < (limit)))                                          \   847         std::ostringstream msgStream;                                   \   849         std::ostringstream actualStream;                                \   850         actualStream << actual;                                         \   851         std::ostringstream limitStream;                                 \   852         limitStream << limit;                                           \   853         ReportTestFailure (std::string (#actual) + " (actual) < " +     \   854                        std::string (#limit) + " (limit)",               \   855                        actualStream.str (), limitStream.str (),         \   856                        msgStream.str (), file, line);                   \   868 #define NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line)  \   870     if (!((actual) <= (limit)))                                         \   873         std::ostringstream msgStream;                                   \   875         std::ostringstream actualStream;                                \   876         actualStream << actual;                                         \   877         std::ostringstream limitStream;                                 \   878         limitStream << limit;                                           \   879         ReportTestFailure (std::string (#actual) + " (actual) < " +     \   880                        std::string (#limit) + " (limit)",               \   881                        actualStream.str (), limitStream.str (),         \   882                        msgStream.str (), file, line);                   \   903 #define NS_TEST_EXPECT_MSG_LT(actual, limit, msg) \   904   NS_TEST_EXPECT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   924 #define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg) \   925   NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)   936 #define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line)  \   938     if (!((actual) > (limit)))                                          \   941         std::ostringstream msgStream;                                   \   943         std::ostringstream actualStream;                                \   944         actualStream << actual;                                         \   945         std::ostringstream limitStream;                                 \   946         limitStream << limit;                                           \   947         ReportTestFailure (std::string (#actual) + " (actual) > " +     \   948                        std::string (#limit) + " (limit)",               \   949                        actualStream.str (), limitStream.str (),         \   950                        msgStream.str (), file, line);                   \   951         CONTINUE_ON_FAILURE;                                            \   960 #define NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line)  \   962     if (!((actual) >= (limit)))                                         \   965         std::ostringstream msgStream;                                   \   967         std::ostringstream actualStream;                                \   968         actualStream << actual;                                         \   969         std::ostringstream limitStream;                                 \   970         limitStream << limit;                                           \   971         ReportTestFailure (std::string (#actual) + " (actual) > " +     \   972                        std::string (#limit) + " (limit)",               \   973                        actualStream.str (), limitStream.str (),         \   974                        msgStream.str (), file, line);                   \   975         CONTINUE_ON_FAILURE;                                            \   997 #define NS_TEST_ASSERT_MSG_GT(actual, limit, msg) \   998   NS_TEST_ASSERT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)  1018 #define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg) \  1019   NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)  1028 #define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line)  \  1030     if (!((actual) > (limit)))                                          \  1032         ASSERT_ON_FAILURE;                                              \  1033         std::ostringstream msgStream;                                   \  1035         std::ostringstream actualStream;                                \  1036         actualStream << actual;                                         \  1037         std::ostringstream limitStream;                                 \  1038         limitStream << limit;                                           \  1039         ReportTestFailure (std::string (#actual) + " (actual) > " +     \  1040                        std::string (#limit) + " (limit)",               \  1041                        actualStream.str (), limitStream.str (),         \  1042                        msgStream.str (), file, line);                   \  1054 #define NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line)  \  1056     if (!((actual) >= (limit)))                                         \  1058         ASSERT_ON_FAILURE;                                              \  1059         std::ostringstream msgStream;                                   \  1061         std::ostringstream actualStream;                                \  1062         actualStream << actual;                                         \  1063         std::ostringstream limitStream;                                 \  1064         limitStream << limit;                                           \  1065         ReportTestFailure (std::string (#actual) + " (actual) > " +     \  1066                        std::string (#limit) + " (limit)",               \  1067                        actualStream.str (), limitStream.str (),         \  1068                        msgStream.str (), file, line);                   \  1090 #define NS_TEST_EXPECT_MSG_GT(actual, limit, msg) \  1091   NS_TEST_EXPECT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)  1111 #define NS_TEST_EXPECT_MSG_GT_OR_EQ(actual, limit, msg) \  1112   NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)  1142 class TestRunnerImpl;
  1173   std::string 
GetName (
void) 
const;  
  1247                       std::string limit, std::string message, 
  1248                       std::string 
file, int32_t line);
  1299   virtual void DoRun (
void) = 0;
  1375   virtual void DoRun (
void);
  1396   static int Run (
int argc, 
char *argv[]);
  1404 template <
typename T>
  1422   void Reserve (uint32_t reserve);
  1429   std::size_t 
Add (T vector);
  1435   std::size_t 
GetN (
void) 
const;
  1441   T 
Get (std::size_t i) 
const;
  1448 template <
typename T>
  1454 template <
typename T>
  1458   m_vectors.reserve (reserve);
  1461 template <
typename T>
  1466 template <
typename T>
  1470   std::size_t index = m_vectors.size ();
  1471   m_vectors.push_back (vector);
  1475 template <
typename T>
  1479   return m_vectors.size ();
  1482 template <
typename T>
  1487   return m_vectors[i];
 virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase. 
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase. 
This test suite implements a System Test. 
bool IsStatusFailure(void) const
Check if any tests failed. 
A base class for (non-Singleton) objects which shouldn't be copied. 
virtual ~TestVectors()
Virtual destructor. 
A runner to execute tests. 
void Reserve(uint32_t reserve)
Set the expected length of this vector. 
Container for results from a TestCase. 
T Get(std::size_t i) const
Get the i'th test vector. 
bool MustAssertOnFailure(void) const
Check if this run should assert on failure. 
std::vector< T > TestVector
Container type. 
enum TestDuration m_duration
TestCase duration. 
ns3::NonCopyable declaration. 
TestSuite(std::string name, Type type=UNIT)
Construct a new test suite. 
A simple way to store test vectors (for stimulus or from responses) 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
bool IsStatusSuccess(void) const
Check if all tests passed. 
std::size_t GetN(void) const
Get the total number of test vectors. 
TestVectors()
Constructor. 
TestCase * m_parent
Pointer to my parent TestCase. 
TestRunnerImpl * m_runner
Pointer to the TestRunner. 
ns3::SystemWallClockMs declaration. 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite. 
bool TestDoubleIsEqual(const double x1, const double x2, const double epsilon)
Compare two double precision floating point numbers and declare them equal if they are within some ep...
TestSuite::Type m_type
Type of this TestSuite. 
This test suite implements a Performance Test. 
TestCase(std::string name)
Constructor. 
This test suite implements a Build Verification Test. 
TestDuration
How long the test takes to execute. 
virtual ~TestCase()
Destructor. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
std::string CreateDataDirFilename(std::string filename)
Construct the full path to a file in the data directory. 
virtual void DoRun(void)=0
Implementation to actually run this TestCase. 
struct Result * m_result
Results data. 
void ReportTestFailure(std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line)
Log the failure of this TestCase. 
TestCase * GetParent() const
Get the parent of this TestCsse. 
void Run(TestRunnerImpl *runner)
Actually run this TestCase. 
bool MustContinueOnFailure(void) const
Check if this run should continue on failure. 
std::string GetName(void) const
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message. 
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory. 
void SetDataDir(std::string directory)
Set the data directory where reference trace files can be found. 
TestVector m_vectors
The list of test vectors. 
std::vector< TestCase * > m_children
Vector of my children. 
This test suite implements an Example Test. 
std::size_t Add(T vector)
This test suite implements a Unit Test. 
TestSuite::Type GetTestType(void)
get the kind of test this test suite implements 
static int Run(int argc, char *argv[])
Run the requested suite of tests, according to the given command line arguments. 
std::string m_name
TestCase name. 
bool IsFailed(void) const
Check if any tests failed.   
std::string m_dataDir
My data directory.