A Discrete-Event Network Simulator
API
test.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #ifndef NS3_TEST_H
20 #define NS3_TEST_H
21 
22 #include <iostream>
23 #include <fstream>
24 #include <sstream>
25 #include <string>
26 #include <vector>
27 #include <list>
28 #include <limits>
29 #include <stdint.h>
30 
31 #include "system-wall-clock-ms.h"
32 
48 //
49 // Note on below macros:
50 //
51 // When multiple statements are used in a macro, they should be bound together
52 // in a loop syntactically, so the macro can appear safely inside if clauses
53 // or other places that expect a single statement or a statement block. The
54 // "strange" do while construct is a generally expected best practice for
55 // defining a robust macro.
56 //
57 
62 #define ASSERT_ON_FAILURE \
63  do { \
64  if (MustAssertOnFailure ()) \
65  { \
66  *(volatile int *)0 = 0; \
67  } \
68  } while (false)
69 
74 #define CONTINUE_ON_FAILURE \
75  do { \
76  if (!MustContinueOnFailure ()) \
77  { \
78  return; \
79  } \
80  } while (false)
81 
86 #define CONTINUE_ON_FAILURE_RETURNS_BOOL \
87  do { \
88  if (!MustContinueOnFailure ()) \
89  { \
90  return IsStatusFailure (); \
91  } \
92  } while (false)
93 
94 
95 
96 // ===========================================================================
97 // Test for equality (generic version)
98 // ===========================================================================
99 
105 #define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \
106  do { \
107  if (!((actual) == (limit))) \
108  { \
109  ASSERT_ON_FAILURE; \
110  std::ostringstream msgStream; \
111  msgStream << msg; \
112  std::ostringstream actualStream; \
113  actualStream << actual; \
114  std::ostringstream limitStream; \
115  limitStream << limit; \
116  ReportTestFailure (std::string (#actual) + " (actual) == " + \
117  std::string (#limit) + " (limit)", \
118  actualStream.str (), limitStream.str (), \
119  msgStream.str (), file, line); \
120  CONTINUE_ON_FAILURE; \
121  } \
122  } while (false)
123 
152 #define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg) \
153  NS_TEST_ASSERT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
154 
160 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
161  do { \
162  if (!((actual) == (limit))) \
163  { \
164  ASSERT_ON_FAILURE; \
165  std::ostringstream msgStream; \
166  msgStream << msg; \
167  std::ostringstream actualStream; \
168  actualStream << actual; \
169  std::ostringstream limitStream; \
170  limitStream << limit; \
171  ReportTestFailure (std::string (#actual) + " (actual) == " + \
172  std::string (#limit) + " (limit)", \
173  actualStream.str (), limitStream.str (), \
174  msgStream.str (), file, line); \
175  CONTINUE_ON_FAILURE_RETURNS_BOOL; \
176  } \
177  } while (false)
178 
210 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg) \
211  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
212 
221 #define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \
222  do { \
223  if (!((actual) == (limit))) \
224  { \
225  ASSERT_ON_FAILURE; \
226  std::ostringstream msgStream; \
227  msgStream << msg; \
228  std::ostringstream actualStream; \
229  actualStream << actual; \
230  std::ostringstream limitStream; \
231  limitStream << limit; \
232  ReportTestFailure (std::string (#actual) + " (actual) == " + \
233  std::string (#limit) + " (limit)", \
234  actualStream.str (), limitStream.str (), \
235  msgStream.str (), file, line); \
236  } \
237  } while (false)
238 
267 #define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg) \
268  NS_TEST_EXPECT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
269 
270 // ===========================================================================
271 // Test for equality with a provided tolerance (use for floating point
272 // comparisons -- both float and double)
273 // ===========================================================================
274 
280 #define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \
281  do { \
282  if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
283  { \
284  ASSERT_ON_FAILURE; \
285  std::ostringstream msgStream; \
286  msgStream << msg; \
287  std::ostringstream actualStream; \
288  actualStream << actual; \
289  std::ostringstream limitStream; \
290  limitStream << limit << " +- " << tol; \
291  std::ostringstream condStream; \
292  condStream << #actual << " (actual) < " << #limit \
293  << " (limit) + " << #tol << " (tol) && " \
294  << #actual << " (actual) > " << #limit \
295  << " (limit) - " << #tol << " (tol)"; \
296  ReportTestFailure (condStream.str (), actualStream.str (), \
297  limitStream.str (), msgStream.str (), \
298  file, line); \
299  CONTINUE_ON_FAILURE; \
300  } \
301  } while (false)
302 
356 #define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg) \
357  NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
358 
364 #define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line) \
365  do { \
366  if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
367  { \
368  ASSERT_ON_FAILURE; \
369  std::ostringstream msgStream; \
370  msgStream << msg; \
371  std::ostringstream actualStream; \
372  actualStream << actual; \
373  std::ostringstream limitStream; \
374  limitStream << limit << " +- " << tol; \
375  std::ostringstream condStream; \
376  condStream << #actual << " (actual) < " << #limit \
377  << " (limit) + " << #tol << " (tol) && " \
378  << #actual << " (actual) > " << #limit \
379  << " (limit) - " << #tol << " (tol)"; \
380  ReportTestFailure (condStream.str (), actualStream.str (), \
381  limitStream.str (), msgStream.str (), \
382  file, line); \
383  CONTINUE_ON_FAILURE_RETURNS_BOOL; \
384  } \
385  } while (false)
386 
443 #define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL(actual, limit, tol, msg) \
444  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
445 
454 #define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \
455  do { \
456  if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
457  { \
458  ASSERT_ON_FAILURE; \
459  std::ostringstream msgStream; \
460  msgStream << msg; \
461  std::ostringstream actualStream; \
462  actualStream << actual; \
463  std::ostringstream limitStream; \
464  limitStream << limit << " +- " << tol; \
465  std::ostringstream condStream; \
466  condStream << #actual << " (actual) < " << #limit \
467  << " (limit) + " << #tol << " (tol) && " \
468  << #actual << " (actual) > " << #limit \
469  << " (limit) - " << #tol << " (tol)"; \
470  ReportTestFailure (condStream.str (), actualStream.str (), \
471  limitStream.str (), msgStream.str (), \
472  file, line); \
473  } \
474  } while (false)
475 
529 #define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg) \
530  NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
531 
532 // ===========================================================================
533 // Test for inequality
534 // ===========================================================================
535 
541 #define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \
542  do { \
543  if (!((actual) != (limit))) \
544  { \
545  ASSERT_ON_FAILURE; \
546  std::ostringstream msgStream; \
547  msgStream << msg; \
548  std::ostringstream actualStream; \
549  actualStream << actual; \
550  std::ostringstream limitStream; \
551  limitStream << limit; \
552  ReportTestFailure (std::string (#actual) + " (actual) != " + \
553  std::string (#limit) + " (limit)", \
554  actualStream.str (), limitStream.str (), \
555  msgStream.str (), file, line); \
556  CONTINUE_ON_FAILURE; \
557  } \
558  } while (false)
559 
587 #define NS_TEST_ASSERT_MSG_NE(actual, limit, msg) \
588  NS_TEST_ASSERT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
589 
595 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
596  do { \
597  if (!((actual) != (limit))) \
598  { \
599  ASSERT_ON_FAILURE; \
600  std::ostringstream msgStream; \
601  msgStream << msg; \
602  std::ostringstream actualStream; \
603  actualStream << actual; \
604  std::ostringstream limitStream; \
605  limitStream << limit; \
606  ReportTestFailure (std::string (#actual) + " (actual) != " + \
607  std::string (#limit) + " (limit)", \
608  actualStream.str (), limitStream.str (), \
609  msgStream.str (), file, line); \
610  CONTINUE_ON_FAILURE_RETURNS_BOOL; \
611  } \
612  } while (false)
613 
644 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg) \
645  NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
646 
655 #define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \
656  do { \
657  if (!((actual) != (limit))) \
658  { \
659  ASSERT_ON_FAILURE; \
660  std::ostringstream msgStream; \
661  msgStream << msg; \
662  std::ostringstream actualStream; \
663  actualStream << actual; \
664  std::ostringstream limitStream; \
665  limitStream << limit; \
666  ReportTestFailure (std::string (#actual) + " (actual) != " + \
667  std::string (#limit) + " (limit)", \
668  actualStream.str (), limitStream.str (), \
669  msgStream.str (), file, line); \
670  } \
671  } while (false)
672 
700 #define NS_TEST_EXPECT_MSG_NE(actual, limit, msg) \
701  NS_TEST_EXPECT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
702 
703 // ===========================================================================
704 // Test for less than relation
705 // ===========================================================================
706 
712 #define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \
713  do { \
714  if (!((actual) < (limit))) \
715  { \
716  ASSERT_ON_FAILURE; \
717  std::ostringstream msgStream; \
718  msgStream << msg; \
719  std::ostringstream actualStream; \
720  actualStream << actual; \
721  std::ostringstream limitStream; \
722  limitStream << limit; \
723  ReportTestFailure (std::string (#actual) + " (actual) < " + \
724  std::string (#limit) + " (limit)", \
725  actualStream.str (), limitStream.str (), \
726  msgStream.str (), file, line); \
727  CONTINUE_ON_FAILURE; \
728  } \
729  } while (false)
730 
736 #define NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
737  do { \
738  if (!((actual) <= (limit))) \
739  { \
740  ASSERT_ON_FAILURE; \
741  std::ostringstream msgStream; \
742  msgStream << msg; \
743  std::ostringstream actualStream; \
744  actualStream << actual; \
745  std::ostringstream limitStream; \
746  limitStream << limit; \
747  ReportTestFailure (std::string (#actual) + " (actual) < " + \
748  std::string (#limit) + " (limit)", \
749  actualStream.str (), limitStream.str (), \
750  msgStream.str (), file, line); \
751  CONTINUE_ON_FAILURE; \
752  } \
753  } while (false)
754 
772 #define NS_TEST_ASSERT_MSG_LT(actual, limit, msg) \
773  NS_TEST_ASSERT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
774 
792 #define NS_TEST_ASSERT_MSG_LT_OR_EQ(actual, limit, msg) \
793  NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
794 
802 #define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \
803  do { \
804  if (!((actual) < (limit))) \
805  { \
806  ASSERT_ON_FAILURE; \
807  std::ostringstream msgStream; \
808  msgStream << msg; \
809  std::ostringstream actualStream; \
810  actualStream << actual; \
811  std::ostringstream limitStream; \
812  limitStream << limit; \
813  ReportTestFailure (std::string (#actual) + " (actual) < " + \
814  std::string (#limit) + " (limit)", \
815  actualStream.str (), limitStream.str (), \
816  msgStream.str (), file, line); \
817  } \
818  } while (false)
819 
828 #define NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
829  do { \
830  if (!((actual) <= (limit))) \
831  { \
832  ASSERT_ON_FAILURE; \
833  std::ostringstream msgStream; \
834  msgStream << msg; \
835  std::ostringstream actualStream; \
836  actualStream << actual; \
837  std::ostringstream limitStream; \
838  limitStream << limit; \
839  ReportTestFailure (std::string (#actual) + " (actual) < " + \
840  std::string (#limit) + " (limit)", \
841  actualStream.str (), limitStream.str (), \
842  msgStream.str (), file, line); \
843  } \
844  } while (false)
845 
862 #define NS_TEST_EXPECT_MSG_LT(actual, limit, msg) \
863  NS_TEST_EXPECT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
864 
882 #define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg) \
883  NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
884 
885 // ===========================================================================
886 // Test for greater than relation
887 // ===========================================================================
888 
894 #define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \
895  do { \
896  if (!((actual) > (limit))) \
897  { \
898  ASSERT_ON_FAILURE; \
899  std::ostringstream msgStream; \
900  msgStream << msg; \
901  std::ostringstream actualStream; \
902  actualStream << actual; \
903  std::ostringstream limitStream; \
904  limitStream << limit; \
905  ReportTestFailure (std::string (#actual) + " (actual) > " + \
906  std::string (#limit) + " (limit)", \
907  actualStream.str (), limitStream.str (), \
908  msgStream.str (), file, line); \
909  CONTINUE_ON_FAILURE; \
910  } \
911  } while (false)
912 
918 #define NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
919  do { \
920  if (!((actual) >= (limit))) \
921  { \
922  ASSERT_ON_FAILURE; \
923  std::ostringstream msgStream; \
924  msgStream << msg; \
925  std::ostringstream actualStream; \
926  actualStream << actual; \
927  std::ostringstream limitStream; \
928  limitStream << limit; \
929  ReportTestFailure (std::string (#actual) + " (actual) > " + \
930  std::string (#limit) + " (limit)", \
931  actualStream.str (), limitStream.str (), \
932  msgStream.str (), file, line); \
933  CONTINUE_ON_FAILURE; \
934  } \
935  } while (false)
936 
954 #define NS_TEST_ASSERT_MSG_GT(actual, limit, msg) \
955  NS_TEST_ASSERT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
956 
974 #define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg) \
975  NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
976 
984 #define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \
985  do { \
986  if (!((actual) > (limit))) \
987  { \
988  ASSERT_ON_FAILURE; \
989  std::ostringstream msgStream; \
990  msgStream << msg; \
991  std::ostringstream actualStream; \
992  actualStream << actual; \
993  std::ostringstream limitStream; \
994  limitStream << limit; \
995  ReportTestFailure (std::string (#actual) + " (actual) > " + \
996  std::string (#limit) + " (limit)", \
997  actualStream.str (), limitStream.str (), \
998  msgStream.str (), file, line); \
999  } \
1000  } while (false)
1001 
1010 #define NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
1011  do { \
1012  if (!((actual) >= (limit))) \
1013  { \
1014  ASSERT_ON_FAILURE; \
1015  std::ostringstream msgStream; \
1016  msgStream << msg; \
1017  std::ostringstream actualStream; \
1018  actualStream << actual; \
1019  std::ostringstream limitStream; \
1020  limitStream << limit; \
1021  ReportTestFailure (std::string (#actual) + " (actual) > " + \
1022  std::string (#limit) + " (limit)", \
1023  actualStream.str (), limitStream.str (), \
1024  msgStream.str (), file, line); \
1025  } \
1026  } while (false)
1027 
1044 #define NS_TEST_EXPECT_MSG_GT(actual, limit, msg) \
1045  NS_TEST_EXPECT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
1046 
1064 #define NS_TEST_EXPECT_MSG_GT_OR_EQ(actual, limit, msg) \
1065  NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
1066 
1067 namespace ns3 {
1068 
1088 bool TestDoubleIsEqual (const double a, const double b,
1089  const double epsilon = std::numeric_limits<double>::epsilon ());
1090 
1091 class TestRunnerImpl;
1092 
1103 {
1104 public:
1110  QUICK = 1,
1113  };
1114 
1118  virtual ~TestCase ();
1119 
1123  std::string GetName (void) const;
1124 
1125 protected:
1129  TestCase (std::string name);
1130 
1137  void AddTestCase (TestCase *testCase, enum TestDuration duration);
1138 
1151  void SetDataDir (std::string directory);
1152 
1156  bool IsStatusFailure (void) const;
1160  bool IsStatusSuccess (void) const;
1161 
1165  TestCase * GetParent () const;
1166 
1183  void ReportTestFailure (std::string cond, std::string actual,
1184  std::string limit, std::string message,
1185  std::string file, int32_t line);
1189  bool MustAssertOnFailure (void) const;
1193  bool MustContinueOnFailure (void) const;
1198  std::string CreateDataDirFilename (std::string filename);
1205  std::string CreateTempDirFilename (std::string filename);
1207 private:
1208  friend class TestRunnerImpl;
1209 
1216  virtual void DoSetup (void);
1217 
1223  virtual void DoRun (void) = 0;
1224 
1230  virtual void DoTeardown (void);
1231 
1235  TestCase (TestCase& tc);
1240 
1241  // methods called by TestRunnerImpl
1247  void Run (TestRunnerImpl *runner);
1251  bool IsFailed (void) const;
1252 
1253  // Forward declaration is enough, since we only include a pointer here
1254  struct Result;
1255 
1256  TestCase *m_parent;
1257  std::vector<TestCase *> m_children;
1258  std::string m_dataDir;
1260  struct Result *m_result;
1261  std::string m_name;
1263 };
1264 
1270 class TestSuite : public TestCase
1271 {
1272 public:
1277  enum Type {
1278  ALL = 0,
1279  BVT = 1,
1284  };
1285 
1292  TestSuite (std::string name, Type type = UNIT);
1293 
1300 
1301 private:
1302  virtual void DoRun (void);
1303 
1304 
1306 };
1307 
1314 {
1315 public:
1323  static int Run (int argc, char *argv[]);
1324 };
1325 
1331 template <typename T>
1333 {
1334 public:
1338  TestVectors ();
1342  virtual ~TestVectors ();
1343 
1347  void Reserve (uint32_t reserve);
1348 
1353  uint32_t Add (T vector);
1354 
1358  uint32_t GetN (void) const;
1364  T Get (uint32_t i) const;
1365 
1366 private:
1370  TestVectors (const TestVectors& tv);
1374  TestVectors& operator= (const TestVectors& tv);
1378  bool operator== (const TestVectors& tv) const;
1379 
1380  typedef std::vector<T> TestVector;
1381  TestVector m_vectors;
1382 };
1383 
1384 template <typename T>
1386  : m_vectors ()
1387 {
1388 }
1389 
1390 template <typename T>
1391 void
1392 TestVectors<T>::Reserve (uint32_t reserve)
1393 {
1394  m_vectors.reserve (reserve);
1395 }
1396 
1397 template <typename T>
1399 {
1400 }
1401 
1402 template <typename T>
1403 uint32_t
1405 {
1406  uint32_t index = m_vectors.size ();
1407  m_vectors.push_back (vector);
1408  return index;
1409 }
1410 
1411 template <typename T>
1412 uint32_t
1414 {
1415  return m_vectors.size ();
1416 }
1417 
1418 template <typename T>
1419 T
1420 TestVectors<T>::Get (uint32_t i) const
1421 {
1422  NS_ABORT_MSG_UNLESS (m_vectors.size () > i, "TestVectors::Get(): Bad index");
1423  return m_vectors[i];
1424 }
1425 
1426 } // namespace ns3
1427 
1428 #endif /* NS3_TEST_H */
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
Definition: test.cc:349
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Definition: test.cc:354
TestVectors & operator=(const TestVectors &tv)
Assignment, private to prevent copying.
T Get(uint32_t i) const
Get the i'th test vector.
Definition: test.h:1420
virtual ~TestVectors()
Virtual desctructor.
Definition: test.h:1398
Fast test.
Definition: test.h:1110
A suite of tests to run.
Definition: test.h:1270
A runner to execute tests.
Definition: test.h:1313
void Reserve(uint32_t reserve)
Definition: test.h:1392
Medium length test.
Definition: test.h:1111
bool IsFailed(void) const
Definition: test.cc:217
std::vector< T > TestVector
Container type.
Definition: test.h:1380
encapsulates test code
Definition: test.h:1102
enum TestDuration m_duration
TestCase duration.
Definition: test.h:1262
This test suite implements a Unit Test.
Definition: test.h:1280
uint32_t GetN(void) const
Definition: test.h:1413
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
Definition: test.cc:360
TestDuration
How long the test takes to execute.
Definition: test.h:1109
This test suite implements an Example Test.
Definition: test.h:1282
A simple way to store test vectors (for stimulus or from responses)
Definition: test.h:1332
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: test.cc:376
TestVectors()
Constructor.
Definition: test.h:1385
TestCase * m_parent
Pointer to my parent TestCase.
Definition: test.h:1254
TestRunnerImpl * m_runner
Pointer to the TestRunner.
Definition: test.h:1259
System-independent wall clock class ns3::SystemWallClockMs declaration.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:184
uint32_t Add(T vector)
Definition: test.h:1404
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...
Definition: test.cc:36
Type
Type of test.
Definition: test.h:1277
TestSuite::Type m_type
Type of this TestSuite.
Definition: test.h:1305
bool MustAssertOnFailure(void) const
Definition: test.cc:276
TestCase(std::string name)
Definition: test.cc:159
virtual ~TestCase()
Destructor.
Definition: test.cc:170
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string CreateDataDirFilename(std::string filename)
Definition: test.cc:289
This test suite implements a Performance Test.
Definition: test.h:1283
virtual void DoRun(void)=0
Implementation to actually run this TestCase.
struct Result * m_result
Results data.
Definition: test.h:1260
bool IsStatusFailure(void) const
Definition: test.cc:329
TestCase * GetParent() const
Definition: test.cc:253
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.
Definition: test.cc:259
bool operator==(const TestVectors &tv) const
Comparison (unimplemented?)
void Run(TestRunnerImpl *runner)
Actually run this TestCase.
Definition: test.cc:224
bool IsStatusSuccess(void) const
Definition: test.cc:335
This test suite implements a System Test.
Definition: test.h:1281
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition: abort.h:144
std::string CreateTempDirFilename(std::string filename)
Definition: test.cc:307
This test suite implements a Build Verification Test.
Definition: test.h:1279
void SetDataDir(std::string directory)
Definition: test.cc:342
TestVector m_vectors
The list of test vectors.
Definition: test.h:1381
std::vector< TestCase * > m_children
Vector of my children.
Definition: test.h:1257
std::string GetName(void) const
Definition: test.cc:247
Very long running test.
Definition: test.h:1112
TestSuite::Type GetTestType(void)
get the kind of test this test suite implements
Definition: test.cc:369
static int Run(int argc, char *argv[])
Run the requested suite of tests.
Definition: test.cc:970
std::string m_name
TestCase name.
Definition: test.h:1261
TestCase & operator=(TestCase &tc)
Private, to block copying.
std::string m_dataDir
My data directory.
Definition: test.h:1258
bool MustContinueOnFailure(void) const
Definition: test.cc:282