Commit d5039779 authored by Olivier Stasse's avatar Olivier Stasse
Browse files

[tests] Improve coverage of signal-cast-registered.

parent c24bc649
...@@ -42,12 +42,6 @@ struct MyEntity : public dynamicgraph::Entity { ...@@ -42,12 +42,6 @@ struct MyEntity : public dynamicgraph::Entity {
signalRegistration(m_sigdSIN << m_sigdTimeDepSOUT << m_sigdTwoTimeDepSOUT); 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) { double &update(double &res, const int &inTime) {
const double &aDouble = m_sigdSIN(inTime); const double &aDouble = m_sigdSIN(inTime);
res = aDouble; res = aDouble;
...@@ -64,8 +58,8 @@ BOOST_AUTO_TEST_CASE(test_tracer) { ...@@ -64,8 +58,8 @@ BOOST_AUTO_TEST_CASE(test_tracer) {
TracerRealTime &atracer = *dynamic_cast<TracerRealTime *>( TracerRealTime &atracer = *dynamic_cast<TracerRealTime *>(
FactoryStorage::getInstance()->newEntity("TracerRealTime", "my-tracer")); FactoryStorage::getInstance()->newEntity("TracerRealTime", "my-tracer"));
Entity &entity = MyEntity &entity = *dynamic_cast<MyEntity *>(
*FactoryStorage::getInstance()->newEntity("MyEntity", "my-entity"); FactoryStorage::getInstance()->newEntity("MyEntity", "my-entity"));
std::string rootdir("/tmp"); std::string rootdir("/tmp");
std::string basename("my-tracer"); std::string basename("my-tracer");
...@@ -80,6 +74,8 @@ BOOST_AUTO_TEST_CASE(test_tracer) { ...@@ -80,6 +74,8 @@ BOOST_AUTO_TEST_CASE(test_tracer) {
/// Add trace by name /// Add trace by name
SignalBase<int> &aSignal = entity.getSignal("out2double"); SignalBase<int> &aSignal = entity.getSignal("out2double");
entity.m_sigdTwoTimeDepSOUT.recompute(2);
Signal<double, int> &aSignalInt = Signal<double, int> &aSignalInt =
*(dynamic_cast<Signal<double, int> *>(&entity.getSignal("in_double"))); *(dynamic_cast<Signal<double, int> *>(&entity.getSignal("in_double")));
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <assert.h> #include <assert.h>
#include <boost/test/output_test_stream.hpp> #include <boost/test/output_test_stream.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <iostream>
#define BOOST_TEST_MODULE signal_array #define BOOST_TEST_MODULE signal_array
...@@ -196,3 +197,20 @@ BOOST_AUTO_TEST_CASE(test_cast_helper) { ...@@ -196,3 +197,20 @@ BOOST_AUTO_TEST_CASE(test_cast_helper) {
DefaultCastRegisterer<std::string> defaultSR; DefaultCastRegisterer<std::string> defaultSR;
boost::any aTest = defaultSR.cast(aiss); boost::any aTest = defaultSR.cast(aiss);
} }
BOOST_AUTO_TEST_CASE(signal_caster_basics) {
/// Get the singleton on registered types.
SignalCaster *asig_caster = SignalCaster::getInstance();
/// List the registered types.
std::vector<std::string> amap = asig_caster->listTypenames();
for (std::vector<std::string>::iterator it = amap.begin(); it != amap.end();
++it)
std::cout << "signal_caster:listTypename: " << *it << std::endl;
/// Unregister a type
asig_caster->unregisterCast(typeid(double));
asig_caster->destroy();
BOOST_CHECK(true);
}
...@@ -139,6 +139,15 @@ BOOST_AUTO_TEST_CASE(standard_double_registerer) { ...@@ -139,6 +139,15 @@ BOOST_AUTO_TEST_CASE(standard_double_registerer) {
BOOST_AUTO_TEST_CASE(custom_vector_registerer) { BOOST_AUTO_TEST_CASE(custom_vector_registerer) {
dynamicgraph::Signal<dynamicgraph::Vector, int> myVectorSignal("vector"); dynamicgraph::Signal<dynamicgraph::Vector, int> myVectorSignal("vector");
/// Create a second local vector registerer to generate an exception.
bool res = false;
try {
EigenCastRegisterer_V myVectorCast2;
} catch (const ExceptionSignal &aes) {
res = (aes.getCode() == ExceptionSignal::GENERIC);
}
// BOOST_CHECK(res);
// Print the signal name. // Print the signal name.
{ {
output_test_stream output; output_test_stream output;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment