exceptions.cpp
Go to the documentation of this file.
1 // Copyright 2020 Olivier Stasse
2 // LAAS, CNRS
3 
8 
9 #include <boost/version.hpp>
10 #include <sstream>
11 
12 #if BOOST_VERSION >= 105900
13 #include <boost/test/tools/output_test_stream.hpp>
14 #else
15 #include <boost/test/output_test_stream.hpp>
16 #endif
17 #include <boost/test/unit_test.hpp>
18 #include <boost/test/unit_test_suite.hpp>
19 
20 using boost::test_tools::output_test_stream;
21 using namespace dynamicgraph;
22 
23 BOOST_AUTO_TEST_CASE(exception_abstract_param) {
26  ExceptionAbstract::Param aParamSimple;
28  ExceptionAbstract::Param aParam(60, "function_test", "my_file");
29  aParamSimple.initCopy(aParam);
30 }
31 
32 BOOST_AUTO_TEST_CASE(exception_abstract) {
34  std::string msg_aea("Test exception abstract");
35  ExceptionAbstract aEA(10, msg_aea);
36 
37  const char *aC = aEA.getMessage();
38  output_test_stream output;
39  output << aC;
40  BOOST_CHECK(output.is_equal("Test exception abstract"));
41 
42  output << aEA;
43  BOOST_CHECK(
44  output.is_equal("AbstractError [#10]: Test exception abstract\n"));
45 }
46 
47 BOOST_AUTO_TEST_CASE(exception_traces) {
48  std::string msg_aet("Test exception traces simple");
50  output_test_stream output;
51  output << aET;
52  BOOST_CHECK(
53  output.is_equal("TracesError [#300]: Test exception traces simple\n"));
54 
56  int a = 2, b = 3;
57  std::string msg_aet2("Test exception traces ");
58  ExceptionTraces aET2(ExceptionTraces::GENERIC, msg_aet2, "(%d,%d)", a, b);
59  output << aET2;
60  BOOST_CHECK(
61  output.is_equal("TracesError [#300]: Test exception traces (2,3)\n"));
62 }
dynamicgraph::ExceptionAbstract::Param
Class owned by exceptions to store error locations.
Definition: exception-abstract.h:36
dynamicgraph
exception-signal.h
dynamicgraph::ExceptionAbstract
Abstract root class for all dynamic-graph exceptions.
Definition: exception-abstract.h:31
dynamicgraph::ExceptionTraces::GENERIC
@ GENERIC
Definition: exception-traces.h:20
dynamicgraph::ExceptionAbstract::getMessage
const char * getMessage() const
Access to the pointer on the array of char related to the error string.
Definition: exception-abstract.cpp:16
exception-factory.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(exception_abstract_param)
Definition: exceptions.cpp:23
exception-traces.h
dynamicgraph::ExceptionAbstract::Param::initCopy
Param & initCopy(const Param &p)
Definition: exception-abstract.cpp:26
dynamicgraph::ExceptionTraces
Exceptions raised when an error related to traces happen.
Definition: exception-traces.h:18
exception-abstract.h


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Fri Aug 2 2024 08:36:38