[neurun] Introduce SimpleMockNode for Graph test (#2536)
author이한종/동작제어Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Fri, 31 Aug 2018 06:51:43 +0000 (15:51 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 31 Aug 2018 06:51:43 +0000 (15:51 +0900)
Introduce SimpleMockNode as a header file so it can be reused from
many tests.

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/neurun/test/graph/operation/MockNode.h [new file with mode: 0644]
runtimes/neurun/test/graph/operation/Set.cc

diff --git a/runtimes/neurun/test/graph/operation/MockNode.h b/runtimes/neurun/test/graph/operation/MockNode.h
new file mode 100644 (file)
index 0000000..c05af8c
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __NEURUN_TEST_GRAPH_OPERATION_MOCK_NODE_H__
+#define __NEURUN_TEST_GRAPH_OPERATION_MOCK_NODE_H__
+
+#include "graph/operation/Node.h"
+#include "graph/operand/IndexSet.h"
+
+namespace neurun_test
+{
+namespace graph
+{
+namespace operation
+{
+
+class SimpleMockNode : public neurun::graph::operation::Node
+{
+public:
+  SimpleMockNode(const neurun::graph::operand::IndexSet &inputs,
+                 const neurun::graph::operand::IndexSet &outputs)
+  {
+    setInputs(inputs);
+    setOutputs(outputs);
+  }
+
+public:
+  virtual void accept(neurun::graph::operation::NodeVisitor &&) const override {}
+};
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun_test
+
+#endif // __NEURUN_TEST_GRAPH_OPERATION_MOCK_NODE_H__
index 9b67402..dbc2bda 100644 (file)
@@ -1,28 +1,17 @@
 #include <gtest/gtest.h>
 
+#include "MockNode.h"
 #include "graph/operation/Set.h"
 
 using neurun::graph::operation::Set;
 using neurun::graph::operation::Node;
 using neurun::graph::operation::Index;
 
-class TestNode : public Node
-{
-public:
-  TestNode(const Node::InitParam &)
-  {
-    setInputs({1, 2, 3, 4});
-    setOutputs({5, 6, 7});
-  }
-
-public:
-  virtual void accept(neurun::graph::operation::NodeVisitor &&) const override {}
-};
-
 TEST(graph_operation_Set, operation_test)
 {
   Set set;
-  set.append(std::unique_ptr<Node>(new TestNode(Node::InitParam{0, nullptr, 0, nullptr})));
+  set.append(std::unique_ptr<Node>(
+      new neurun_test::graph::operation::SimpleMockNode({1, 2, 3, 4}, {5, 6, 7})));
   Index idx{0u};
   ASSERT_EQ(set.at(idx).getInputs().size(), 4);
   ASSERT_EQ(set.at(idx).getOutputs().size(), 3);