diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt index bf1bd7d28b8b77f64b3e3608682ac149a180afe4..08a0226636e8c6532c9e0bb032f64b147fb8864e 100644 --- a/unitTesting/CMakeLists.txt +++ b/unitTesting/CMakeLists.txt @@ -3,27 +3,49 @@ # ### tests -SET(tests +SET(tests_exe test_pool test_depend test_signalcast) -FOREACH(test_name ${tests}) - SET(EXECUTABLE_NAME ${test_name}) +SET(tests_libs + test_signalcast_libA + test_signalcast_libB +) - ADD_DEFINITIONS(-DDEBUG=2) +SET(test_signalcast_additional_libs ${test_libs}) - ADD_EXECUTABLE(${EXECUTABLE_NAME} - ${test_name}.cpp) +ADD_DEFINITIONS(-DDEBUG=2) + +INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR}/../include +) + +LINK_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/lib) - INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ) +# Additional tests +FOREACH(test_name ${tests_libs}) + SET(LIBRARY_NAME ${test_name}) - LINK_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/lib) + ADD_LIBRARY(${LIBRARY_NAME} + SHARED + ${test_name}.cpp) + TARGET_LINK_LIBRARIES(${LIBRARY_NAME} + ${PROJECT_NAME}) +ENDFOREACH(test_name) + +FOREACH(test_name ${tests_exe}) + SET(EXECUTABLE_NAME ${test_name}) + + ADD_EXECUTABLE(${EXECUTABLE_NAME} + ${test_name}.cpp) + TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${PROJECT_NAME}) + TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} + ${${test_name}_additional_libs}) + ADD_TEST(NAME ${test_name} COMMAND ${test_name}) ENDFOREACH(test_name) \ No newline at end of file diff --git a/unitTesting/test_signalcast.cpp b/unitTesting/test_signalcast.cpp index 253e62ee14f43cf4f2f98668e89c729d96235685..1cb72b2071504ede81cec286e0fc62090aed861e 100644 --- a/unitTesting/test_signalcast.cpp +++ b/unitTesting/test_signalcast.cpp @@ -35,6 +35,10 @@ // only included because we will define new casts here. Not needed in general. #include <dynamic-graph/signal-caster.h> +#include "test_signalcast_libA.h" +#include "test_signalcast_libB.h" + + using namespace std; using namespace dynamicgraph; @@ -108,6 +112,23 @@ int main() { cout << endl; } + // check the following: "typeid of vA is different from typeid of vB + // in different shared libraries"" + cout << "-- check typeid equality in shared libs" << endl; + if(typeid(vA) == typeid(vB)) { + cout << "The types of vA (libA.so) and vB (libB.so) are equal" << endl; + } else { + cout << "The types of vA (libA.so) and vB (libB.so) are different" << endl; + } + + cout << "-- check type *name* equality in shared libs with type:" << endl + << " " << typeid(vA).name() << endl; + if( !strcmp(typeid(vA).name(), typeid(vB).name()) ) { + cout << "The type names of vA (libA.so) and vB (libB.so) are equal" << endl; + } else { + cout << "The type names of vA (libA.so) and vB (libB.so) are different" << endl; + } + return 0; } diff --git a/unitTesting/test_signalcast_libA.cpp b/unitTesting/test_signalcast_libA.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8d07eed064903ee53a1e22b6c475274243dc3e6d --- /dev/null +++ b/unitTesting/test_signalcast_libA.cpp @@ -0,0 +1,18 @@ + +#include <string> +#include <iostream> +#include <cstdlib> +#include <memory> + +#include <dynamic-graph/factory.h> +#include <dynamic-graph/entity.h> +#include <dynamic-graph/debug.h> +#include <dynamic-graph/pool.h> +#include <dynamic-graph/signal.h> +#include <dynamic-graph/signal-caster.h> +#include "test_signalcast_libA.h" + +using namespace dynamicgraph; +using namespace std; + +vec_type vA; diff --git a/unitTesting/test_signalcast_libA.h b/unitTesting/test_signalcast_libA.h new file mode 100644 index 0000000000000000000000000000000000000000..66e0283248ce98137800970f83038c8e72b8e749 --- /dev/null +++ b/unitTesting/test_signalcast_libA.h @@ -0,0 +1,5 @@ +#include <boost/numeric/ublas/vector.hpp> +#include <boost/numeric/ublas/io.hpp> + +typedef boost::numeric::ublas::vector<double> vec_type; +extern vec_type vA; diff --git a/unitTesting/test_signalcast_libB.cpp b/unitTesting/test_signalcast_libB.cpp new file mode 100644 index 0000000000000000000000000000000000000000..58040651428d5a0eb95701c2eee8dcae797cd553 --- /dev/null +++ b/unitTesting/test_signalcast_libB.cpp @@ -0,0 +1,16 @@ + +#include <string> +#include <iostream> + +#include <dynamic-graph/factory.h> +#include <dynamic-graph/entity.h> +#include <dynamic-graph/debug.h> +#include <dynamic-graph/pool.h> +#include <dynamic-graph/signal.h> +#include <dynamic-graph/signal-caster.h> + +#include "test_signalcast_libB.h" +using namespace dynamicgraph; +using namespace std; + +vec_type vB; diff --git a/unitTesting/test_signalcast_libB.h b/unitTesting/test_signalcast_libB.h new file mode 100644 index 0000000000000000000000000000000000000000..f80abccd93233381226bf4af500bac8a2ab41201 --- /dev/null +++ b/unitTesting/test_signalcast_libB.h @@ -0,0 +1,5 @@ +#include <boost/numeric/ublas/vector.hpp> +#include <boost/numeric/ublas/io.hpp> + +typedef boost::numeric::ublas::vector<double> vec_type; +extern vec_type vB;