Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / compiler / mio-circle05 / src / Reader.test.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "mio_circle/Reader.h"
18
19 #include <flatbuffers/flatbuffers.h>
20 #include <gtest/gtest.h>
21
22 class mio_circle05_reader_test : public ::testing::Test
23 {
24 protected:
25   void initialization_emty(void)
26   {
27     _model = circle::CreateModelDirect(_fbb, 0, &_opcodes_vec);
28     circle::FinishModelBuffer(_fbb, _model);
29   }
30
31   const circle::Model *circleModel(void)
32   {
33     auto ptr = _fbb.GetBufferPointer();
34     return circle::GetModel(ptr);
35   }
36
37 private:
38   flatbuffers::FlatBufferBuilder _fbb;
39   flatbuffers::Offset<circle::Model> _model;
40   std::vector<flatbuffers::Offset<circle::OperatorCode>> _opcodes_vec;
41 };
42
43 TEST_F(mio_circle05_reader_test, null_Model_NEG)
44 {
45   EXPECT_THROW(mio::circle::Reader reader(nullptr), std::runtime_error);
46 }
47
48 TEST_F(mio_circle05_reader_test, empty_Model)
49 {
50   initialization_emty();
51
52   const circle::Model *model = circleModel();
53   EXPECT_NE(nullptr, model);
54
55   mio::circle::Reader reader(model);
56
57   SUCCEED();
58 }
59
60 // TODO add more tests