diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt index 51df61e04df245c5ead844c3bdf3873c8335eb76..be31ec9523231c53a1442d6205a8e0fb63d9928e 100644 --- a/unitTesting/CMakeLists.txt +++ b/unitTesting/CMakeLists.txt @@ -2,36 +2,30 @@ # Copyright # -### test_shell -SET(EXECUTABLE_NAME test_shell) - -ADD_DEFINITIONS(-DDEBUG=2) - -ADD_EXECUTABLE(${EXECUTABLE_NAME} - test_shell.cpp) - -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR}/../include -) - -LINK_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/lib) - -TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} - ${PROJECT_NAME} - dl) - - -### test_factory -# test currently disabled -#SET(EXECUTABLE_NAME test_factory) - -#ADD_DEFINITIONS(-DDEBUG=2) - -#ADD_EXECUTABLE(${EXECUTABLE_NAME} -# test_factory.cpp) - -#INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -#link_directories(${LIBRARY_OUTPUT_PATH}) -#TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} -# ${PROJECT_NAME} -# dl) \ No newline at end of file +### tests +SET(tests + test_shell + test_pool + test_depend) + +FOREACH(test_name ${tests}) + SET(EXECUTABLE_NAME ${test_name}) + + ADD_DEFINITIONS(-DDEBUG=2) + + ADD_EXECUTABLE(${EXECUTABLE_NAME} + ${test_name}.cpp) + + INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR}/../include + ) + + LINK_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/lib) + + TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} + ${PROJECT_NAME} + dl) + + INSTALL(TARGETS ${test_name} + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}) +ENDFOREACH(test_name) \ No newline at end of file diff --git a/unitTesting/test_pool.cpp b/unitTesting/test_pool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1f77fb6670ae38cbeb2a79caf41e7b9960ac58d7 --- /dev/null +++ b/unitTesting/test_pool.cpp @@ -0,0 +1,75 @@ +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * Copyright Projet JRL-JAPAN, Tsukuba, 2007 + *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * + * File: test_entity.cc + * Project: dynamicGraph + * Author: François Bleibel + * + * Version control + * =============== + * + * $Id$ + * + * Description + * ============ + * + * + * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + +/* -------------------------------------------------------------------------- */ +/* --- INCLUDES ------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + + +#include <string> +#include <iostream> +#include <cstdlib> + +#include <dynamic-graph/factory.h> +#include <dynamic-graph/entity.h> +#include <dynamic-graph/debug.h> +#include <dynamic-graph/pool.h> + +#include <memory> + +using namespace std; +using namespace dynamicgraph; + +class MyEntity +: public Entity +{ + + public: + MyEntity(const std::string& name); + + + public: /* --- ENTITY INHERITANCE --- */ + static const std::string CLASS_NAME; + virtual void display( std::ostream& os ) const; + virtual const std::string& getClassName( void ) const { return CLASS_NAME; } + + + protected: +}; + +DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(MyEntity,"MyEntity"); + +MyEntity::MyEntity(const std::string& name) + : Entity(name){ + +} + +void MyEntity::display(std::ostream& os ) const { + os << "Hello! My name is " << getName() << " !" << endl; +} + +main() { + MyEntity myEntity("MyEntity"); + + cout << "-- Pool.list" << endl; + pool.commandLine("pool", "list", *auto_ptr<istringstream>(new istringstream("")), cout); + Entity& e = pool.getEntity("MyEntity"); + cout << "-- Display" << endl; + e.display(cout); +}