Commit 0b05a14e authored by Nicolas Mansard's avatar Nicolas Mansard Committed by Nicolas Mansard
Browse files

Account for the Entity::getClassName becoming pure virtual.

parent 7a974b89
......@@ -29,7 +29,7 @@ struct CustomEntity : public dynamicgraph::Entity
{
static const std::string CLASS_NAME;
virtual const std::string& getClassName ()
virtual const std::string& getClassName () const
{
return CLASS_NAME;
}
......
......@@ -16,6 +16,7 @@
#include <sstream>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/factory.h>
#define BOOST_TEST_MODULE entity
......@@ -24,20 +25,39 @@
using boost::test_tools::output_test_stream;
namespace dynamicgraph
{
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)
{
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (CustomEntity,"CustomEntity");
}
BOOST_AUTO_TEST_CASE (constructor)
{
BOOST_CHECK_EQUAL (dynamicgraph::Entity::CLASS_NAME, "Entity");
BOOST_CHECK_EQUAL (dynamicgraph::CustomEntity::CLASS_NAME, "CustomEntity");
dynamicgraph::Entity entity ("my-entity");
BOOST_CHECK_EQUAL (entity.getName (), "my-entity");
BOOST_CHECK_EQUAL (entity.getClassName (), dynamicgraph::Entity::CLASS_NAME);
dynamicgraph::CustomEntity entity ("my-entity");
BOOST_CHECK_EQUAL (entity.getName (), "my-entity");
BOOST_CHECK_EQUAL (entity.getClassName (), dynamicgraph::Entity::CLASS_NAME);
dynamicgraph::Entity entity2 ("");
dynamicgraph::CustomEntity entity2 ("");
}
BOOST_AUTO_TEST_CASE (signal)
{
dynamicgraph::Entity entity ("");
dynamicgraph::CustomEntity entity ("");
// Non const getter.
try
......@@ -54,7 +74,7 @@ BOOST_AUTO_TEST_CASE (signal)
// Const getter.
try
{
const dynamicgraph::Entity& entityConst = entity;
const dynamicgraph::CustomEntity& entityConst = entity;
entityConst.getSignal ("I do not exist");
BOOST_ERROR ("Should never happen.");
}
......@@ -67,7 +87,7 @@ BOOST_AUTO_TEST_CASE (signal)
BOOST_AUTO_TEST_CASE (displaySignalList)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
......@@ -77,7 +97,7 @@ BOOST_AUTO_TEST_CASE (displaySignalList)
BOOST_AUTO_TEST_CASE (display)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
......@@ -87,13 +107,13 @@ BOOST_AUTO_TEST_CASE (display)
BOOST_AUTO_TEST_CASE (getCommandList)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
BOOST_CHECK_EQUAL (entity.getCommandList (), "print\nsignals\nsignalDep");
}
BOOST_AUTO_TEST_CASE (commandLine_help)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
......@@ -112,19 +132,19 @@ BOOST_AUTO_TEST_CASE (commandLine_help)
BOOST_AUTO_TEST_CASE (commandLine_print)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
std::istringstream args;
entity.commandLine("print", args, output);
BOOST_CHECK (output.is_equal ("Entity: my-entity\n"));
BOOST_CHECK (output.is_equal ("CustomEntity: my-entity\n"));
}
BOOST_AUTO_TEST_CASE (commandLine_signals)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
......@@ -137,7 +157,7 @@ BOOST_AUTO_TEST_CASE (commandLine_signals)
// FIXME: is it what we should expect?
BOOST_AUTO_TEST_CASE (commandLine_signalDep)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
......@@ -159,7 +179,7 @@ BOOST_AUTO_TEST_CASE (commandLine_signalDep)
BOOST_AUTO_TEST_CASE (commandLine_unknown)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
......@@ -181,7 +201,7 @@ BOOST_AUTO_TEST_CASE (commandLine_unknown)
BOOST_AUTO_TEST_CASE (writeGraph)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
entity.writeGraph (output);
......@@ -191,7 +211,7 @@ BOOST_AUTO_TEST_CASE (writeGraph)
BOOST_AUTO_TEST_CASE (writeCompletionList)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
output_test_stream output;
entity.writeGraph (output);
......@@ -202,7 +222,7 @@ BOOST_AUTO_TEST_CASE (writeCompletionList)
// WTF?
BOOST_AUTO_TEST_CASE (wtf)
{
dynamicgraph::Entity entity ("my-entity");
dynamicgraph::CustomEntity entity ("my-entity");
BOOST_CHECK_EQUAL (entity.test (),
static_cast<dynamicgraph::SignalBase<int>*> (0));
......
......@@ -26,9 +26,29 @@
using boost::test_tools::output_test_stream;
namespace dynamicgraph
{
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)
{
}
};
const std::string CustomEntity::CLASS_NAME = "CustomEntity";
}
dynamicgraph::Entity* makeEntity(const std::string& objectName)
{
return new dynamicgraph::Entity (objectName);
return new dynamicgraph::CustomEntity (objectName);
}
......
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