[coco] Use ObjectManager inside Op tests (#825)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 26 Jul 2018 02:18:03 +0000 (11:18 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 26 Jul 2018 02:18:03 +0000 (11:18 +0900)
This commit revises IR_OP_CONV2D.ker_update to use ObjectManager when it
creates a KernelObject instance for testing.

This change allows us to reduce the degree of coupling between 'KernelObject'
class design and IR_OP_CONV2D.ker_update test implementation.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/src/IR/Op.test.cpp

index 7b26535..ab68ef8 100644 (file)
@@ -1,4 +1,5 @@
 #include "coco/IR/Op.h"
+#include "coco/IR/ObjectManager.h"
 
 #include <gtest/gtest.h>
 
@@ -24,11 +25,16 @@ TEST(IR_OP_CONV2D, asConv2D)
 
 TEST(IR_OP_CONV2D, ker_update)
 {
+  // Prepare a kernel object for testing
+  coco::PtrLink<coco::Bag, coco::BagInfo> bag_link;
+  coco::ObjectManager obj_mgr{&bag_link};
+
+  auto obj = obj_mgr.create(nncc::core::ADT::kernel::Shape{1, 1, 3, 3});
+
+  // Test 'Conv2D' class
   const coco::Conv2D::Param param{};
   coco::Conv2D op{param};
 
-  coco::KernelObject obj{nncc::core::ADT::kernel::Shape{1, 1, 3, 3}};
-
-  op.ker(&obj);
-  ASSERT_EQ(op.ker(), &obj);
+  op.ker(obj);
+  ASSERT_EQ(op.ker(), obj);
 }