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)
--- /dev/null
+#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<std::string> 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();
+}