From: Ivan Vagin/AI Tools Lab /SRR/Engineer/삼성전자 Date: Mon, 18 Jun 2018 15:39:40 +0000 (+0300) Subject: PluginManager tests part 1.1 (#341) X-Git-Tag: nncc_backup~2596 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=666105d5c659d036a8895dc3252a41fc191c27f2;p=platform%2Fcore%2Fml%2Fnnfw.git PluginManager tests part 1.1 (#341) DataException tests This commit introduced test for DataException class and appropriate CMakeLists Signed-off-by: Ivan Vagin --- diff --git a/contrib/nnc/CMakeLists.txt b/contrib/nnc/CMakeLists.txt index b1e1dcc..b6d9693 100644 --- a/contrib/nnc/CMakeLists.txt +++ b/contrib/nnc/CMakeLists.txt @@ -1,13 +1,26 @@ project(nnc) -file(GLOB_RECURSE CL_SRC src/*.cpp include/*.h) +file(GLOB_RECURSE HEADERS "include/*.h") +file(GLOB_RECURSE SOURCES "src/*.cpp") +file(GLOB_RECURSE TESTS "src/*.test.cpp") +file(GLOB_RECURSE MAIN "src/main.cpp") +list(REMOVE_ITEM SOURCES ${MAIN}) +list(REMOVE_ITEM SOURCES ${TESTS}) -add_executable(nnc ${CL_SRC}) -target_link_libraries(nnc PRIVATE nncc_core) -target_link_libraries(nnc PRIVATE nncc_foundation) -target_link_libraries(nnc PRIVATE nnc_plugin_core) -target_link_libraries(nnc PRIVATE dl) +# Plugin module library +add_nncc_library(nnc_module SHARED ${HEADERS} ${SOURCES}) +target_link_libraries(nnc_module PRIVATE nncc_core nncc_foundation nnc_plugin_core dl) +target_include_directories(nnc_module PUBLIC include) + +# nnc executable +add_executable(nnc ${MAIN}) +target_link_libraries(nnc PRIVATE nnc_module nncc_core nncc_foundation nnc_plugin_core dl) target_include_directories(nnc PUBLIC include) +# Plugin module tests +add_nncc_test(nnc_module_test ${TESTS} ${HEADERS}) +nncc_target_link_libraries(nnc_module_test nnc_module nncc_core nncc_foundation nnc_plugin_core) +target_include_directories(nnc_module_test PUBLIC include) + add_subdirectory(libs) add_subdirectory(examples) diff --git a/contrib/nnc/src/module/plugin/PluginData.test.cpp b/contrib/nnc/src/module/plugin/PluginData.test.cpp new file mode 100644 index 0000000..c0d6afa --- /dev/null +++ b/contrib/nnc/src/module/plugin/PluginData.test.cpp @@ -0,0 +1,42 @@ +#include "module/plugin/PluginData.h" + +#include "gtest/gtest.h" + +using namespace nncc::contrib::config; + +// DataException class + +std::string errorMsg1 = "error constructor"; +std::string errorMsg2 = "error second constructor"; + +std::vector msgs = {errorMsg1, errorMsg2}; + +void err1() { throw DataException(errorMsg1); } + +void err2() +{ + try + { + err1(); + } + catch (DataException &e) + { + throw DataException(e, errorMsg2); + } +} + +TEST(CONTRIB_NNC, DataException) +{ + try + { + err2(); + } + catch (DataException &e) + { + ASSERT_TRUE(msgs == e.getInfo()); + return; + } + + // should not happen + FAIL(); +}