[coco] Use 'BagManager' in Input/Output tests (#886)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 3 Aug 2018 02:02:03 +0000 (11:02 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 3 Aug 2018 02:02:03 +0000 (11:02 +0900)
The current implementation of Input/Output tests explicitly invokes the
constructor of 'Bag'. As a result, these implementations are fragile over
Bag class design changes.

This commit revises these tests to use 'BagManager' to reduce the dependency
on the implementation details of Bag class.

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

index 705aa18..1c31a93 100644 (file)
@@ -1,4 +1,5 @@
 #include "coco/IR/Input.h"
+#include "coco/IR/BagManager.h"
 
 #include <nncc/core/ADT/tensor/IndexEnumerator.h>
 
@@ -19,12 +20,17 @@ TEST(IR_INPUT, ctor_should_set_shape)
 
 TEST(IR_INPUT, bag_update)
 {
+  // Create a bag
+  coco::PtrLink<coco::Bag, coco::BagInfo> bag_link;
+  coco::BagManager bag_mgr{&bag_link};
+
+  auto bag = bag_mgr.create(9);
+
   const nncc::core::ADT::tensor::Shape shape{1, 3, 3, 1};
   coco::Input input{shape};
-  coco::Bag bag{9};
 
-  input.bag(&bag);
-  ASSERT_EQ(input.bag(), &bag);
+  input.bag(bag);
+  ASSERT_EQ(input.bag(), bag);
 }
 
 TEST(IR_INPUT, name_update)
index f1874e8..fb5eac2 100644 (file)
@@ -1,4 +1,5 @@
 #include "coco/IR/Output.h"
+#include "coco/IR/BagManager.h"
 
 #include <nncc/core/ADT/tensor/IndexEnumerator.h>
 
@@ -18,12 +19,17 @@ TEST(IR_OUTPUT, ctor_should_set_shape)
 
 TEST(IR_OUTPUT, bag_update)
 {
+  // Create a bag for test
+  coco::PtrLink<coco::Bag, coco::BagInfo> bag_link;
+  coco::BagManager bag_mgr{&bag_link};
+
+  auto bag = bag_mgr.create(9);
+
   const nncc::core::ADT::tensor::Shape shape{1, 3, 3, 1};
   coco::Output output{shape};
-  coco::Bag bag{1};
 
-  output.bag(&bag);
-  ASSERT_EQ(output.bag(), &bag);
+  output.bag(bag);
+  ASSERT_EQ(output.bag(), bag);
 }
 
 TEST(IR_OUTPUT, name_update)