Publishing 2019 R1.1 content and Myriad plugin sources (#162)
[platform/upstream/dldt.git] / inference-engine / tests / unit / engines / gna / matchers / input_data_matcher.hpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #include <utility>
6 #pragma once
7
8 #include <gmock/gmock-matchers.h>
9 #include "nnet_base_matcher.hpp"
10
11 class InputDataMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t *> {
12     std::vector<int16_t> refInput;
13 public:
14
15     explicit InputDataMatcher(const std::vector<int16_t> &_refInput) : refInput(_refInput) {}
16
17     bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
18         if (foo->pLayers == nullptr) {
19             *listener << "Address of the first layer descriptor is NULL";
20             return false;
21         }
22         auto firstLayer = foo->pLayers[0];
23         auto actualInput = firstLayer.pInputs;
24         if (!actualInput) {
25             *listener << "Input of the first layer is NULL";
26             return false;
27         }
28
29         auto *actualInputI16 = reinterpret_cast<int16_t *>(actualInput);
30         for (int i = 0; i < refInput.size(); i++) {
31             if (actualInputI16[i] != refInput[i]) {
32                 *listener << "Actual and reference value of input doesn't match: " << actualInputI16[i] << " vs "
33                           << refInput[i];
34             }
35         }
36         return true;
37     }
38
39     void DescribeTo(::std::ostream *os) const override {}
40 };