From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Fri, 3 Aug 2018 02:02:03 +0000 (+0900) Subject: [coco] Use 'BagManager' in Input/Output tests (#886) X-Git-Tag: nncc_backup~2262 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4021d681592d65baf99c7172ae4486eb9859182;p=platform%2Fcore%2Fml%2Fnnfw.git [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 --- 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)