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 
54 //
55 // Note on below macros:
56 //
57 // When multiple statements are used in a macro, they should be bound together
58 // in a loop syntactically, so the macro can appear safely inside if clauses
59 // or other places that expect a single statement or a statement block. The
60 // "strange" do while construct is a generally expected best practice for
61 // defining a robust macro.
62 //
63 
68 #define ASSERT_ON_FAILURE \
69  do { \
70  if (MustAssertOnFailure ()) \
71  { \
72  *(volatile int *)0 = 0; \
73  } \
74  } while (false)
75 
80 #define CONTINUE_ON_FAILURE \
81  do { \
82  if (!MustContinueOnFailure ()) \
83  { \
84  return; \
85  } \
86  } while (false)
87 
92 #define CONTINUE_ON_FAILURE_RETURNS_BOOL \
93  do { \
94  if (!MustContinueOnFailure ()) \
95  { \
96  return IsStatusFailure (); \
97  } \
98  } while (false)
99 
100 
101 
102 // ===========================================================================
103 // Test for equality (generic version)
104 // ===========================================================================
105 
111 #define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \
112  do { \
113  if (!((actual) == (limit))) \
114  { \
115  ASSERT_ON_FAILURE; \
116  std::ostringstream msgStream; \
117  msgStream << msg; \
118  std::ostringstream actualStream; \
119  actualStream << actual; \
120  std::ostringstream limitStream; \
121  limitStream << limit; \
122  ReportTestFailure (std::string (#actual) + " (actual) == " + \
123  std::string (#limit) + " (limit)", \
124  actualStream.str (), limitStream.str (), \
125  msgStream.str (), file, line); \
126  CONTINUE_ON_FAILURE; \
127  } \
128  } while (false)
129 
158 #define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg) \
159  NS_TEST_ASSERT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
160 
166 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
167  do { \
168  if (!((actual) == (limit))) \
169  { \
170  ASSERT_ON_FAILURE; \
171  std::ostringstream msgStream; \
172  msgStream << msg; \
173  std::ostringstream actualStream; \
174  actualStream << actual; \
175  std::ostringstream limitStream; \
176  limitStream << limit; \
177  ReportTestFailure (std::string (#actual) + " (actual) == " + \
178  std::string (#limit) + " (limit)", \
179  actualStream.str (), limitStream.str (), \
180  msgStream.str (), file, line); \
181  CONTINUE_ON_FAILURE_RETURNS_BOOL; \
182  } \
183  } while (false)
184 
216 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg) \
217  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
218 
227 #define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \
228  do { \
229  if (!((actual) == (limit))) \
230  { \
231  ASSERT_ON_FAILURE; \
232  std::ostringstream msgStream; \
233  msgStream << msg; \
234  std::ostringstream actualStream; \
235  actualStream << actual; \
236  std::ostringstream limitStream; \
237  limitStream << limit; \
238  ReportTestFailure (std::string (#actual) + " (actual) == " + \
239  std::string (#limit) + " (limit)", \
240  actualStream.str (), limitStream.str (), \
241  msgStream.str (), file, line); \
242  } \
243  } while (false)
244 
273 #define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg) \
274  NS_TEST_EXPECT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
275 
276 // ===========================================================================
277 // Test for equality with a provided tolerance (use for floating point
278 // comparisons -- both float and double)
279 // ===========================================================================
280 
286 #define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \
287  do { \
288  if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
289  { \
290  ASSERT_ON_FAILURE; \
291  std::ostringstream msgStream; \
292  msgStream << msg; \
293  std::ostringstream actualStream; \
294  actualStream << actual; \
295  std::ostringstream limitStream; \
296  limitStream << limit << " +- " << tol; \
297  std::ostringstream condStream; \
298  condStream << #actual << " (actual) < " << #limit \
299  << " (limit) + " << #tol << " (tol) && " \
300  << #actual << " (actual) > " << #limit \
301  << " (limit) - " << #tol << " (tol)"; \
302  ReportTestFailure (condStream.str (), actualStream.str (), \
303  limitStream.str (), msgStream.str (), \
304  file, line); \
305  CONTINUE_ON_FAILURE; \
306  } \
307  } while (false)
308 
362 #define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg) \
363  NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
364 
370 #define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line) \
371  do { \
372  if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
373  { \
374  ASSERT_ON_FAILURE; \
375  std::ostringstream msgStream; \
376  msgStream << msg; \
377  std::ostringstream actualStream; \
378  actualStream << actual; \
379  std::ostringstream limitStream; \
380  limitStream << limit << " +- " << tol; \
381  std::ostringstream condStream; \
382  condStream << #actual << " (actual) < " << #limit \
383  << " (limit) + " << #tol << " (tol) && " \
384  << #actual << " (actual) > " << #limit \
385  << " (limit) - " << #tol << " (tol)"; \
386  ReportTestFailure (condStream.str (), actualStream.str (), \
387  limitStream.str (), msgStream.str (), \
388  file, line); \
389  CONTINUE_ON_FAILURE_RETURNS_BOOL; \
390  } \
391  } while (false)
392 
449 #define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL(actual, limit, tol, msg) \
450  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
451 
460 #define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \
461  do { \
462  if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
463  { \
464  ASSERT_ON_FAILURE; \
465  std::ostringstream msgStream; \
466  msgStream << msg; \
467  std::ostringstream actualStream; \
468  actualStream << actual; \
469  std::ostringstream limitStream; \
470  limitStream << limit << " +- " << tol; \
471  std::ostringstream condStream; \
472  condStream << #actual << " (actual) < " << #limit \
473  << " (limit) + " << #tol << " (tol) && " \
474  << #actual << " (actual) > " << #limit \
475  << " (limit) - " << #tol << " (tol)"; \
476  ReportTestFailure (condStream.str (), actualStream.str (), \
477  limitStream.str (), msgStream.str (), \
478  file, line); \
479  } \
480  } while (false)
481 
535 #define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg) \
536  NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
537 
538 // ===========================================================================
539 // Test for inequality
540 // ===========================================================================
541 
547 #define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \
548  do { \
549  if (!((actual) != (limit))) \
550  { \
551  ASSERT_ON_FAILURE; \
552  std::ostringstream msgStream; \
553  msgStream << msg; \
554  std::ostringstream actualStream; \
555  actualStream << actual; \
556  std::ostringstream limitStream; \
557  limitStream << limit; \
558  ReportTestFailure (std::string (#actual) + " (actual) != " + \
559  std::string (#limit) + " (limit)", \
560  actualStream.str (), limitStream.str (), \
561  msgStream.str (), file, line); \
562  CONTINUE_ON_FAILURE; \
563  } \
564  } while (false)
565 
593 #define NS_TEST_ASSERT_MSG_NE(actual, limit, msg) \
594  NS_TEST_ASSERT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
595 
601 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
602  do { \
603  if (!((actual) != (limit))) \
604  { \
605  ASSERT_ON_FAILURE; \
606  std::ostringstream msgStream; \
607  msgStream << msg; \
608  std::ostringstream actualStream; \
609  actualStream << actual; \
610  std::ostringstream limitStream; \
611  limitStream << limit; \
612  ReportTestFailure (std::string (#actual) + " (actual) != " + \
613  std::string (#limit) + " (limit)", \
614  actualStream.str (), limitStream.str (), \
615  msgStream.str (), file, line); \
616  CONTINUE_ON_FAILURE_RETURNS_BOOL; \
617  } \
618  } while (false)
619 
650 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg) \
651  NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
652 
661 #define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \
662  do { \
663  if (!((actual) != (limit))) \
664  { \
665  ASSERT_ON_FAILURE; \
666  std::ostringstream msgStream; \
667  msgStream << msg; \
668  std::ostringstream actualStream; \
669  actualStream << actual; \
670  std::ostringstream limitStream; \
671  limitStream << limit; \
672  ReportTestFailure (std::string (#actual) + " (actual) != " + \
673  std::string (#limit) + " (limit)", \
674  actualStream.str (), limitStream.str (), \
675  msgStream.str (), file, line); \
676  } \
677  } while (false)
678 
706 #define NS_TEST_EXPECT_MSG_NE(actual, limit, msg) \
707  NS_TEST_EXPECT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
708 
709 // ===========================================================================
710 // Test for less than relation
711 // ===========================================================================
712 
718 #define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \
719  do { \
720  if (!((actual) < (limit))) \
721  { \
722  ASSERT_ON_FAILURE; \
723  std::ostringstream msgStream; \
724  msgStream << msg; \
725  std::ostringstream actualStream; \
726  actualStream << actual; \
727  std::ostringstream limitStream; \
728  limitStream << limit; \
729  ReportTestFailure (std::string (#actual) + " (actual) < " + \
730  std::string (#limit) + " (limit)", \
731  actualStream.str (), limitStream.str (), \
732  msgStream.str (), file, line); \
733  CONTINUE_ON_FAILURE; \
734  } \
735  } while (false)
736 
742 #define NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
743  do { \
744  if (!((actual) <= (limit))) \
745  { \
746  ASSERT_ON_FAILURE; \
747  std::ostringstream msgStream; \
748  msgStream << msg; \
749  std::ostringstream actualStream; \
750  actualStream << actual; \
751  std::ostringstream limitStream; \
752  limitStream << limit; \
753  ReportTestFailure (std::string (#actual) + " (actual) < " + \
754  std::string (#limit) + " (limit)", \
755  actualStream.str (), limitStream.str (), \
756  msgStream.str (), file, line); \
757  CONTINUE_ON_FAILURE; \
758  } \
759  } while (false)
760 
778 #define NS_TEST_ASSERT_MSG_LT(actual, limit, msg) \
779  NS_TEST_ASSERT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
780 
798 #define NS_TEST_ASSERT_MSG_LT_OR_EQ(actual, limit, msg) \
799  NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
800 
808 #define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \
809  do { \
810  if (!((actual) < (limit))) \
811  { \
812  ASSERT_ON_FAILURE; \
813  std::ostringstream msgStream; \
814  msgStream << msg; \
815  std::ostringstream actualStream; \
816  actualStream << actual; \
817  std::ostringstream limitStream; \
818  limitStream << limit; \
819  ReportTestFailure (std::string (#actual) + " (actual) < " + \
820  std::string (#limit) + " (limit)", \
821  actualStream.str (), limitStream.str (), \
822  msgStream.str (), file, line); \
823  } \
824  } while (false)
825 
834 #define NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
835  do { \
836  if (!((actual) <= (limit))) \
837  { \
838  ASSERT_ON_FAILURE; \
839  std::ostringstream msgStream; \
840  msgStream << msg; \
841  std::ostringstream actualStream; \
842  actualStream << actual; \
843  std::ostringstream limitStream; \
844  limitStream << limit; \
845  ReportTestFailure (std::string (#actual) + " (actual) < " + \
846  std::string (#limit) + " (limit)", \
847  actualStream.str (), limitStream.str (), \
848  msgStream.str (), file, line); \
849  } \
850  } while (false)
851 
868 #define NS_TEST_EXPECT_MSG_LT(actual, limit, msg) \
869  NS_TEST_EXPECT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
870 
888 #define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg) \
889  NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
890 
891 // ===========================================================================
892 // Test for greater than relation
893 // ===========================================================================
894 
900 #define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \
901  do { \
902  if (!((actual) > (limit))) \
903  { \
904  ASSERT_ON_FAILURE; \
905  std::ostringstream msgStream; \
906  msgStream << msg; \
907  std::ostringstream actualStream; \
908  actualStream << actual; \
909  std::ostringstream limitStream; \
910  limitStream << limit; \
911  ReportTestFailure (std::string (#actual) + " (actual) > " + \
912  std::string (#limit) + " (limit)", \
913  actualStream.str (), limitStream.str (), \
914  msgStream.str (), file, line); \
915  CONTINUE_ON_FAILURE; \
916  } \
917  } while (false)
918 
924 #define NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
925  do { \
926  if (!((actual) >= (limit))) \
927  { \
928  ASSERT_ON_FAILURE; \
929  std::ostringstream msgStream; \
930  msgStream << msg; \
931  std::ostringstream actualStream; \
932  actualStream << actual; \
933  std::ostringstream limitStream; \
934  limitStream << limit; \
935  ReportTestFailure (std::string (#actual) + " (actual) > " + \
936  std::string (#limit) + " (limit)", \
937  actualStream.str (), limitStream.str (), \
938  msgStream.str (), file, line); \
939  CONTINUE_ON_FAILURE; \
940  } \
941  } while (false)
942 
960 #define NS_TEST_ASSERT_MSG_GT(actual, limit, msg) \
961  NS_TEST_ASSERT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
962 
980 #define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg) \
981  NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
982 
990 #define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \
991  do { \
992  if (!((actual) > (limit))) \
993  { \
994  ASSERT_ON_FAILURE; \
995  std::ostringstream msgStream; \
996  msgStream << msg; \
997  std::ostringstream actualStream; \
998  actualStream << actual; \
999  std::ostringstream limitStream; \
1000  limitStream << limit; \
1001  ReportTestFailure (std::string (#actual) + " (actual) > " + \
1002  std::string (#limit) + " (limit)", \
1003  actualStream.str (), limitStream.str (), \
1004  msgStream.str (), file, line); \
1005  } \
1006  } while (false)
1007 
1016 #define NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
1017  do { \
1018  if (!((actual) >= (limit))) \
1019  { \
1020  ASSERT_ON_FAILURE; \
1021  std::ostringstream msgStream; \
1022  msgStream << msg; \
1023  std::ostringstream actualStream; \
1024  actualStream << actual; \
1025  std::ostringstream limitStream; \
1026  limitStream << limit; \
1027  ReportTestFailure (std::string (#actual) + " (actual) > " + \
1028  std::string (#limit) + " (limit)", \
1029  actualStream.str (), limitStream.str (), \
1030  msgStream.str (), file, line); \
1031  } \
1032  } while (false)
1033 
1050 #define NS_TEST_EXPECT_MSG_GT(actual, limit, msg) \
1051  NS_TEST_EXPECT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
1052 
1070 #define NS_TEST_EXPECT_MSG_GT_OR_EQ(actual, limit, msg) \
1071  NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
1072 
1073 namespace ns3 {
1074 
1094 bool TestDoubleIsEqual (const double a, const double b,
1095  const double epsilon = std::numeric_limits<double>::epsilon ());
1096 
1097 class TestRunnerImpl;
1098 
1109 {
1110 public:
1116  QUICK = 1,
1119  };
1120 
1124  virtual ~TestCase ();
1125 
1129  std::string GetName (void) const;
1130 
1131 protected:
1135  TestCase (std::string name);
1136 
1143  void AddTestCase (TestCase *testCase, enum TestDuration duration);
1144 
1157  void SetDataDir (std::string directory);
1158 
1162  bool IsStatusFailure (void) const;
1166  bool IsStatusSuccess (void) const;
1167 
1171  TestCase * GetParent () const;
1172 
1189  void ReportTestFailure (std::string cond, std::string actual,
1190  std::string limit, std::string message,
1191  std::string file, int32_t line);
1195  bool MustAssertOnFailure (void) const;
1199  bool MustContinueOnFailure (void) const;
1204  std::string CreateDataDirFilename (std::string filename);
1211  std::string CreateTempDirFilename (std::string filename);
1213 private:
1214  friend class TestRunnerImpl;
1215 
1222  virtual void DoSetup (void);
1223 
1229  virtual void DoRun (void) = 0;
1230 
1236  virtual void DoTeardown (void);
1237 
1241  TestCase (TestCase& tc);
1246 
1247  // methods called by TestRunnerImpl
1253  void Run (TestRunnerImpl *runner);
1257  bool IsFailed (void) const;
1258 
1259  // Forward declaration is enough, since we only include a pointer here
1260  struct Result;
1261 
1262  TestCase *m_parent;
1263  std::vector<TestCase *> m_children;
1264  std::string m_dataDir;
1266  struct Result *m_result;
1267  std::string m_name;
1269 };
1270 
1276 class TestSuite : public TestCase
1277 {
1278 public:
1283  enum Type {
1284  ALL = 0,
1285  BVT = 1,
1290  };
1291 
1298  TestSuite (std::string name, Type type = UNIT);
1299 
1306 
1307 private:
1308  virtual void DoRun (void);
1309 
1310 
1312 };
1313 
1320 {
1321 public:
1329  static int Run (int argc, char *argv[]);
1330 };
1331 
1337 template <typename T>
1339 {
1340 public:
1344  TestVectors ();
1348  virtual ~TestVectors ();
1349 
1353  void Reserve (uint32_t reserve);
1354 
1359  uint32_t Add (T vector);
1360 
1364  uint32_t GetN (void) const;
1370  T Get (uint32_t i) const;
1371 
1372 private:
1376  TestVectors (const TestVectors& tv);
1380  TestVectors& operator= (const TestVectors& tv);
1384  bool operator== (const TestVectors& tv) const;
1385 
1386  typedef std::vector<T> TestVector;
1387  TestVector m_vectors;
1388 };
1389 
1390 template <typename T>
1392  : m_vectors ()
1393 {
1394 }
1395 
1396 template <typename T>
1397 void
1398 TestVectors<T>::Reserve (uint32_t reserve)
1399 {
1400  m_vectors.reserve (reserve);
1401 }
1402 
1403 template <typename T>
1405 {
1406 }
1407 
1408 template <typename T>
1409 uint32_t
1411 {
1412  uint32_t index = m_vectors.size ();
1413  m_vectors.push_back (vector);
1414  return index;
1415 }
1416 
1417 template <typename T>
1418 uint32_t
1420 {
1421  return m_vectors.size ();
1422 }
1423 
1424 template <typename T>
1425 T
1426 TestVectors<T>::Get (uint32_t i) const
1427 {
1428  NS_ABORT_MSG_UNLESS (m_vectors.size () > i, "TestVectors::Get(): Bad index");
1429  return m_vectors[i];
1430 }
1431 
1432 } // namespace ns3
1433 
1434 #endif /* NS3_TEST_H */
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
Definition: test.cc:355
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Definition: test.cc:360
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:1426
virtual ~TestVectors()
Virtual desctructor.
Definition: test.h:1404
Fast test.
Definition: test.h:1116
A suite of tests to run.
Definition: test.h:1276
A runner to execute tests.
Definition: test.h:1319
void Reserve(uint32_t reserve)
Definition: test.h:1398
Medium length test.
Definition: test.h:1117
bool IsFailed(void) const
Definition: test.cc:223
std::vector< T > TestVector
Container type.
Definition: test.h:1386
encapsulates test code
Definition: test.h:1108
enum TestDuration m_duration
TestCase duration.
Definition: test.h:1268
This test suite implements a Unit Test.
Definition: test.h:1286
uint32_t GetN(void) const
Definition: test.h:1419
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
Definition: test.cc:366
TestDuration
How long the test takes to execute.
Definition: test.h:1115
This test suite implements an Example Test.
Definition: test.h:1288
A simple way to store test vectors (for stimulus or from responses)
Definition: test.h:1338
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: test.cc:382
TestVectors()
Constructor.
Definition: test.h:1391
TestCase * m_parent
Pointer to my parent TestCase.
Definition: test.h:1260
TestRunnerImpl * m_runner
Pointer to the TestRunner.
Definition: test.h:1265
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:190
uint32_t Add(T vector)
Definition: test.h:1410
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:42
Type
Type of test.
Definition: test.h:1283
TestSuite::Type m_type
Type of this TestSuite.
Definition: test.h:1311
bool MustAssertOnFailure(void) const
Definition: test.cc:282
TestCase(std::string name)
Definition: test.cc:165
virtual ~TestCase()
Destructor.
Definition: test.cc:176
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string CreateDataDirFilename(std::string filename)
Definition: test.cc:295
This test suite implements a Performance Test.
Definition: test.h:1289
virtual void DoRun(void)=0
Implementation to actually run this TestCase.
struct Result * m_result
Results data.
Definition: test.h:1266
bool IsStatusFailure(void) const
Definition: test.cc:335
TestCase * GetParent() const
Definition: test.cc:259
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:265
bool operator==(const TestVectors &tv) const
Comparison (unimplemented?)
void Run(TestRunnerImpl *runner)
Actually run this TestCase.
Definition: test.cc:230
bool IsStatusSuccess(void) const
Definition: test.cc:341
This test suite implements a System Test.
Definition: test.h:1287
#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:313
This test suite implements a Build Verification Test.
Definition: test.h:1285
void SetDataDir(std::string directory)
Definition: test.cc:348
TestVector m_vectors
The list of test vectors.
Definition: test.h:1387
std::vector< TestCase * > m_children
Vector of my children.
Definition: test.h:1263
std::string GetName(void) const
Definition: test.cc:253
Very long running test.
Definition: test.h:1118
TestSuite::Type GetTestType(void)
get the kind of test this test suite implements
Definition: test.cc:375
static int Run(int argc, char *argv[])
Run the requested suite of tests.
Definition: test.cc:976
std::string m_name
TestCase name.
Definition: test.h:1267
TestCase & operator=(TestCase &tc)
Private, to block copying.
std::string m_dataDir
My data directory.
Definition: test.h:1264
bool MustContinueOnFailure(void) const
Definition: test.cc:288