Test.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 #include "Test.h"
14 #include "TestRegistry.h"
15 #include "TestResult.h"
16 #include "Failure.h"
17 
18 Test::Test (const std::string& testName)
19  : name_ (testName), next_(0), lineNumber_(-1), safeCheck_(true)
20 {
21  TestRegistry::addTest (this);
22 }
23 
24 Test::Test (const std::string& testName, const std::string& filename, long lineNumber, bool safeCheck)
25  : name_(testName), next_(0), filename_(filename), lineNumber_(lineNumber), safeCheck_(safeCheck)
26 {
27  TestRegistry::addTest (this);
28 }
29 
30 
32 {
33  return next_;
34 }
35 
37 {
38  next_ = test;
39 }
40 
41 bool Test::check(long expected, long actual, TestResult& result, const std::string& fileName, long lineNumber)
42 {
43  if (expected == actual)
44  return true;
45  result.addFailure (
46  Failure (
47  name_,
48  std::string(__FILE__),
49  __LINE__,
50  std::to_string(expected),
51  std::to_string(actual)));
52 
53  return false;
54 
55 }
56 
57 
58 bool Test::check(const std::string& expected, const std::string& actual, TestResult& result, const std::string& fileName, long lineNumber)
59 {
60  if (expected == actual)
61  return true;
62  result.addFailure (
63  Failure (
64  name_,
65  std::string(__FILE__),
66  __LINE__,
67  expected,
68  actual));
69 
70  return false;
71 
72 }
73 
Test * getNext() const
Definition: Test.cpp:31
Matrix expected
Definition: testMatrix.cpp:971
bool check(long expected, long actual, TestResult &result, const std::string &fileName, long lineNumber)
Definition: Test.cpp:41
Definition: test.py:1
Definition: Test.h:30
static void addTest(Test *test)
Test * next_
Definition: Test.h:53
Values result
Test(const std::string &testName)
Definition: Test.cpp:18
long lineNumber_
Definition: Test.h:55
void setNext(Test *test)
Definition: Test.cpp:36
void test(OptionalJacobian< 2, 3 > H={})
std::string name_
Definition: Test.h:52
std::string filename_
Definition: Test.h:54
virtual void addFailure(const Failure &failure)
Definition: TestResult.cpp:30
bool safeCheck_
This is the line line number of the test, rather than the a single check.
Definition: Test.h:56


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:37:45