fce42239861514bb882665cf6e12be6abec9aee5
[platform/core/ml/nnfw.git] / runtime / neurun / test / graph / operand / Set.cc
1 /*
2  * Copyright (c) 2018 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 <gtest/gtest.h>
18
19 #include "model/Operands.h"
20
21 TEST(graph_operand_Set, set_test)
22 {
23   neurun::model::Operands set;
24
25   ::neurun::model::Shape shape0{1, 2, 3};
26
27   ::neurun::model::Shape shape1(4);
28   shape1.dim(0) = 10;
29   shape1.dim(1) = 20;
30   shape1.dim(2) = 30;
31   shape1.dim(3) = 40;
32
33   ::neurun::model::TypeInfo type{neurun::model::DataType::INT32};
34
35   set.emplace(shape0, type);
36   set.emplace(shape1, type);
37
38   ASSERT_EQ(set.exist(neurun::model::OperandIndex{0u}), true);
39   ASSERT_EQ(set.exist(neurun::model::OperandIndex{1u}), true);
40   ASSERT_EQ(set.exist(neurun::model::OperandIndex{2u}), false);
41
42   ASSERT_EQ(set.at(neurun::model::OperandIndex{0u}).shape().dim(0), 1);
43   ASSERT_EQ(set.at(neurun::model::OperandIndex{0u}).shape().dim(1), 2);
44   ASSERT_EQ(set.at(neurun::model::OperandIndex{0u}).shape().dim(2), 3);
45 }