TestRegistry.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
12 
13 
14 #include <exception>
15 
16 #include "Test.h"
17 #include "Failure.h"
18 #include "TestResult.h"
19 #include "TestRegistry.h"
20 
22 {
23  instance ().add (test);
24 }
25 
26 
28 {
29  return instance ().run (result);
30 }
31 
32 
34 {
35  static TestRegistry registry;
36  return registry;
37 }
38 
39 
41 {
42  if (tests == 0) {
43  test->setNext(0);
44  tests = test;
45  lastTest = test;
46  return;
47  }
48 
49  test->setNext (0);
50  lastTest->setNext(test);
51  lastTest = test;
52 }
53 
54 
56 {
57  result.testsStarted ();
58 
59  for (Test *test = tests; test != 0; test = test->getNext ()) {
60  if (test->safe()) {
61  try {
62  test->run (result);
63  } catch (std::exception& e) {
64  // catch standard exceptions and derivatives
65  result.addFailure(
66  Failure(test->getName(), test->getFilename(), test->getLineNumber(),
67  std::string("Exception: ") + std::string(e.what())));
68  } catch (...) {
69  // catch all other exceptions
70  result.addFailure(
71  Failure(test->getName(), test->getFilename(), test->getLineNumber(),
72  "ExceptionThrown!"));
73  }
74  }
75  else {
76  test->run (result);
77  }
78  }
79  result.testsEnded ();
80  return result.getFailureCount();
81 }
82 
83 
84 
virtual void testsEnded()
Definition: TestResult.cpp:51
static int runAllTests(TestResult &result)
int run(TestResult &result)
Definition: test.py:1
Definition: Test.h:30
Test * lastTest
Definition: TestRegistry.h:43
static void addTest(Test *test)
void add(Test *test)
Values result
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void setNext(Test *test)
Definition: Test.cpp:36
virtual void testsStarted()
Definition: TestResult.cpp:25
static TestRegistry & instance()
void test(OptionalJacobian< 2, 3 > H={})
Test * tests
Definition: TestRegistry.h:42
int getFailureCount()
Definition: TestResult.h:35
virtual void addFailure(const Failure &failure)
Definition: TestResult.cpp:30


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:39:15