GammaLib  2.0.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GException_test.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GException_test.cpp - Unit Test exception handlers *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012 by Jean-Baptiste Cayrou *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GException_test.cpp
23  * @brief Implement exceptions for unit test module
24  * @author Jean-Baptiste Cayrou
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GException.hpp"
32 #include "GTools.hpp"
33 
34 
35 /***********************************************************************//**
36  * @brief Test nested try error
37  *
38  * @param[in] origin Method throwing the exception.
39  * @param[in] message Optional error message.
40  ***************************************************************************/
41 GException::test_nested_try_error::test_nested_try_error(std::string origin, std::string message)
42 {
43  // Set origin and message
44  m_origin = origin;
45  m_message = "Nested try error ("+message+")";
46 
47  // Return
48  return;
49 }
50 
51 /***********************************************************************//**
52  * @brief Failure test
53  *
54  * @param[in] origin Method throwing the exception.
55  * @param[in] message Optional error message.
56  *
57  * Use in unit tests to notice a fail in a try block
58  ***************************************************************************/
59 GException::test_failure::test_failure(std::string origin, std::string message)
60 {
61  // Set origin and message
62  m_origin = origin;
63  m_message = "Failure Test ("+message+")";
64 
65  // Return
66  return;
67 }
68 
69 /***********************************************************************//**
70  * @brief Failure test
71  *
72  * @param[in] origin Method throwing the exception.
73  * @param[in] message Optional error message.
74  *
75  * Use in unit tests to notice a fail in a try block
76  ***************************************************************************/
77 GException::test_error::test_error(std::string origin, std::string message)
78 {
79  // Set origin and message
80  m_origin = origin;
81  m_message = "Error Test ("+message+")";
82 
83  // Return
84  return;
85 }
Gammalib tools definition.
std::string m_message
Definition: GException.hpp:51
test_error(std::string origin, std::string message="")
Failure test.
test_nested_try_error(std::string origin, std::string message="")
Test nested try error.
Exception handler interface definition.
std::string m_origin
Definition: GException.hpp:50
test_failure(std::string origin, std::string message="")
Failure test.