A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #include "deprecated.h"
33 
40 //
41 // Note on below macros:
42 //
43 // When multiple statements are used in a macro, they should be bound together
44 // in a loop syntactically, so the macro can appear safely inside if clauses
45 // or other places that expect a single statement or a statement block. The
46 // "strange" do while construct is a generally expected best practice for
47 // defining a robust macro.
48 //
49 
55 #define ASSERT_ON_FAILURE \
56  do { \
57  if (MustAssertOnFailure ()) \
58  { \
59  *(volatile int *)0 = 0; \
60  } \
61  } while (false)
62 
68 #define CONTINUE_ON_FAILURE \
69  do { \
70  if (!MustContinueOnFailure ()) \
71  { \
72  return; \
73  } \
74  } while (false)
75 
81 #define CONTINUE_ON_FAILURE_RETURNS_BOOL \
82  do { \
83  if (!MustContinueOnFailure ()) \
84  { \
85  return IsStatusFailure (); \
86  } \
87  } while (false)
88 
89 
90 
91 // ===========================================================================
92 // Test for equality (generic version)
93 // ===========================================================================
94 
101 #define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \
102  do { \
103  if (!((actual) == (limit))) \
104  { \
105  ASSERT_ON_FAILURE; \
106  std::ostringstream msgStream; \
107  msgStream << msg; \
108  std::ostringstream actualStream; \
109  actualStream << actual; \
110  std::ostringstream limitStream; \
111  limitStream << limit; \
112  ReportTestFailure (std::string (#actual) + " (actual) == " + \
113  std::string (#limit) + " (limit)", \
114  actualStream.str (), limitStream.str (), \
115  msgStream.str (), file, line); \
116  CONTINUE_ON_FAILURE; \
117  } \
118  } while (false)
119 
148 #define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg) \
149  NS_TEST_ASSERT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
150 
157 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
158  do { \
159  if (!((actual) == (limit))) \
160  { \
161  ASSERT_ON_FAILURE; \
162  std::ostringstream msgStream; \
163  msgStream << msg; \
164  std::ostringstream actualStream; \
165  actualStream << actual; \
166  std::ostringstream limitStream; \
167  limitStream << limit; \
168  ReportTestFailure (std::string (#actual) + " (actual) == " + \
169  std::string (#limit) + " (limit)", \
170  actualStream.str (), limitStream.str (), \
171  msgStream.str (), file, line); \
172  CONTINUE_ON_FAILURE_RETURNS_BOOL; \
173  } \
174  } while (false)
175 
207 #define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg) \
208  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
209 
219 #define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line) \
220  do { \
221  if (!((actual) == (limit))) \
222  { \
223  ASSERT_ON_FAILURE; \
224  std::ostringstream msgStream; \
225  msgStream << msg; \
226  std::ostringstream actualStream; \
227  actualStream << actual; \
228  std::ostringstream limitStream; \
229  limitStream << limit; \
230  ReportTestFailure (std::string (#actual) + " (actual) == " + \
231  std::string (#limit) + " (limit)", \
232  actualStream.str (), limitStream.str (), \
233  msgStream.str (), file, line); \
234  } \
235  } while (false)
236 
265 #define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg) \
266  NS_TEST_EXPECT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
267 
268 // ===========================================================================
269 // Test for equality with a provided tolerance (use for floating point
270 // comparisons -- both float and double)
271 // ===========================================================================
272 
279 #define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \
280  do { \
281  if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
282  { \
283  ASSERT_ON_FAILURE; \
284  std::ostringstream msgStream; \
285  msgStream << msg; \
286  std::ostringstream actualStream; \
287  actualStream << actual; \
288  std::ostringstream limitStream; \
289  limitStream << limit << " +- " << tol; \
290  std::ostringstream condStream; \
291  condStream << #actual << " (actual) < " << #limit \
292  << " (limit) + " << #tol << " (tol) && " \
293  << #actual << " (actual) > " << #limit \
294  << " (limit) - " << #tol << " (tol)"; \
295  ReportTestFailure (condStream.str (), actualStream.str (), \
296  limitStream.str (), msgStream.str (), \
297  file, line); \
298  CONTINUE_ON_FAILURE; \
299  } \
300  } while (false)
301 
355 #define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg) \
356  NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
357 
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 
455 #define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \
456  do { \
457  if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
458  { \
459  ASSERT_ON_FAILURE; \
460  std::ostringstream msgStream; \
461  msgStream << msg; \
462  std::ostringstream actualStream; \
463  actualStream << actual; \
464  std::ostringstream limitStream; \
465  limitStream << limit << " +- " << tol; \
466  std::ostringstream condStream; \
467  condStream << #actual << " (actual) < " << #limit \
468  << " (limit) + " << #tol << " (tol) && " \
469  << #actual << " (actual) > " << #limit \
470  << " (limit) - " << #tol << " (tol)"; \
471  ReportTestFailure (condStream.str (), actualStream.str (), \
472  limitStream.str (), msgStream.str (), \
473  file, line); \
474  } \
475  } while (false)
476 
530 #define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg) \
531  NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
532 
533 // ===========================================================================
534 // Test for inequality
535 // ===========================================================================
536 
543 #define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \
544  do { \
545  if (!((actual) != (limit))) \
546  { \
547  ASSERT_ON_FAILURE; \
548  std::ostringstream msgStream; \
549  msgStream << msg; \
550  std::ostringstream actualStream; \
551  actualStream << actual; \
552  std::ostringstream limitStream; \
553  limitStream << limit; \
554  ReportTestFailure (std::string (#actual) + " (actual) != " + \
555  std::string (#limit) + " (limit)", \
556  actualStream.str (), limitStream.str (), \
557  msgStream.str (), file, line); \
558  CONTINUE_ON_FAILURE; \
559  } \
560  } while (false)
561 
589 #define NS_TEST_ASSERT_MSG_NE(actual, limit, msg) \
590  NS_TEST_ASSERT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
591 
598 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
599  do { \
600  if (!((actual) != (limit))) \
601  { \
602  ASSERT_ON_FAILURE; \
603  std::ostringstream msgStream; \
604  msgStream << msg; \
605  std::ostringstream actualStream; \
606  actualStream << actual; \
607  std::ostringstream limitStream; \
608  limitStream << limit; \
609  ReportTestFailure (std::string (#actual) + " (actual) != " + \
610  std::string (#limit) + " (limit)", \
611  actualStream.str (), limitStream.str (), \
612  msgStream.str (), file, line); \
613  CONTINUE_ON_FAILURE_RETURNS_BOOL; \
614  } \
615  } while (false)
616 
647 #define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg) \
648  NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
649 
659 #define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line) \
660  do { \
661  if (!((actual) != (limit))) \
662  { \
663  ASSERT_ON_FAILURE; \
664  std::ostringstream msgStream; \
665  msgStream << msg; \
666  std::ostringstream actualStream; \
667  actualStream << actual; \
668  std::ostringstream limitStream; \
669  limitStream << limit; \
670  ReportTestFailure (std::string (#actual) + " (actual) != " + \
671  std::string (#limit) + " (limit)", \
672  actualStream.str (), limitStream.str (), \
673  msgStream.str (), file, line); \
674  } \
675  } while (false)
676 
704 #define NS_TEST_EXPECT_MSG_NE(actual, limit, msg) \
705  NS_TEST_EXPECT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
706 
707 // ===========================================================================
708 // Test for less than relation
709 // ===========================================================================
710 
717 #define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \
718  do { \
719  if (!((actual) < (limit))) \
720  { \
721  ASSERT_ON_FAILURE; \
722  std::ostringstream msgStream; \
723  msgStream << msg; \
724  std::ostringstream actualStream; \
725  actualStream << actual; \
726  std::ostringstream limitStream; \
727  limitStream << limit; \
728  ReportTestFailure (std::string (#actual) + " (actual) < " + \
729  std::string (#limit) + " (limit)", \
730  actualStream.str (), limitStream.str (), \
731  msgStream.str (), file, line); \
732  CONTINUE_ON_FAILURE; \
733  } \
734  } while (false)
735 
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 
809 #define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line) \
810  do { \
811  if (!((actual) < (limit))) \
812  { \
813  ASSERT_ON_FAILURE; \
814  std::ostringstream msgStream; \
815  msgStream << msg; \
816  std::ostringstream actualStream; \
817  actualStream << actual; \
818  std::ostringstream limitStream; \
819  limitStream << limit; \
820  ReportTestFailure (std::string (#actual) + " (actual) < " + \
821  std::string (#limit) + " (limit)", \
822  actualStream.str (), limitStream.str (), \
823  msgStream.str (), file, line); \
824  } \
825  } while (false)
826 
836 #define NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
837  do { \
838  if (!((actual) <= (limit))) \
839  { \
840  ASSERT_ON_FAILURE; \
841  std::ostringstream msgStream; \
842  msgStream << msg; \
843  std::ostringstream actualStream; \
844  actualStream << actual; \
845  std::ostringstream limitStream; \
846  limitStream << limit; \
847  ReportTestFailure (std::string (#actual) + " (actual) < " + \
848  std::string (#limit) + " (limit)", \
849  actualStream.str (), limitStream.str (), \
850  msgStream.str (), file, line); \
851  } \
852  } while (false)
853 
870 #define NS_TEST_EXPECT_MSG_LT(actual, limit, msg) \
871  NS_TEST_EXPECT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
872 
890 #define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg) \
891  NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
892 
893 // ===========================================================================
894 // Test for greater than relation
895 // ===========================================================================
896 
903 #define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \
904  do { \
905  if (!((actual) > (limit))) \
906  { \
907  ASSERT_ON_FAILURE; \
908  std::ostringstream msgStream; \
909  msgStream << msg; \
910  std::ostringstream actualStream; \
911  actualStream << actual; \
912  std::ostringstream limitStream; \
913  limitStream << limit; \
914  ReportTestFailure (std::string (#actual) + " (actual) > " + \
915  std::string (#limit) + " (limit)", \
916  actualStream.str (), limitStream.str (), \
917  msgStream.str (), file, line); \
918  CONTINUE_ON_FAILURE; \
919  } \
920  } while (false)
921 
928 #define NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
929  do { \
930  if (!((actual) >= (limit))) \
931  { \
932  ASSERT_ON_FAILURE; \
933  std::ostringstream msgStream; \
934  msgStream << msg; \
935  std::ostringstream actualStream; \
936  actualStream << actual; \
937  std::ostringstream limitStream; \
938  limitStream << limit; \
939  ReportTestFailure (std::string (#actual) + " (actual) > " + \
940  std::string (#limit) + " (limit)", \
941  actualStream.str (), limitStream.str (), \
942  msgStream.str (), file, line); \
943  CONTINUE_ON_FAILURE; \
944  } \
945  } while (false)
946 
964 #define NS_TEST_ASSERT_MSG_GT(actual, limit, msg) \
965  NS_TEST_ASSERT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
966 
984 #define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg) \
985  NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
986 
995 #define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line) \
996  do { \
997  if (!((actual) > (limit))) \
998  { \
999  ASSERT_ON_FAILURE; \
1000  std::ostringstream msgStream; \
1001  msgStream << msg; \
1002  std::ostringstream actualStream; \
1003  actualStream << actual; \
1004  std::ostringstream limitStream; \
1005  limitStream << limit; \
1006  ReportTestFailure (std::string (#actual) + " (actual) > " + \
1007  std::string (#limit) + " (limit)", \
1008  actualStream.str (), limitStream.str (), \
1009  msgStream.str (), file, line); \
1010  } \
1011  } while (false)
1012 
1022 #define NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line) \
1023  do { \
1024  if (!((actual) >= (limit))) \
1025  { \
1026  ASSERT_ON_FAILURE; \
1027  std::ostringstream msgStream; \
1028  msgStream << msg; \
1029  std::ostringstream actualStream; \
1030  actualStream << actual; \
1031  std::ostringstream limitStream; \
1032  limitStream << limit; \
1033  ReportTestFailure (std::string (#actual) + " (actual) > " + \
1034  std::string (#limit) + " (limit)", \
1035  actualStream.str (), limitStream.str (), \
1036  msgStream.str (), file, line); \
1037  } \
1038  } while (false)
1039 
1056 #define NS_TEST_EXPECT_MSG_GT(actual, limit, msg) \
1057  NS_TEST_EXPECT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
1058 
1076 #define NS_TEST_EXPECT_MSG_GT_OR_EQ(actual, limit, msg) \
1077  NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
1078 
1079 namespace ns3 {
1080 
1099 bool TestDoubleIsEqual (const double a, const double b,
1100  const double epsilon = std::numeric_limits<double>::epsilon ());
1101 
1102 class TestRunnerImpl;
1103 
1114 {
1115 public:
1121  QUICK = 1,
1124  };
1125 
1129  virtual ~TestCase ();
1130 
1134  std::string GetName (void) const;
1135 
1136 protected:
1140  TestCase (std::string name);
1141 
1150  void AddTestCase (TestCase *testCase) NS_DEPRECATED;
1151 
1158  void AddTestCase (TestCase *testCase, enum TestDuration duration);
1159 
1172  void SetDataDir (std::string directory);
1173 
1178  bool GetErrorStatus (void) const NS_DEPRECATED;
1182  bool IsStatusFailure (void) const;
1186  bool IsStatusSuccess (void) const;
1187 
1191  TestCase * GetParent () const;
1192 
1202  void ReportTestFailure (std::string cond, std::string actual,
1203  std::string limit, std::string message,
1204  std::string file, int32_t line);
1208  bool MustAssertOnFailure (void) const;
1212  bool MustContinueOnFailure (void) const;
1217  std::string CreateDataDirFilename (std::string filename);
1224  std::string CreateTempDirFilename (std::string filename);
1226 private:
1227  friend class TestRunnerImpl;
1228 
1235  virtual void DoSetup (void);
1236 
1242  virtual void DoRun (void) = 0;
1243 
1249  virtual void DoTeardown (void);
1250 
1254  TestCase (TestCase& tc);
1258  TestCase& operator= (TestCase& tc);
1259 
1260  // methods called by TestRunnerImpl
1266  void Run (TestRunnerImpl *runner);
1270  bool IsFailed (void) const;
1271 
1272  // Forward declaration is enough, since we only include a pointer here
1273  struct Result;
1274 
1275  TestCase *m_parent;
1276  std::vector<TestCase *> m_children;
1277  std::string m_dataDir;
1278  TestRunnerImpl *m_runner;
1279  struct Result *m_result;
1280  std::string m_name;
1282 };
1283 
1289 class TestSuite : public TestCase
1290 {
1291 public:
1296  enum Type {
1297  ALL = 0,
1298  BVT = 1,
1302  PERFORMANCE
1303  };
1304 
1311  TestSuite (std::string name, Type type = UNIT);
1312 
1318  TestSuite::Type GetTestType (void);
1319 
1320 private:
1321  virtual void DoRun (void);
1322 
1323 
1325 };
1326 
1333 {
1334 public:
1342  static int Run (int argc, char *argv[]);
1343 };
1344 
1350 template <typename T>
1352 {
1353 public:
1357  TestVectors ();
1361  virtual ~TestVectors ();
1362 
1366  void Reserve (uint32_t reserve);
1367 
1372  uint32_t Add (T vector);
1373 
1377  uint32_t GetN (void) const;
1383  T Get (uint32_t i) const;
1384 
1385 private:
1389  TestVectors (const TestVectors& tv);
1393  TestVectors& operator= (const TestVectors& tv);
1397  bool operator== (const TestVectors& tv) const;
1398 
1399  typedef std::vector<T> TestVector;
1401 };
1402 
1403 template <typename T>
1405  : m_vectors ()
1406 {
1407 }
1408 
1409 template <typename T>
1410 void
1411 TestVectors<T>::Reserve (uint32_t reserve)
1412 {
1413  m_vectors.reserve (reserve);
1414 }
1415 
1416 template <typename T>
1418 {
1419 }
1420 
1421 template <typename T>
1422 uint32_t
1424 {
1425  uint32_t index = m_vectors.size ();
1426  m_vectors.push_back (vector);
1427  return index;
1428 }
1429 
1430 template <typename T>
1431 uint32_t
1433 {
1434  return m_vectors.size ();
1435 }
1436 
1437 template <typename T>
1438 T
1439 TestVectors<T>::Get (uint32_t i) const
1440 {
1441  NS_ABORT_MSG_UNLESS (m_vectors.size () > i, "TestVectors::Get(): Bad index");
1442  return m_vectors[i];
1443 }
1444 
1445 } // namespace ns3
1446 
1447 #endif /* NS3_TEST_H */
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
Definition: test.cc:361
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Definition: test.cc:366
This test suite implements a System Test.
Definition: test.h:1300
T Get(uint32_t i) const
Get the i'th test vector.
Definition: test.h:1439
virtual ~TestVectors()
Virtual desctructor.
Definition: test.h:1417
A suite of tests to run.
Definition: test.h:1289
A runner to execute tests.
Definition: test.h:1332
void Reserve(uint32_t reserve)
Definition: test.h:1411
Very long running test.
Definition: test.h:1123
Type
Type of test.
Definition: test.h:1296
bool IsFailed(void) const
Definition: test.cc:223
std::vector< T > TestVector
Container type.
Definition: test.h:1399
encapsulates test code
Definition: test.h:1113
enum TestDuration m_duration
TestCase duration.
Definition: test.h:1281
uint32_t GetN(void) const
Definition: test.h:1432
A simple way to store test vectors (for stimulus or from responses)
Definition: test.h:1351
TestVectors()
Constructor.
Definition: test.h:1404
TestCase * m_parent
Pointer to my parent TestCase.
Definition: test.h:1273
TestRunnerImpl * m_runner
Pointer to the TestRunner.
Definition: test.h:1278
#define NS_DEPRECATED
Definition: deprecated.h:7
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
uint32_t Add(T vector)
Definition: test.h:1423
Medium length test.
Definition: test.h:1122
TestSuite::Type m_type
Type of this TestSuite.
Definition: test.h:1324
bool MustAssertOnFailure(void) const
Definition: test.cc:282
TestCase(std::string name)
Definition: test.cc:159
bool GetErrorStatus(void) const NS_DEPRECATED
Definition: test.cc:335
TestDuration
How long the test takes to execute.
Definition: test.h:1120
virtual ~TestCase()
Destructor.
Definition: test.cc:170
std::string CreateDataDirFilename(std::string filename)
Definition: test.cc:295
virtual void DoRun(void)=0
Implementation to actually run this TestCase.
struct Result * m_result
Results data.
Definition: test.h:1279
bool IsStatusFailure(void) const
Definition: test.cc:341
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
void Run(TestRunnerImpl *runner)
Actually run this TestCase.
Definition: test.cc:230
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
bool IsStatusSuccess(void) const
Definition: test.cc:347
Fast test.
Definition: test.h:1121
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if cond is false.
Definition: abort.h:136
#define private
std::string CreateTempDirFilename(std::string filename)
Definition: test.cc:313
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.cc:89
void SetDataDir(std::string directory)
Definition: test.cc:354
TestVector m_vectors
The list of test vectors.
Definition: test.h:1400
std::vector< TestCase * > m_children
Vector of my children.
Definition: test.h:1276
This test suite implements an Example Test.
Definition: test.h:1301
std::string GetName(void) const
Definition: test.cc:253
This test suite implements a Unit Test.
Definition: test.h:1299
std::string m_name
TestCase name.
Definition: test.h:1280
TestCase & operator=(TestCase &tc)
Private, to block copying.
std::string m_dataDir
My data directory.
Definition: test.h:1277
bool MustContinueOnFailure(void) const
Definition: test.cc:288