From e4021d681592d65baf99c7172ae4486eb9859182 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 3 Aug 2018 11:02:03 +0900 Subject: [PATCH] [coco] Use 'BagManager' in Input/Output tests (#886) 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 --- contrib/coco/core/src/IR/Input.test.cpp | 12 +++++++++--- contrib/coco/core/src/IR/Output.test.cpp | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/contrib/coco/core/src/IR/Input.test.cpp b/contrib/coco/core/src/IR/Input.test.cpp index 705aa18..1c31a93 100644 --- a/contrib/coco/core/src/IR/Input.test.cpp +++ b/contrib/coco/core/src/IR/Input.test.cpp @@ -1,4 +1,5 @@ #include "coco/IR/Input.h" +#include "coco/IR/BagManager.h" #include @@ -19,12 +20,17 @@ TEST(IR_INPUT, ctor_should_set_shape) TEST(IR_INPUT, bag_update) { + // Create a bag + coco::PtrLink 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) diff --git a/contrib/coco/core/src/IR/Output.test.cpp b/contrib/coco/core/src/IR/Output.test.cpp index f1874e8..fb5eac2 100644 --- a/contrib/coco/core/src/IR/Output.test.cpp +++ b/contrib/coco/core/src/IR/Output.test.cpp @@ -1,4 +1,5 @@ #include "coco/IR/Output.h" +#include "coco/IR/BagManager.h" #include @@ -18,12 +19,17 @@ TEST(IR_OUTPUT, ctor_should_set_shape) TEST(IR_OUTPUT, bag_update) { + // Create a bag for test + coco::PtrLink 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) -- 2.7.4