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//
15// FAILURE.H
16//
17// Failure is a class which holds information pertaining to a specific
18// test failure. The stream insertion operator is overloaded to allow easy
19// display.
20//
21///////////////////////////////////////////////////////////////////////////////
22
23
24#pragma once
25
26#include <string>
27
28class Failure
29{
30
31public:
32 Failure (const std::string& theTestName,
33 const std::string& theFileName,
34 long theLineNumber,
35 const std::string& theCondition)
36 : message (theCondition),
37 testName (theTestName),
38 fileName (theFileName),
39 lineNumber (theLineNumber)
40 {
41 }
42
43 Failure (const std::string& theTestName,
44 const std::string& theFileName,
45 const std::string& theCondition)
46 : message (theCondition),
47 testName (theTestName),
48 fileName (theFileName),
49 lineNumber (-1)
50 {
51 }
52
53
54 Failure (const std::string& theTestName,
55 const std::string& theFileName,
56 long theLineNumber,
57 const std::string& expected,
58 const std::string& actual)
59 : message("expected " + expected + " but was: " + actual),
60 testName (theTestName),
61 fileName (theFileName),
62 lineNumber (theLineNumber)
63 {
64 }
65
66 std::string message;
67 std::string testName;
68 std::string fileName;
69 long lineNumber;
70};
71