Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / unit / inference_engine_tests / preprocess_test.cpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #include <gtest/gtest.h>
6 #include <ie_preprocess.hpp>
7
8 using namespace std;
9
10 class PreProcessTests : public ::testing::Test {
11 protected:
12     virtual void TearDown() {
13     }
14
15     virtual void SetUp() {
16     }
17
18 public:
19
20 };
21
22 TEST_F(PreProcessTests, throwsOnSettingNullMeanImage) {
23     InferenceEngine::PreProcessInfo info;
24     info.init(1);
25     ASSERT_THROW(info.setMeanImage(InferenceEngine::Blob::Ptr(nullptr)),
26             InferenceEngine::details::InferenceEngineException);
27
28 }
29
30 TEST_F(PreProcessTests, throwsOnSetting2DMeanImage) {
31     InferenceEngine::PreProcessInfo info;
32     info.init(1);
33     InferenceEngine::Blob::Ptr blob(new InferenceEngine::TBlob<float>(InferenceEngine::Precision::FP32, InferenceEngine::Layout::HW, {1, 1}));
34     ASSERT_THROW(info.setMeanImage(blob), InferenceEngine::details::InferenceEngineException);
35
36 }
37
38 TEST_F(PreProcessTests, throwsOnSettingWrongSizeMeanImage) {
39     InferenceEngine::PreProcessInfo info;
40     info.init(1);
41     InferenceEngine::TBlob<float>::Ptr blob(new InferenceEngine::TBlob<float>(InferenceEngine::Precision::FP32, InferenceEngine::Layout::CHW, { 1, 1, 2 }));
42     blob->set({ 1.f, 2.f });
43     ASSERT_THROW(info.setMeanImage(blob), InferenceEngine::details::InferenceEngineException);
44 }
45
46 TEST_F(PreProcessTests, noThrowWithCorrectSizeMeanImage) {
47     InferenceEngine::PreProcessInfo info;
48     info.init(2);
49     InferenceEngine::TBlob<float>::Ptr blob(new InferenceEngine::TBlob<float>(InferenceEngine::Precision::FP32, InferenceEngine::Layout::CHW, { 1, 1, 2 }));
50     blob->set({ 1.f, 2.f });
51     ASSERT_NO_THROW(info.setMeanImage(blob));
52 }