| 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 (test: 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 (test: this); |
| 28 | } |
| 29 | |
| 30 | |
| 31 | Test *Test::getNext() const |
| 32 | { |
| 33 | return next_; |
| 34 | } |
| 35 | |
| 36 | void Test::setNext(Test *test) |
| 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: Failure ( |
| 47 | name_, |
| 48 | std::string(__FILE__), |
| 49 | __LINE__, |
| 50 | std::to_string(val: expected), |
| 51 | std::to_string(val: 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: Failure ( |
| 64 | name_, |
| 65 | std::string(__FILE__), |
| 66 | __LINE__, |
| 67 | expected, |
| 68 | actual)); |
| 69 | |
| 70 | return false; |
| 71 | |
| 72 | } |
| 73 | |
| 74 | |