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 #include <boost/lexical_cast.hpp>
19 
20 Test::Test (const std::string& testName)
21  : name_ (testName), next_(0), lineNumber_(-1), safeCheck_(true)
22 {
23  TestRegistry::addTest (this);
24 }
25 
26 Test::Test (const std::string& testName, const std::string& filename, long lineNumber, bool safeCheck)
27  : name_(testName), next_(0), filename_(filename), lineNumber_(lineNumber), safeCheck_(safeCheck)
28 {
29  TestRegistry::addTest (this);
30 }
31 
32 
34 {
35  return next_;
36 }
37 
39 {
40  next_ = test;
41 }
42 
43 bool Test::check(long expected, long actual, TestResult& result, const std::string& fileName, long lineNumber)
44 {
45  if (expected == actual)
46  return true;
47  result.addFailure (
48  Failure (
49  name_,
50  boost::lexical_cast<std::string> (__FILE__),
51  __LINE__,
52  boost::lexical_cast<std::string> (expected),
53  boost::lexical_cast<std::string> (actual)));
54 
55  return false;
56 
57 }
58 
59 
60 bool Test::check(const std::string& expected, const std::string& actual, TestResult& result, const std::string& fileName, long lineNumber)
61 {
62  if (expected == actual)
63  return true;
64  result.addFailure (
65  Failure (
66  name_,
67  boost::lexical_cast<std::string> (__FILE__),
68  __LINE__,
69  expected,
70  actual));
71 
72  return false;
73 
74 }
75 
Matrix expected
Definition: testMatrix.cpp:974
bool check(long expected, long actual, TestResult &result, const std::string &fileName, long lineNumber)
Definition: Test.cpp:43
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:20
long lineNumber_
Definition: Test.h:55
void setNext(Test *test)
Definition: Test.cpp:38
Test * getNext() const
Definition: Test.cpp:33
void test(OptionalJacobian< 2, 3 > H=boost::none)
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 Sat May 8 2021 02:46:02