GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tests/exceptions.cpp Lines: 27 27 100.0 %
Date: 2023-03-15 12:04:10 Branches: 144 288 50.0 %

Line Branch Exec Source
1
// Copyright 2020 Olivier Stasse
2
// LAAS, CNRS
3
4
#include <dynamic-graph/exception-abstract.h>
5
#include <dynamic-graph/exception-factory.h>
6
#include <dynamic-graph/exception-signal.h>
7
#include <dynamic-graph/exception-traces.h>
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
















4
BOOST_AUTO_TEST_CASE(exception_abstract_param) {
24
  /// Test param from Exception
25
  /// Default constructor
26
2
  ExceptionAbstract::Param aParamSimple;
27
  /// Advanced constructor
28
2
  ExceptionAbstract::Param aParam(60, "function_test", "my_file");
29
2
  aParamSimple.initCopy(aParam);
30
2
}
31
32
















4
BOOST_AUTO_TEST_CASE(exception_abstract) {
33
  /// Test exception abstract with a simple message
34
4
  std::string msg_aea("Test exception abstract");
35
4
  ExceptionAbstract aEA(10, msg_aea);
36
37
2
  const char *aC = aEA.getMessage();
38

4
  output_test_stream output;
39
2
  output << aC;
40



2
  BOOST_CHECK(output.is_equal("Test exception abstract"));
41
42
2
  output << aEA;
43



2
  BOOST_CHECK(
44
      output.is_equal("AbstractError [#10]:  Test exception abstract\n"));
45
2
}
46
47
















4
BOOST_AUTO_TEST_CASE(exception_traces) {
48
4
  std::string msg_aet("Test exception traces simple");
49
4
  ExceptionTraces aET(ExceptionTraces::GENERIC, msg_aet);
50

4
  output_test_stream output;
51
2
  output << aET;
52



2
  BOOST_CHECK(
53
      output.is_equal("TracesError [#300]:  Test exception traces simple\n"));
54
55
  /// Test exception traces with a format.
56
2
  int a = 2, b = 3;
57
4
  std::string msg_aet2("Test exception traces ");
58
4
  ExceptionTraces aET2(ExceptionTraces::GENERIC, msg_aet2, "(%d,%d)", a, b);
59
2
  output << aET2;
60



2
  BOOST_CHECK(
61
      output.is_equal("TracesError [#300]:  Test exception traces (2,3)\n"));
62
2
}