From 2892dc419f7a97cbbb7ea8c7a5c9ed90fa8fff7e Mon Sep 17 00:00:00 2001 From: Francois Bleibel <fbleibel@gmail.com> Date: Fri, 11 Jun 2010 18:24:02 +0900 Subject: [PATCH] Added a new test (test_pool). --- unitTesting/CMakeLists.txt | 60 ++++++++++++++---------------- unitTesting/test_pool.cpp | 75 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 33 deletions(-) create mode 100644 unitTesting/test_pool.cpp diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt index 51df61e0..be31ec95 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 00000000..1f77fb66 --- /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); +} -- GitLab