CppUnitLite
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
21
void
TestRegistry::addTest
(
Test
*
test
)
22
{
23
instance
().
add
(
test
);
24
}
25
26
27
int
TestRegistry::runAllTests
(
TestResult
&
result
)
28
{
29
return
instance
().
run
(
result
);
30
}
31
32
33
TestRegistry
&
TestRegistry::instance
()
34
{
35
static
TestRegistry
registry;
36
return
registry;
37
}
38
39
40
void
TestRegistry::add
(
Test
*
test
)
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
55
int
TestRegistry::run
(
TestResult
&
result
)
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
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition:
TestRegistry.cpp:27
TestRegistry::addTest
static void addTest(Test *test)
Definition:
TestRegistry.cpp:21
TestResult.h
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
TestRegistry::run
int run(TestResult &result)
Definition:
TestRegistry.cpp:55
result
Values result
Definition:
OdometryOptimize.cpp:8
test
Definition:
test.py:1
Failure
Definition:
Failure.h:28
test
void test(OptionalJacobian< 2, 3 > H={})
Definition:
testOptionalJacobian.cpp:63
TestRegistry::lastTest
Test * lastTest
Definition:
TestRegistry.h:43
TestRegistry::instance
static TestRegistry & instance()
Definition:
TestRegistry.cpp:33
TestRegistry
Definition:
TestRegistry.h:29
TestRegistry::add
void add(Test *test)
Definition:
TestRegistry.cpp:40
TestRegistry.h
Test::setNext
void setNext(Test *test)
Definition:
Test.cpp:36
TestResult
Definition:
TestResult.h:26
TestRegistry::tests
Test * tests
Definition:
TestRegistry.h:42
Test.h
Test
Definition:
Test.h:30
Failure.h
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:08:22