...
 
Commits (36)
......@@ -23,7 +23,7 @@ notifications:
branches:
only:
- master
- debian
- devel
script: ./travis_custom/build_custom
after_success: ./.travis/run after_success
after_failure: ./.travis/run after_failure
......
......@@ -96,7 +96,6 @@ SET(${PROJECT_NAME}_SOURCES
SET(${PROJECT_NAME}_HEADERS
include/dynamic-graph/fwd.hh
include/dynamic-graph/null-ptr.hh
include/dynamic-graph/debug.h
include/dynamic-graph/real-time-logger.h
......
dynamic-graph
=============
[![Building Status](https://travis-ci.org/stack-of-tasks/dynamic-graph.svg?branch=master)](https://travis-ci.org/stack-of-tasks/dynamic-graph)
[![Pipeline status](https://gepgitlab.laas.fr/stack-of-tasks/dynamic-graph/badges/master/pipeline.svg)](https://gepgitlab.laas.fr/stack-of-tasks/dynamic-graph/commits/master)
[![Building status](https://gepgitlab.laas.fr/stack-of-tasks/dynamic-graph/badges/master/pipeline.svg)](https://gepgitlab.laas.fr/stack-of-tasks/dynamic-graph/commits/master)
[![Coverage report](https://gepgitlab.laas.fr/stack-of-tasks/dynamic-graph/badges/master/coverage.svg?job=doc-coverage)](http://projects.laas.fr/stack-of-tasks/doc/stack-of-tasks/dynamic-graph/master/coverage/)
[![License](https://img.shields.io/badge/License-BSD%202--Clause-green.svg)](https://opensource.org/licenses/BSD-2-Clause)
This software provides an efficient way to modelize a C++ data-flow.
......@@ -42,10 +42,7 @@ located in the `$prefix/share/doc/dynamic-graph` directoy where
Getting Help
------------
Support is provided through:
* the HPP mailing-list: hpp@laas.fr
* the following HipChat room: http://www.hipchat.com/gh4wQrZeV
Support is provided through issues on the github interface.
How can I install dynamic-graph?
--------------------------------
......@@ -57,13 +54,9 @@ have to be available on your machine.
- Libraries:
- [Boost][] (>= 1.40)
Its detection is controlled by the `BOOST_ROOT` variable, see next section
for more information.
- [Lapack][] library
Use the generic purpose `CMAKE_CXX_FLAGS` and `CMAKE_EXE_LINKER_FLAGS`
to insert the flags required for the compiler to find your Lapack library
if it is installed in a non-standard directory.
- [jrl-mal][] library
- Doxygen
- Eigen3
- pthread
- System tools:
- [CMake][] (>=2.6)
- [pkg-config][]
......@@ -143,15 +136,12 @@ This package authors are credited in the [AUTHORS](AUTHORS) file.
Available Packages
------------------
* RobotPkg (Release 2.5.3r1):
* RobotPkg :
http://robotpkg.openrobots.org/robotpkg/motion/dynamic-graph/index.html
[doxygen-documentation]: http://stack-of-tasks.github.io/dynamic-graph/doxygen/HEAD/
[jrl-mathtools]: https://github.com/jrl-umi3218/jrl-mathtools
[jrl-mal]: https://github.com/jrl-umi3218/jrl-mal
[git-submodules]: http://git-scm.com/book/en/Git-Tools-Submodules
[Boost]: http://www.boost.org/
......@@ -159,7 +149,6 @@ Available Packages
[Doxygen]: http://www.stack.nl/~dimitri/doxygen/
[Eigen]: http://eigen.tuxfamily.org/
[Git]: http://git-scm.com/
[Lapack]: http://www.netlib.org/lapack/
[Libtool]: https://www.gnu.org/software/libtool/
[RobotPkg]: http://robotpkg.openrobots.org/
[log4cxx]: https://logging.apache.org/log4cxx/
......
......@@ -7,6 +7,7 @@
#ifndef DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#define DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#include "dynamic-graph/command-setter.h"
#include "dynamic-graph/linear-algebra.h"
#include "dynamic-graph/command-setter.h"
#include <boost/assign/list_of.hpp>
......
......@@ -9,8 +9,10 @@
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
#pragma GCC diagnostic push
#pragma GCC system_header
#include <Eigen/Geometry>
#pragma GCC diagnostic pop
#include <dynamic-graph/exception-signal.h>
#include <dynamic-graph/linear-algebra.h>
......
......@@ -6,8 +6,11 @@
#ifndef DYNAMIC_GRAPH_LINEAR_ALGEBRA_H
#define DYNAMIC_GRAPH_LINEAR_ALGEBRA_H
#pragma GCC diagnostic push
#pragma GCC system_header
#include <Eigen/Core>
#include <Eigen/Geometry>
#pragma GCC diagnostic pop
namespace dynamicgraph {
typedef Eigen::MatrixXd Matrix;
......
// Copyright 2010, Thomas Moulard, JRL, CNRS/AIST
//
#ifndef DYNAMIC_GRAPH_NULL_PTR_HH
#define DYNAMIC_GRAPH_NULL_PTR_HH
namespace dynamicgraph {
/// \cond
const class {
public:
template <class T> operator T *() const { return 0; }
template <class C, class T> operator T C::*() const { return 0; }
private:
void operator&() const;
} nullptr = {};
/// \endcond
} // end of namespace dynamicgraph.
#endif //! DYNAMIC_GRAPH_NULL_PTR_HH
......@@ -20,6 +20,11 @@ namespace dynamicgraph {
/// In that sense, when plugged into, it acts as a "pointer" to the
/// input signal, hence the name. Operator -> is also overloaded and
/// can be used to access the pointed signal.
///
/// If the signal provided as a parameter of the plug operation
/// cannot be casted in type T, but is compatible then the class
/// holds a reference to an abstract object.
///
template <class T, class Time>
class SignalPtr : public virtual Signal<T, Time> {
public:
......
......@@ -107,6 +107,8 @@ public:
}
public:
/// checkCompatibility is used to get the object contained in the
/// signal. This used to verify if a dynamic cast is possible or not.
virtual void checkCompatibility() { throw Tcopy; }
private:
......
......@@ -113,21 +113,6 @@ bool TimeDependency<Time>::needUpdate(const Time &t1) const {
template <class Time>
std::ostream &TimeDependency<Time>::writeGraph(std::ostream &os) const {
std::string LeaderLocalName;
std::string LeaderNodeName;
leader.ExtractNodeAndLocalNames(LeaderLocalName, LeaderNodeName);
if (dependencies.size() != 0) {
const typename Dependencies::const_iterator itend = dependencies.end();
for (typename Dependencies::const_iterator it = dependencies.begin();
it != itend; ++it) {
std::string itLocalName, itNodeName;
(*it)->ExtractNodeAndLocalNames(itLocalName, itNodeName);
os << "\"" << itNodeName << "\" -> \"" << LeaderNodeName << "\""
<< std::endl
<< " [ headlabel = \"" << LeaderLocalName << "\" , taillabel = \""
<< itLocalName << "\" ]" << std::endl;
}
}
return os;
}
......@@ -159,7 +144,7 @@ TimeDependency<Time>::displayDependencies(std::ostream &os, const int depth,
std::string ajout = "|";
std::string ajout2 = "|";
typename Dependencies::const_iterator it2 = it;
it2++;
++it2;
if (it2 == dependencies.end()) {
ajout = "`";
ajout2 = " ";
......
......@@ -72,22 +72,22 @@ struct RealTimeLogger::thread {
bool changedThreadParams;
boost::thread t_;
thread(RealTimeLogger *logger)
explicit thread(RealTimeLogger *logger)
: requestShutdown_(false), threadPolicy_(SCHED_OTHER), threadPriority_(0),
changedThreadParams(true), t_(&thread::spin, this, logger) {}
void setThreadPolicy(int policy) {
threadPolicy_ = policy;
changedThreadParams = true;
}
// void setThreadPolicy(int policy) {
// threadPolicy_ = policy;
// changedThreadParams = true;
// }
void setPriority(int priority) {
threadPriority_ = priority;
changedThreadParams = true;
}
// void setPriority(int priority) {
// threadPriority_ = priority;
// changedThreadParams = true;
// }
int getThreadPolicy() { return threadPolicy_; }
int getThreadPriority() { return threadPriority_; }
// int getThreadPolicy() { return threadPolicy_; }
// int getThreadPriority() { return threadPriority_; }
void changeThreadParams() {
int threadPolicy;
......
......@@ -46,7 +46,7 @@ Entity::Entity(const string &name__) : name(name__) {
Entity::~Entity() {
dgDEBUG(25) << "# In (" << name << " { " << endl;
for (std::map<const std::string, Command *>::iterator it = commandMap.begin();
it != commandMap.end(); it++) {
it != commandMap.end(); ++it) {
delete it->second;
}
dgDEBUGOUT(25);
......
......@@ -83,7 +83,7 @@ std::vector<std::string> SignalCaster::listTypenames() const {
std::vector<std::string> typeList;
for (std::map<std::string, cast_functions_type>::const_iterator iter =
functions_.begin();
iter != functions_.end(); iter++)
iter != functions_.end(); ++iter)
typeList.push_back(iter->first);
return typeList;
}
......
......@@ -317,7 +317,7 @@ void TracerRealTime::display(std::ostream &os) const {
os.precision(PRECISION);
}
os << endl;
iterFile++;
++iterFile;
}
}
......
......@@ -59,9 +59,12 @@ DYNAMIC_GRAPH_TEST(real-time-logger)
DYNAMIC_GRAPH_TEST(debug-trace)
DYNAMIC_GRAPH_TEST(debug-tracer)
TARGET_LINK_LIBRARIES(debug-tracer tracer)
DYNAMIC_GRAPH_TEST(debug-real-time-tracer)
TARGET_LINK_LIBRARIES(debug-real-time-tracer tracer-real-time tracer)
DYNAMIC_GRAPH_TEST(debug-logger)
DYNAMIC_GRAPH_TEST(debug-logger-winit)
DYNAMIC_GRAPH_TEST(signal-all)
DYNAMIC_GRAPH_TEST(command-test)
DYNAMIC_GRAPH_TEST(test-mt)
TARGET_LINK_LIBRARIES(test-mt tracer)
DYNAMIC_GRAPH_TEST(exceptions)
......@@ -37,7 +37,7 @@ public:
bool test_four_args_;
virtual const std::string &getClassName() const { return CLASS_NAME; }
CustomEntity(const std::string n) : Entity(n) {
explicit CustomEntity(const std::string &n) : Entity(n) {
test_zero_arg_ = false;
test_one_arg_ = false;
test_two_args_ = false;
......@@ -62,6 +62,16 @@ public:
makeCommandVoid4(
*this, &CustomEntity::four_args,
docCommandVoid4("four args", "int", "int", "int", "int")));
/// Generating an exception by adding a command which already exist
bool res = false;
std::string e_1_arg("1_arg");
try {
addCommand(e_1_arg, getNewStyleCommand(e_1_arg));
} catch (dynamicgraph::ExceptionFactory &aef) {
res = (aef.getCode() == dynamicgraph::ExceptionFactory::OBJECT_CONFLICT);
}
BOOST_CHECK(res);
}
~CustomEntity() {}
......@@ -84,10 +94,11 @@ DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity");
} // namespace dynamicgraph
BOOST_AUTO_TEST_CASE(command_test) {
dynamicgraph::CustomEntity &entity =
*(dynamic_cast<dynamicgraph::CustomEntity *>(
dynamicgraph::CustomEntity *ptr_entity =
(dynamic_cast<dynamicgraph::CustomEntity *>(
dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity",
"my-entity")));
dynamicgraph::CustomEntity &entity = *ptr_entity;
std::map<const std::string, Command *> aCommandMap =
entity.getNewStyleCommandMap();
......@@ -116,10 +127,55 @@ BOOST_AUTO_TEST_CASE(command_test) {
values.push_back(aValue);
it_map->second->setParameterValues(values);
it_map->second->execute();
it_map->second->owner();
it_map->second->getDocstring();
}
BOOST_CHECK(entity.test_one_arg_);
BOOST_CHECK(entity.test_two_args_);
BOOST_CHECK(entity.test_three_args_);
BOOST_CHECK(entity.test_four_args_);
std::vector<Value> values_two;
values_two.push_back(aValue);
/// Wrong number of arguments
bool res = false;
it_map = aCommandMap.find(std::string("2_args"));
try {
it_map->second->setParameterValues(values_two);
} catch (const dynamicgraph::ExceptionAbstract &aea) {
res = (aea.getCode() == dynamicgraph::ExceptionAbstract::ABSTRACT);
}
BOOST_CHECK(res);
double snd_arg_db = 10.0;
Value aValue2(snd_arg_db);
values_two.push_back(aValue2);
/// Wrong types of arguments
res = false;
it_map = aCommandMap.find(std::string("2_args"));
try {
it_map->second->setParameterValues(values_two);
} catch (const dynamicgraph::ExceptionAbstract &aea) {
res = (aea.getCode() == dynamicgraph::ExceptionAbstract::TOOLS);
}
BOOST_CHECK(res);
/// Try to find the command 1_arg
res = false;
entity.getNewStyleCommand(vec_fname[0]);
BOOST_CHECK(true);
/// Generate an exception by searching a command with an empty name.w
std::string empty("");
try {
entity.getNewStyleCommand(empty);
} catch (dynamicgraph::ExceptionFactory &aef) {
res = (aef.getCode() == dynamicgraph::ExceptionFactory::UNREFERED_FUNCTION);
}
BOOST_CHECK(res);
/// delete the entity.
delete ptr_entity;
}
......@@ -19,7 +19,7 @@ struct CustomEntity : public dynamicgraph::Entity {
virtual const std::string &getClassName() const { return CLASS_NAME; }
CustomEntity(const std::string n) : Entity(n) {}
explicit CustomEntity(const std::string &n) : Entity(n) {}
virtual ~CustomEntity() {}
......
......@@ -32,7 +32,7 @@ class CustomEntity : public Entity {
public:
static const std::string CLASS_NAME;
virtual const std::string &getClassName() const { return CLASS_NAME; }
CustomEntity(const std::string n) : Entity(n) {
explicit CustomEntity(const std::string &n) : Entity(n) {
logger_.setTimeSample(0.001);
logger_.setStreamPrintPeriod(0.005);
logger_.setVerbosity(VERBOSITY_ALL);
......@@ -62,10 +62,7 @@ DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity");
} // namespace dynamicgraph
BOOST_AUTO_TEST_CASE(debug_logger_wrong_initialization) {
std::ofstream of;
dynamicgraph::RealTimeLogger::instance();
// of.open("/tmp/dg-LOGS.txt",std::ofstream::out|std::ofstream::app);
// dgADD_OSTREAM_TO_RTLOG (of);
BOOST_CHECK_EQUAL(dynamicgraph::CustomEntity::CLASS_NAME, "CustomEntity");
......
......@@ -28,7 +28,7 @@ class CustomEntity : public Entity {
public:
static const std::string CLASS_NAME;
virtual const std::string &getClassName() const { return CLASS_NAME; }
CustomEntity(const std::string n) : Entity(n) {
explicit CustomEntity(const std::string &n) : Entity(n) {
logger_.setTimeSample(0.001);
logger_.setStreamPrintPeriod(0.005);
logger_.setVerbosity(VERBOSITY_ALL);
......@@ -59,6 +59,7 @@ public:
vq[1] = 2.0;
vq[2] = 3.0;
sendMsg("Value to display: " + toString(vq));
sendMsg("Value to display: " + toString(vq, 3, 10));
Eigen::Matrix<double, 3, 3> an_eig_m;
an_eig_m.Ones();
sendMsg("Value to display: " + toString(an_eig_m));
......
/* Copyright 2019, LAAS-CNRS
*
* Olivier Stasse
*
*/
#include <iostream>
#include <dynamic-graph/command.h>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/factory.h>
#include <dynamic-graph/pool.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/tracer-real-time.h>
#define BOOST_TEST_MODULE debug - tracer
#include <boost/test/output_test_stream.hpp>
#include <boost/test/unit_test.hpp>
using boost::test_tools::output_test_stream;
namespace dynamicgraph {
struct MyEntity : public dynamicgraph::Entity {
static const std::string CLASS_NAME;
dynamicgraph::Signal<double, int> m_sigdSIN;
dynamicgraph::SignalTimeDependent<double, int> m_sigdTimeDepSOUT;
dynamicgraph::SignalTimeDependent<double, int> m_sigdTwoTimeDepSOUT;
explicit MyEntity(const std::string &name)
: Entity(name),
m_sigdSIN("MyEntity(" + name + ")::input(double)::in_double"),
m_sigdTimeDepSOUT(boost::bind(&MyEntity::update, this, _1, _2),
m_sigdSIN,
"MyEntity(" + name + ")::input(double)::out_double"),
m_sigdTwoTimeDepSOUT(
boost::bind(&MyEntity::update, this, _1, _2), m_sigdSIN,
"MyEntity(" + name + ")::input(double)::out2double")
{
signalRegistration(m_sigdSIN << m_sigdTimeDepSOUT << m_sigdTwoTimeDepSOUT);
}
virtual void display(std::ostream &os) const {
os << "Hello! My name is " << getName() << " !" << std::endl;
}
virtual const std::string &getClassName() const { return CLASS_NAME; }
double &update(double &res, const int &inTime) {
const double &aDouble = m_sigdSIN(inTime);
res = aDouble;
return res;
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(MyEntity, "MyEntity");
} // namespace dynamicgraph
BOOST_AUTO_TEST_CASE(test_tracer) {
using namespace dynamicgraph;
// Creates a tracer.
TracerRealTime &atracer = *dynamic_cast<TracerRealTime *>(
FactoryStorage::getInstance()->newEntity("TracerRealTime", "my-tracer"));
Entity &entity =
*FactoryStorage::getInstance()->newEntity("MyEntity", "my-entity");
std::string rootdir("/tmp");
std::string basename("my-tracer");
std::string suffix(".dat");
/// Test openfiles
atracer.openFiles(rootdir, basename, suffix);
/// Add trace by name
atracer.addSignalToTraceByName("my-entity.out_double", "output");
/// Add trace by name
SignalBase<int> &aSignal = entity.getSignal("out2double");
Signal<double, int> &aSignalInt =
*(dynamic_cast<Signal<double, int> *>(&entity.getSignal("in_double")));
aSignalInt.setConstant(1.5);
atracer.start();
atracer.trace();
std::string emptybuf_cmd_str("empty");
command::Command *acmd = atracer.getNewStyleCommand(emptybuf_cmd_str);
acmd->execute();
for (int i = 0; i < 1000; i++) {
aSignal.setTime(i);
aSignalInt.setTime(i);
atracer.recordTrigger(i, i);
}
output_test_stream output;
atracer.display(output);
atracer.stop();
atracer.clearSignalToTrace();
atracer.closeFiles();
acmd->execute();
atracer.record();
BOOST_CHECK(output.is_equal(
"TracerRealTime my-tracer [mode=play] : \n"
" - Dep list: \n"
" -> MyEntity(my-entity)::input(double)::out_double (in output)"
" [0Mo/1Mo] \n"));
}
......@@ -28,7 +28,7 @@ class CustomEntity : public Entity {
public:
static const std::string CLASS_NAME;
virtual const std::string &getClassName() const { return CLASS_NAME; }
CustomEntity(const std::string n) : Entity(n) {
explicit CustomEntity(const std::string &n) : Entity(n) {
dynamicgraph::dgDEBUGFLOW.openFile("/tmp/dynamic-graph-traces.txt");
}
~CustomEntity() {
......@@ -53,10 +53,13 @@ DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity");
BOOST_AUTO_TEST_CASE(testDebugTrace) {
BOOST_CHECK_EQUAL(dynamicgraph::CustomEntity::CLASS_NAME, "CustomEntity");
dynamicgraph::CustomEntity &entity =
*(dynamic_cast<dynamicgraph::CustomEntity *>(
dynamicgraph::CustomEntity *ptr_entity =
(dynamic_cast<dynamicgraph::CustomEntity *>(
dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity",
"my-entity")));
dynamicgraph::CustomEntity &entity = *ptr_entity;
entity.testDebugTrace();
/// Copy the debug file into the oss_debug_file
......@@ -89,4 +92,6 @@ BOOST_AUTO_TEST_CASE(testDebugTrace) {
two_sub_string_identical = str_to_test == oss_debug_file.str();
BOOST_CHECK(two_sub_string_identical);
delete ptr_entity;
}
......@@ -27,7 +27,7 @@ struct MyEntity : public dynamicgraph::Entity {
dynamicgraph::SignalTimeDependent<double, int> m_sigdTimeDepSOUT;
dynamicgraph::SignalTimeDependent<double, int> m_sigdTwoTimeDepSOUT;
MyEntity(const std::string &name)
explicit MyEntity(const std::string &name)
: Entity(name),
m_sigdSIN("MyEntity(" + name + ")::input(double)::in_double"),
m_sigdTimeDepSOUT(boost::bind(&MyEntity::update, this, _1, _2),
......
......@@ -7,6 +7,8 @@
#include "dynamic-graph/factory.h"
#include "dynamic-graph/pool.h"
#include <dynamic-graph/command-direct-getter.h>
#include <dynamic-graph/command-direct-setter.h>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/real-time-logger.h>
......@@ -24,21 +26,33 @@ using boost::test_tools::output_test_stream;
namespace dynamicgraph {
class CustomEntity : public Entity {
public:
dynamicgraph::SignalPtr<double, int> m_sigdSIN;
dynamicgraph::SignalPtr<double, int> m_sigdSIN, m_sigdSIN2;
dynamicgraph::SignalTimeDependent<double, int> m_sigdTimeDepSOUT;
static const std::string CLASS_NAME;
virtual const std::string &getClassName() const { return CLASS_NAME; }
CustomEntity(const std::string n)
explicit CustomEntity(const std::string &n)
: Entity(n),
m_sigdSIN(NULL, "CustomEntity(" + name + ")::input(double)::in_double"),
m_sigdSIN2(NULL,
"CustomEntity(" + name + ")::input(double)::in_double"),
m_sigdTimeDepSOUT(
boost::bind(&CustomEntity::update, this, _1, _2), m_sigdSIN,
"CustomEntity(" + name + ")::input(double)::out_double")
{}
void addSignal() { signalRegistration(m_sigdSIN << m_sigdTimeDepSOUT); }
"CustomEntity(" + name + ")::input(double)::out_double"),
m_value(0.0) {}
~CustomEntity() { entityDeregistration(); }
void addSignal() {
signalRegistration(m_sigdSIN << m_sigdTimeDepSOUT);
/// Try a second time to generate an exception
try {
signalRegistration(m_sigdSIN2 << m_sigdTimeDepSOUT);
} catch (ExceptionFactory &aef) {
BOOST_CHECK_EQUAL(aef.getCode(),
dynamicgraph::ExceptionFactory::SIGNAL_CONFLICT);
}
}
void rmValidSignal() {
signalDeregistration("in_double");
......@@ -50,21 +64,47 @@ public:
res = aDouble;
return res;
}
public:
double m_value;
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity");
} // namespace dynamicgraph
BOOST_AUTO_TEST_CASE(constructor) {
BOOST_CHECK_EQUAL(dynamicgraph::CustomEntity::CLASS_NAME, "CustomEntity");
namespace dg = dynamicgraph;
namespace dgc = dynamicgraph::command;
dynamicgraph::Entity &entity =
*dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity",
"my-entity");
BOOST_CHECK_EQUAL(dg::CustomEntity::CLASS_NAME, "CustomEntity");
dg::Entity &entity = *dg::FactoryStorage::getInstance()->newEntity(
"CustomEntity", "my-entity");
BOOST_CHECK_EQUAL(entity.getName(), "my-entity");
BOOST_CHECK_EQUAL(entity.getClassName(),
dynamicgraph::CustomEntity::CLASS_NAME);
BOOST_CHECK_EQUAL(entity.getClassName(), dg::CustomEntity::CLASS_NAME);
dg::CustomEntity entity2("");
// Test Commands
dgc::DirectGetter<dg::CustomEntity, double> a_direct_getter(
entity2, &entity2.m_value,
dgc::docDirectGetter("Get value m_value", "double"));
dgc::DirectSetter<dg::CustomEntity, double> a_direct_setter(
entity2, &entity2.m_value,
dgc::docDirectSetter("Set value m_value", "double"));
dgc::Value aValue(2.0);
std::vector<dgc::Value> values;
values.push_back(aValue);
a_direct_setter.setParameterValues(values);
a_direct_setter.execute();
a_direct_getter.execute();
output_test_stream output;
output << entity2.m_value;
output << entity2;
dynamicgraph::CustomEntity entity2("");
entity.getDocString();
}
BOOST_AUTO_TEST_CASE(signal) {
......@@ -94,6 +134,12 @@ BOOST_AUTO_TEST_CASE(signal) {
dynamicgraph::CustomEntity *customEntity =
dynamic_cast<dynamicgraph::CustomEntity *>(&entity);
customEntity->addSignal();
std::string signame("CustomEntity(my-entity)::input(double)::in_double");
customEntity->Entity::hasSignal(signame);
output_test_stream output;
customEntity->Entity::displaySignalList(output);
dynamicgraph::Entity::SignalMap asigmap = customEntity->getSignalMap();
output << customEntity;
// Removing signals is working the first time
customEntity->rmValidSignal();
// Removing signals generates an exception the second time.
......
// Copyright 2020 Olivier Stasse
// LAAS, CNRS
#include <dynamic-graph/exception-abstract.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/exception-signal.h>
#include <dynamic-graph/exception-traces.h>
#include <sstream>
#include <boost/test/output_test_stream.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test_suite.hpp>
using boost::test_tools::output_test_stream;
using namespace dynamicgraph;
BOOST_AUTO_TEST_CASE(exception_abstract) {
std::string msg_aea("Test exception abstract");
ExceptionAbstract aEA(10, msg_aea);
const char *aC = aEA.getMessage();
output_test_stream output;
output << aC;
BOOST_CHECK(output.is_equal("Test exception abstract"));
output << aEA;
BOOST_CHECK(
output.is_equal("AbstractError [#10]: Test exception abstract\n"));
std::string msg_aet("Test exception abstract");
ExceptionTraces aET(ExceptionTraces::GENERIC, msg_aet);
output << aET;
}
......@@ -18,7 +18,7 @@ class CustomEntity : public Entity {
public:
static const std::string CLASS_NAME;
virtual const std::string &getClassName() const { return CLASS_NAME; }
CustomEntity(const std::string n) : Entity(n) {}
explicit CustomEntity(const std::string &n) : Entity(n) {}
};
const std::string CustomEntity::CLASS_NAME = "CustomEntity";
} // namespace dynamicgraph
......
......@@ -23,7 +23,7 @@ struct MyEntity : public dynamicgraph::Entity {
dynamicgraph::SignalPtr<double, int> m_sigdSIN;
dynamicgraph::SignalTimeDependent<double, int> m_sigdTimeDepSOUT;
MyEntity(const std::string &name)
explicit MyEntity(const std::string &name)
: Entity(name),
m_sigdSIN(NULL, "MyEntity(" + name + ")::input(double)::in_double"),
m_sigdTimeDepSOUT(boost::bind(&MyEntity::update, this, _1, _2),
......
......@@ -45,9 +45,97 @@ BOOST_AUTO_TEST_CASE(test_array) {
}
BOOST_AUTO_TEST_CASE(test_base) {
SignalBase<int> sigA("testA");
SignalBase<int> sigB("test");
sigB.setReady();
BOOST_CHECK_EQUAL(true, sigB.getReady());
// Does nothing, just check that the interface
// still exist at the abstract level.
sigB.setPeriodTime(1);
sigB.getPeriodTime();
sigB.addDependency(sigA);
sigB.removeDependency(sigA);
sigB.clearDependencies();
BOOST_CHECK_EQUAL(true, sigB.needUpdate(10));
output_test_stream output;
sigB.writeGraph(output);
BOOST_CHECK(output.is_equal(""));
/// Verify plug operations
bool res = false;
try {
sigB.plug(&sigA);
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::PLUG_IMPOSSIBLE);
}
BOOST_CHECK(res);
res = false;
try {
sigB.unplug();
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::PLUG_IMPOSSIBLE);
}
BOOST_CHECK(res);
res = false;
try {
sigB.setConstantDefault();
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::PLUG_IMPOSSIBLE);
}
BOOST_CHECK(res);
res = false;
try {
/// Check signal compatibility.
sigB.checkCompatibility();
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::PLUG_IMPOSSIBLE);
}
/// Verify set command value
/// set
std::istringstream iss("empty");
res = false;
try {
sigB.set(iss);
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::SET_IMPOSSIBLE);
}
BOOST_CHECK(res);
/// get a value
res = false;
std::ostringstream oss;
try {
sigB.get(oss);
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::SET_IMPOSSIBLE);
}
BOOST_CHECK(res);
/// Trigger revaluation of the signal
res = false;
try {
sigB.recompute(100);
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::SET_IMPOSSIBLE);
}
BOOST_CHECK(res);
/// Trace the signal
res = false;
try {
sigB.trace(oss);
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::SET_IMPOSSIBLE);
}
BOOST_CHECK(res);
/// Display the signal
sigB.display(output);
BOOST_CHECK(output.is_equal("Sig:test"));
}
BOOST_AUTO_TEST_CASE(test_cast_helper) {
......@@ -60,7 +148,7 @@ BOOST_AUTO_TEST_CASE(test_cast_helper) {
std::istringstream iss_fail;
iss.str("test");
defaultCR.cast(iss_fail);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
// Take int, not string
}
}
\ No newline at end of file
}
#pragma GCC diagnostic push
#pragma GCC system_header
#include <Eigen/Dense>
#pragma GCC diagnostic pop
......@@ -6,8 +6,7 @@
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <Eigen/Dense>
#include "signal-cast-register-test.h"
#include <dynamic-graph/debug.h>
#include <dynamic-graph/eigen-io.h>
#include <dynamic-graph/entity.h>
......@@ -172,7 +171,7 @@ BOOST_AUTO_TEST_CASE(custom_vector_registerer) {
try {
std::istringstream ss("test");
myVectorSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[0] != \"[\"";
}
......@@ -180,7 +179,7 @@ BOOST_AUTO_TEST_CASE(custom_vector_registerer) {
try {
std::istringstream ss("[test");
myVectorSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[1] != %i";
}
......@@ -188,7 +187,7 @@ BOOST_AUTO_TEST_CASE(custom_vector_registerer) {
try {
std::istringstream ss("[5[");
myVectorSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[2] != \"]\"";
}
......@@ -196,7 +195,7 @@ BOOST_AUTO_TEST_CASE(custom_vector_registerer) {
try {
std::istringstream ss("[5]test");
myVectorSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[3] != \"(\"";
}
......@@ -204,7 +203,7 @@ BOOST_AUTO_TEST_CASE(custom_vector_registerer) {
try {
std::istringstream ss("[5](1, ");
myVectorSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
BOOST_ERROR("Can't happened");
}
......@@ -212,7 +211,7 @@ BOOST_AUTO_TEST_CASE(custom_vector_registerer) {
try {
std::istringstream ss("[5](1,2,3,4,5]");
myVectorSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[-1] != \")\"";
}
}
......@@ -233,7 +232,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("test");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[0] != \"[\"";
}
......@@ -241,7 +240,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[test");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[1] != %i";
}
......@@ -249,7 +248,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5[");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[2] != \",\"";
}
......@@ -257,7 +256,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5,c");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[3] != %i";
}
......@@ -265,7 +264,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5,3[");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[4] != \"]\"";
}
......@@ -273,7 +272,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5,3]test");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[5] != \"(\"";
}
......@@ -281,7 +280,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5,3](test");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[6] != \"(\"";
}
......@@ -289,7 +288,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5,3]((1,");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
BOOST_ERROR("Can't happened");
}
......@@ -297,7 +296,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5,3]((1,2,3]");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << ("ss[6+n] != \")\"");
}
......@@ -305,7 +304,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5,1]((1)(2)(3[");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[5] != \")\"";
}
......@@ -313,7 +312,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[5,1]((1)(2)(3)[");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[5] != \")\"";
}
......@@ -321,7 +320,7 @@ BOOST_AUTO_TEST_CASE(custom_matrix_registerer) {
try {
std::istringstream ss("[3,1]((1)(2),(3)[");
myMatrixSignal.set(ss);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
std::cout << "Test passed : ss[5] != \")\" and ignore \",\"";
}
......
......@@ -3,12 +3,15 @@
#include <string>
#include <boost/foreach.hpp>
#include <dynamic-graph/debug.h>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/factory.h>
#include <dynamic-graph/pool.h>
#include <dynamic-graph/signal-base.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal.h>
#include <iostream>
......@@ -17,21 +20,128 @@
#include <boost/test/unit_test_suite.hpp>
#include <string>
using boost::test_tools::output_test_stream;
typedef dynamicgraph::SignalTimeDependent<double, int> sigDouble_t;
typedef dynamicgraph::SignalTimeDependent<std::string, int> sigString_t;
using namespace dynamicgraph;
using std::cout;
BOOST_AUTO_TEST_CASE(normal_test) {
Signal<double, int> sig("sig");
SignalPtr<double, int> sigPtrA(NULL, "sigPtrA"), sigPtrB(NULL, "sigPtrB");
template <class T> class DummyClass {
public:
std::string proname;
std::list<sigDouble_t *> inputsig;
std::list<sigString_t *> inputsigV;
explicit DummyClass(const std::string &n)
: proname(n), res(), call(), timedata() {}
T &fun(T &res, int t) {
++call;
timedata = t;
BOOST_FOREACH (sigDouble_t *ptr, inputsig)
ptr->access(timedata);
BOOST_FOREACH (sigString_t *ptr, inputsigV)
ptr->access(timedata);
res = (*this)();
return res;
}
void add(sigDouble_t &sig) { inputsig.push_back(&sig); }
void add(sigString_t &sig) { inputsigV.push_back(&sig); }
T operator()();
T res;
int call;
int timedata;
};
template <> double DummyClass<double>::operator()() {
res = call * timedata;
return res;
}
template <> std::string DummyClass<std::string>::operator()() {
std::ostringstream oss;
oss << call * timedata;
return oss.str();
}
template <class T> T DummyClass<T>::operator()() { return this->res; }
BOOST_AUTO_TEST_CASE(normal_cst_test) {
SignalPtr<double, int> sigNotPlug(NULL, "sigNotPlug");
SignalPtr<double, int> sigPtrAbstract(NULL, "sigPtrAbstract");
const SignalPtr<double, int> cstSigNotPlug(NULL, "sigNotPlug");
try {
sigNotPlug.getPtr();
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
cout << "Error catch" << std::endl;
}
// Test getPtr without plug
/// This create a ExceptionSignal::NOT_INITIALIZED
bool res = false;
try {
// Signal<double, int> * r =
sigNotPlug.getPtr();
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::NOT_INITIALIZED);
}
BOOST_CHECK(res);
/// Testing const getPtr() interface: no plug case
try {
cstSigNotPlug.getPtr();
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::NOT_INITIALIZED);
}
BOOST_CHECK(res);
/// Test needUpdate without plug
res = (sigNotPlug.needUpdate(5) == false);
BOOST_CHECK(res);
sigNotPlug.getTime();
output_test_stream output;
sigNotPlug.display(output);
cstSigNotPlug.display(output);
/// Testing getAbsatractPtr() interface: no plug
res = false;
try {
sigNotPlug.getAbstractPtr();
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::NOT_INITIALIZED);
}
BOOST_CHECK(res);
/// Testing const getAbstractPtr() interface: no plug case
try {
cstSigNotPlug.getAbstractPtr();
} catch (const ExceptionSignal &aea) {
res = (aea.getCode() == ExceptionSignal::NOT_INITIALIZED);
}
BOOST_CHECK(res);
try {
sigNotPlug.checkCompatibility();
} catch (...) {
}
BOOST_CHECK(res);
}
BOOST_AUTO_TEST_CASE(normal_test) {
Signal<double, int> sig("sig");
Signal<int, int> sigint("sig");
Signal<std::string, int> sigstr("sig_str");
SignalPtr<double, int> sigPtrA(NULL, "sigPtrA"), sigPtrB(NULL, "sigPtrB");
SignalPtr<double, int> sigPtrAbstract(NULL, "sigPtrAbstract");
DummyClass<double> pro3("pro3");
sig.setConstant(1.56);
sig.recompute(2);
std::string name = "sig";
......@@ -39,22 +149,72 @@ BOOST_AUTO_TEST_CASE(normal_test) {
std::string test = "test";
try {
sig.getClassName(test);
} catch (ExceptionSignal e) {
} catch (ExceptionSignal &e) {
e.getExceptionName();
}
BOOST_CHECK(true);
SignalBase<int> &sigRef = sig;
sigPtrA.setFunction(boost::bind(&DummyClass<double>::fun, &pro3, _1, _2));
/// Plugging signal.
SignalBase<int> &sigRef = sig, sigBase("sigBase");
SignalBase<int> &sigPtrARef = sigPtrA, &sigPtrBRef = sigPtrB,
&sigPtrAbstractRef = sigPtrAbstract;
sigPtrARef.plug(0);
sigPtrARef.plug(&sigRef);
sigPtrBRef.plug(&sigPtrARef);
/// Try to plug an incompatible signal.
/// leave
bool res = false;
try {
sigPtrARef.plug(&sigstr);
} catch (const ExceptionSignal &aes) {
res = (aes.getCode() == ExceptionSignal::PLUG_IMPOSSIBLE);
}
BOOST_CHECK(res);
// TODO here
/// Plug the signal.
sigPtrAbstractRef.plug(&sigRef);
sigPtrA.getPtr();
BOOST_CHECK(true);
try {
sigPtrARef.checkCompatibility();
} catch (const ExceptionSignal &aes) {
/// Should be NOT_INITIALIZED becase the last plug
/// on sigstr failed.
res = (aes.getCode() == ExceptionSignal::NOT_INITIALIZED);
} catch (const std::exception &e) {
std::cout << "Standard Exception:" << e.what() << std::endl;
} catch (...) {
std::cout << "Anything else: " << std::endl;
}
sigPtrA.needUpdate(5);
BOOST_CHECK(true);
int ltime = sigPtrA.getTime();
sigPtrA.getPluged();
sigPtrA(ltime);
BOOST_CHECK(true);
sigPtrB.getPtr();
sigPtrAbstract.getAbstractPtr();
/// Test sigPtrAbstract with a normal plug.
res = false;
try {
sigPtrAbstract.getAbstractPtr();
} catch (ExceptionSignal &aes) {
/// Should be NOT_INITIALIZED becase the last plug
/// on sigstr failed.
std::cout << "Code: " << aes.getCode() << std::endl;
res = (aes.getCode() == ExceptionSignal::NOT_INITIALIZED);
} catch (...) {
std::cout << "Anything else with sigPtrAbstract.getAbstractPtr()"
<< std::endl;
}
BOOST_CHECK(true);
/// Test the case where the plug ref is zero.
sigPtrAbstractRef.plug(0);
BOOST_CHECK(true);
assert(sigRef.isPlugged() != true);
SignalBase<int> *t = sigRef.getPluged();
......@@ -71,9 +231,17 @@ BOOST_AUTO_TEST_CASE(normal_test) {
tab_D[0] = 1.2;
tab_D[1] = 3.4;
sigPtrA.setReference(tab_D, NULL);
sigPtrA.access(5);
output_test_stream output;
sigPtrA.display(output);
sigPtrA.setReferenceNonConstant(tab_D, NULL);
sigPtrA.access(5);
sigPtrA.display(output);
// getreference
sigPtrA.operator=(1.2);
// getconstant
sigPtrA.displayDependencies(output);
cout << t << std::endl;
cout << "Sig = ";
......@@ -85,6 +253,8 @@ BOOST_AUTO_TEST_CASE(normal_test) {
cout << "SigPtrB = ";
sigPtrBRef.get(cout);
cout << std::endl;
sigPtrA.unplug();
}
BOOST_AUTO_TEST_CASE(plug_signal_string) {
......
// Copyright 2010 Thomas Moulard.
//
#include <boost/foreach.hpp>
#include <iostream>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal.h>
......@@ -22,7 +22,8 @@ public:
std::list<sigDouble_t *> inputsig;
std::list<sigString_t *> inputsigV;
DummyClass(const std::string &n) : proname(n), res(), call(), timedata() {}
explicit DummyClass(const std::string &n)
: proname(n), res(), call(), timedata() {}
T &fun(T &res, int t) {
++call;
......@@ -72,6 +73,7 @@ BOOST_AUTO_TEST_CASE(signaltimedependent) {
sigDouble_t sig3(sig2 << sig5 << sig6, "Sig3");
sigDouble_t sig1(boost::bind(&DummyClass<double>::fun, &pro1, _1, _2),
sig2 << sig3, "Sig1");
sigDouble_t sig7("Sig7");
sig2.setFunction(boost::bind(&DummyClass<std::string>::fun, &pro2, _1, _2));
sig3.setFunction(boost::bind(&DummyClass<double>::fun, &pro3, _1, _2));
......@@ -209,4 +211,22 @@ BOOST_AUTO_TEST_CASE(signaltimedependent) {
sig1.needUpdate(6);
sig1.needUpdate(6);
output_test_stream output;
sig1.writeGraph(output);
BOOST_CHECK(output.is_equal(""));
sig1.removeDependency(sig3);
BOOST_CHECK(true);
const double &avalue = sig1(6);
output << avalue;
BOOST_CHECK(true);
/// Verify check compatibility
try {
sig1.checkCompatibility();
}
// catch(double e)
catch (...) {
std::cout << "Message: test \n";
}
BOOST_CHECK(true);
}
......@@ -2,6 +2,7 @@
//
#include "dynamic-graph/value.h"
#include <dynamic-graph/exception-factory.h>
#include <iostream>
#define BOOST_TEST_MODULE value
......@@ -11,8 +12,258 @@
using boost::test_tools::output_test_stream;
namespace dg = dynamicgraph;
BOOST_AUTO_TEST_CASE(value_none) {
using dg::command::Value;
Value value1;
Value value(value1);
{
output_test_stream output;
output << value1;
BOOST_CHECK(output.is_equal("Type=unknown, value="));
}
}
BOOST_AUTO_TEST_CASE(value_bool) {
using dg::command::Value;
bool abool1(false);
Value value1(abool1);
Value value = value1;
{
output_test_stream output;
output << value1;
BOOST_CHECK(output.is_equal("Type=bool, value=0"));
}
{
output_test_stream output;
output << value;
BOOST_CHECK(output.is_equal("Type=bool, value=0"));
}
}
BOOST_AUTO_TEST_CASE(value_exceptions) {
using dg::command::Value;
Value value1;
dg::command::EitherType anet(value1);
output_test_stream output, output2;
// Check if the exception is working when calling intValue
// while we are having a none.
bool res = false;
try {
int aInt(anet);
output << aInt;
} catch (const dg::ExceptionAbstract &aea) {
output << aea.getExceptionName();
output2 << aea.what();
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS);
}
BOOST_CHECK(res);
BOOST_CHECK(output.is_equal("Abstract"));
BOOST_CHECK(output2.is_equal("value is not an int int"));
// Check if the exception is working when calling boolValue
// while we are having a none.
res = false;
try {
bool abool(anet);
output << abool;
} catch (const dg::ExceptionAbstract &aea) {
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS);
}
BOOST_CHECK(res);
// Check if the exception is working when calling unsignedintValue
// while we are having a none.
res = false;
try {
unsigned int aint(anet);
output << aint;
} catch (const dg::ExceptionAbstract &aea) {
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS);
}
BOOST_CHECK(res);
// Check if the exception is working when calling doubleValue
// while we are having a none.
res = false;
try {
double adouble(anet);
output << adouble;
} catch (const dg::ExceptionAbstract &aea) {
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS);
}