Skip to content
Snippets Groups Projects
Commit a955e307 authored by Olivier Stasse's avatar Olivier Stasse Committed by olivier stasse
Browse files

[tests] Improve coverage of entity.

parent ed29cdae
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ using boost::test_tools::output_test_stream; ...@@ -26,7 +26,7 @@ using boost::test_tools::output_test_stream;
namespace dynamicgraph { namespace dynamicgraph {
class CustomEntity : public Entity { class CustomEntity : public Entity {
public: public:
dynamicgraph::SignalPtr<double, int> m_sigdSIN; dynamicgraph::SignalPtr<double, int> m_sigdSIN, m_sigdSIN2;
dynamicgraph::SignalTimeDependent<double, int> m_sigdTimeDepSOUT; dynamicgraph::SignalTimeDependent<double, int> m_sigdTimeDepSOUT;
static const std::string CLASS_NAME; static const std::string CLASS_NAME;
...@@ -34,13 +34,24 @@ public: ...@@ -34,13 +34,24 @@ public:
CustomEntity(const std::string n) CustomEntity(const std::string n)
: Entity(n), : Entity(n),
m_sigdSIN(NULL, "CustomEntity(" + name + ")::input(double)::in_double"), m_sigdSIN(NULL, "CustomEntity(" + name + ")::input(double)::in_double"),
m_sigdSIN2(NULL,
"CustomEntity(" + name + ")::input(double)::in_double"),
m_sigdTimeDepSOUT( m_sigdTimeDepSOUT(
boost::bind(&CustomEntity::update, this, _1, _2), m_sigdSIN, boost::bind(&CustomEntity::update, this, _1, _2), m_sigdSIN,
"CustomEntity(" + name + ")::input(double)::out_double") "CustomEntity(" + name + ")::input(double)::out_double") {}
{} ~CustomEntity() { entityDeregistration(); }
void addSignal() { signalRegistration(m_sigdSIN << m_sigdTimeDepSOUT); } 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() { void rmValidSignal() {
signalDeregistration("in_double"); signalDeregistration("in_double");
...@@ -90,6 +101,9 @@ BOOST_AUTO_TEST_CASE(constructor) { ...@@ -90,6 +101,9 @@ BOOST_AUTO_TEST_CASE(constructor) {
output_test_stream output; output_test_stream output;
output << entity2.m_value; output << entity2.m_value;
output << entity2;
entity.getDocString();
} }
BOOST_AUTO_TEST_CASE(signal) { BOOST_AUTO_TEST_CASE(signal) {
...@@ -119,6 +133,12 @@ BOOST_AUTO_TEST_CASE(signal) { ...@@ -119,6 +133,12 @@ BOOST_AUTO_TEST_CASE(signal) {
dynamicgraph::CustomEntity *customEntity = dynamicgraph::CustomEntity *customEntity =
dynamic_cast<dynamicgraph::CustomEntity *>(&entity); dynamic_cast<dynamicgraph::CustomEntity *>(&entity);
customEntity->addSignal(); 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 // Removing signals is working the first time
customEntity->rmValidSignal(); customEntity->rmValidSignal();
// Removing signals generates an exception the second time. // Removing signals generates an exception the second time.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment