From: 이한종/동작제어Lab(SR)/Engineer/삼성전자 Date: Fri, 31 Aug 2018 06:51:43 +0000 (+0900) Subject: [neurun] Introduce SimpleMockNode for Graph test (#2536) X-Git-Tag: 0.2~126 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9cfde41a9705d1b9150e1a29d6b6847b74497247;p=platform%2Fcore%2Fml%2Fnnfw.git [neurun] Introduce SimpleMockNode for Graph test (#2536) Introduce SimpleMockNode as a header file so it can be reused from many tests. Signed-off-by: Hanjoung Lee --- diff --git a/runtimes/neurun/test/graph/operation/MockNode.h b/runtimes/neurun/test/graph/operation/MockNode.h new file mode 100644 index 0000000..c05af8c --- /dev/null +++ b/runtimes/neurun/test/graph/operation/MockNode.h @@ -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__ diff --git a/runtimes/neurun/test/graph/operation/Set.cc b/runtimes/neurun/test/graph/operation/Set.cc index 9b67402..dbc2bda 100644 --- a/runtimes/neurun/test/graph/operation/Set.cc +++ b/runtimes/neurun/test/graph/operation/Set.cc @@ -1,28 +1,17 @@ #include +#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(new TestNode(Node::InitParam{0, nullptr, 0, nullptr}))); + set.append(std::unique_ptr( + 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);