PluginProxy class tests (#347)
authorIvan Vagin/AI Tools Lab /SRR/Engineer/삼성전자 <ivan.vagin@samsung.com>
Fri, 22 Jun 2018 11:47:08 +0000 (14:47 +0300)
committerSergey Vostokov/AI Tools Lab /SRR/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Fri, 22 Jun 2018 11:47:08 +0000 (14:47 +0300)
This commit introduced test for PluginProxy class

Signed-off-by: Ivan Vagin <ivan.vagin@samsung.com>
contrib/nnc/src/module/plugin/PluginProxy.test.cpp [new file with mode: 0644]

diff --git a/contrib/nnc/src/module/plugin/PluginProxy.test.cpp b/contrib/nnc/src/module/plugin/PluginProxy.test.cpp
new file mode 100644 (file)
index 0000000..9265243
--- /dev/null
@@ -0,0 +1,36 @@
+#include "module/plugin/PluginProxy.h"
+
+#include "gtest/gtest.h"
+
+#define STRING(s) _STRING(s)
+#define _STRING(s) #s
+
+using namespace nncc::contrib::module::plugin;
+
+void tryCreatePluginProxy(std::string path)
+{
+  try
+  {
+    std::shared_ptr<PluginProxy> pp = PluginProxy::create(path);
+    FAIL();
+  }
+  catch (nncc::foundation::Exception &e){}
+}
+
+TEST(CONTRIB_NNC, PluginProxy)
+{
+  // Create PluginProxy from path with '/' and without, to visit both execution pathes
+  tryCreatePluginProxy("/some/path/pluginName");
+  tryCreatePluginProxy("pluginName");
+
+  // Create PluginProxy with sample plugin
+  std::shared_ptr<PluginProxy> pp = PluginProxy::create(STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH));
+  ASSERT_EQ(pp->getPluginPath(), STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH));
+  ASSERT_EQ(pp->getPluginName(), "libsome_parser.so");
+  ASSERT_NE(&pp->getPluginInstance(), nullptr);
+
+  // Operator '<<'
+  std::ostringstream os;
+  os << *pp;
+  ASSERT_EQ(os.str(), STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH));
+}