File: Test.cpp

package info (click to toggle)
gtsam 4.2.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 46,108 kB
  • sloc: cpp: 127,191; python: 14,312; xml: 8,442; makefile: 252; sh: 119; ansic: 101
file content (75 lines) | stat: -rw-r--r-- 1,755 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* ----------------------------------------------------------------------------

 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
 * Atlanta, Georgia 30332-0415
 * All Rights Reserved
 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)

 * See LICENSE for the license information

 * -------------------------------------------------------------------------- */


#include "Test.h"
#include "TestRegistry.h"
#include "TestResult.h"
#include "Failure.h"

#include <boost/lexical_cast.hpp>

Test::Test (const std::string& testName)
  : name_ (testName), next_(0), lineNumber_(-1), safeCheck_(true)
{
  TestRegistry::addTest (this);
}

Test::Test (const std::string& testName, const std::string& filename, long lineNumber, bool safeCheck)
  : name_(testName), next_(0), filename_(filename), lineNumber_(lineNumber), safeCheck_(safeCheck)
{
  TestRegistry::addTest (this);
}


Test *Test::getNext() const
{
  return next_;
}

void Test::setNext(Test *test)
{
  next_ = test;
}

bool Test::check(long expected, long actual, TestResult& result, const std::string& fileName, long lineNumber)
{
  if (expected == actual)
    return true;
  result.addFailure (
    Failure (
      name_,
      boost::lexical_cast<std::string> (__FILE__),
      __LINE__,
      boost::lexical_cast<std::string> (expected),
      boost::lexical_cast<std::string> (actual)));

  return false;

}


bool Test::check(const std::string& expected, const std::string& actual, TestResult& result, const std::string& fileName, long lineNumber)
{
  if (expected == actual)
    return true;
  result.addFailure (
    Failure (
      name_,
      boost::lexical_cast<std::string> (__FILE__),
      __LINE__,
      expected,
      actual));

  return false;

}