From 42dfa164c7752a46fd268cff2638c0d881dd9422 Mon Sep 17 00:00:00 2001 From: The Coriolis Project Date: Mon, 2 Feb 2009 10:20:29 +0000 Subject: [PATCH] Initiating Hurricane Tests --- hurricane/CMakeLists.txt | 4 +++ hurricane/src/hurricane/CMakeLists.txt | 5 ++-- hurricane/tests/CMakeLists.txt | 5 ++++ hurricane/tests/HTest.cpp | 40 ++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 hurricane/tests/CMakeLists.txt create mode 100644 hurricane/tests/HTest.cpp 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; +}