1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
5 #include <gtest/gtest.h>
6 #include <gmock/gmock-matchers.h>
8 #include <shape_infer/mock_ishape_infer_impl.hpp>
9 #include <shape_infer/ie_reshape_io_controllers.hpp>
11 using namespace InferenceEngine;
12 using namespace InferenceEngine::details;
13 using namespace ShapeInfer;
14 using namespace ::testing;
16 class InputControllerTest : public ::testing::Test {
18 static const std::string TEST_NAME;
19 DataPtr notEmptyData = std::make_shared<Data>(TEST_NAME, Precision::UNSPECIFIED, Layout::C);
23 const std::string InputControllerTest::TEST_NAME = "TEST_NAME";
25 TEST_F(InputControllerTest, failedToCreateWithEmptyInsData) {
26 EXPECT_THROW(InputController({}, TEST_NAME), InferenceEngineException);
29 TEST_F(InputControllerTest, failedToCreateWithNullData) {
30 EXPECT_THROW(InputController({nullptr}, TEST_NAME), InferenceEngineException);
33 TEST_F(InputControllerTest, canCreateInputController) {
34 ASSERT_NO_THROW(InputController({notEmptyData}, TEST_NAME));
37 TEST_F(InputControllerTest, canPushShapes) {
38 InputController controller({notEmptyData}, TEST_NAME);
39 ASSERT_NO_THROW(controller.setShapeByName(inDims, TEST_NAME));
42 TEST_F(InputControllerTest, DISABLED_throwOnGetWithNotEnoughShapes) {
43 InputController controller({notEmptyData, notEmptyData}, TEST_NAME);
44 controller.setShapeByName(inDims, TEST_NAME);
45 ASSERT_THROW(controller.getShapes(true), InferenceEngineException);
48 TEST_F(InputControllerTest, canGetWithNotEnoughShapes) {
49 InputController controller({notEmptyData, notEmptyData}, TEST_NAME);
50 controller.setShapeByName(inDims, TEST_NAME);
51 controller.getShapes(false);
54 TEST_F(InputControllerTest, canGetChanges) {
55 InputController controller({notEmptyData}, TEST_NAME);
56 controller.setShapeByName(inDims, TEST_NAME);
57 ASSERT_NO_THROW(controller.getShapes(true));
60 TEST_F(InputControllerTest, DISABLED_throwOnApplyWithNotEnoughShapes) {
61 InputController controller({notEmptyData, notEmptyData}, TEST_NAME);
62 controller.setShapeByName(inDims, TEST_NAME);
63 ASSERT_THROW(controller.applyChanges(), InferenceEngineException);
66 TEST_F(InputControllerTest, canApplyChanges) {
67 InputController controller({notEmptyData}, TEST_NAME);
68 controller.setShapeByName(inDims, TEST_NAME);
69 ASSERT_NO_THROW(controller.applyChanges());
72 TEST_F(InputControllerTest, canResetShapes) {
73 InputController controller({notEmptyData}, TEST_NAME);
74 controller.setShapeByName(inDims, TEST_NAME);
75 ASSERT_EQ(controller.getShapes(true)[0], inDims);
76 ASSERT_NO_THROW(controller.reset());
77 ASSERT_NE(controller.getShapes(true)[0], inDims);