diff --git a/hurricane/CMakeLists.txt b/hurricane/CMakeLists.txt index 8194d111..41f6c0bf 100644 --- a/hurricane/CMakeLists.txt +++ b/hurricane/CMakeLists.txt @@ -29,6 +29,10 @@ FIND_PACKAGE(Doxygen) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(cmake_modules) +ADD_SUBDIRECTORY(tests) IF(DOXYGEN_FOUND) ADD_SUBDIRECTORY(doc) ENDIF(DOXYGEN_FOUND) + +ENABLE_TESTING() +ADD_TEST(HurricaneTest ${PROJECT_BINARY_DIR}/tests/htest) diff --git a/hurricane/src/hurricane/CMakeLists.txt b/hurricane/src/hurricane/CMakeLists.txt index 58cfb045..dfe72246 100644 --- a/hurricane/src/hurricane/CMakeLists.txt +++ b/hurricane/src/hurricane/CMakeLists.txt @@ -160,5 +160,6 @@ install ( TARGETS hurricane DESTINATION /lib) endif ( BUILD_STATIC ) - install ( FILES ${includes} DESTINATION /include/hurricane) - +install(FILES ${includes} DESTINATION /include/hurricane) + +add_subdirectory(tests) diff --git a/hurricane/tests/CMakeLists.txt b/hurricane/tests/CMakeLists.txt new file mode 100644 index 00000000..e082a0ee --- /dev/null +++ b/hurricane/tests/CMakeLists.txt @@ -0,0 +1,5 @@ +INCLUDE_DIRECTORIES(${HURRICANE_SOURCE_DIR}/src/hurricane) + +ADD_EXECUTABLE(htest HTest.cpp) + +TARGET_LINK_LIBRARIES(htest hurricane) diff --git a/hurricane/tests/HTest.cpp b/hurricane/tests/HTest.cpp new file mode 100644 index 00000000..7bfe3b0a --- /dev/null +++ b/hurricane/tests/HTest.cpp @@ -0,0 +1,40 @@ +#include +using namespace std; + +#include "hurricane/DataBase.h" +#include "hurricane/Library.h" +using namespace Hurricane; + +int main() { + DataBase* db = DataBase::create(); + cout << "Testing DataBase creation" << endl; + if (!db) { + cout << "Error in DataBase creation" << endl; + return 1; + } + + Library* rootLibrary = Library::create(db, Name("RootLibrary")); + if (!rootLibrary) { + cout << "Error in RootLibrary creation" << endl; + return 1; + } + + Library* workLibrary = Library::create(rootLibrary, Name("WorkLibrary")); + if (!workLibrary) { + cout << "Error in WorkLibrary creation" << endl; + return 1; + } + + workLibrary = rootLibrary->getLibrary(Name("WorkLibrary")); + if (!workLibrary) { + cout << "Error in Library->getLibrary(const Name& name)" << endl; + } + + workLibrary->destroy(); + workLibrary = rootLibrary->getLibrary(Name("WorkLibrary")); + if (workLibrary) { + cout << "Error in Library destruction" << endl; + } + + return 0; +}