Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / compiler / loco / src / IR / FeatureShape.test.cpp
1 /*
2  * Copyright (c) 2019 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 "loco/IR/FeatureShape.h"
18
19 #include <gtest/gtest.h>
20
21 TEST(FeatureShapeTest, default_constructor)
22 {
23   loco::FeatureShape shape;
24
25   ASSERT_FALSE(shape.count().known());
26   ASSERT_FALSE(shape.depth().known());
27   ASSERT_FALSE(shape.height().known());
28   ASSERT_FALSE(shape.width().known());
29 }
30
31 TEST(FeatureShapeTest, settet_and_getter)
32 {
33   loco::FeatureShape shape;
34
35   // Set count
36   shape.count() = 2;
37
38   ASSERT_TRUE(shape.count().known());
39   ASSERT_FALSE(shape.depth().known());
40   ASSERT_FALSE(shape.height().known());
41   ASSERT_FALSE(shape.width().known());
42
43   ASSERT_EQ(2, shape.count());
44
45   // Set depth
46   shape.depth() = 3;
47
48   ASSERT_TRUE(shape.count().known());
49   ASSERT_TRUE(shape.depth().known());
50   ASSERT_FALSE(shape.height().known());
51   ASSERT_FALSE(shape.width().known());
52
53   ASSERT_EQ(2, shape.count());
54   ASSERT_EQ(3, shape.depth());
55
56   // Set height
57   shape.height() = 4;
58
59   ASSERT_TRUE(shape.count().known());
60   ASSERT_TRUE(shape.depth().known());
61   ASSERT_TRUE(shape.height().known());
62   ASSERT_FALSE(shape.width().known());
63
64   ASSERT_EQ(2, shape.count());
65   ASSERT_EQ(3, shape.depth());
66   ASSERT_EQ(4, shape.height());
67
68   // Set width
69   shape.width() = 5;
70
71   ASSERT_TRUE(shape.count().known());
72   ASSERT_TRUE(shape.depth().known());
73   ASSERT_TRUE(shape.height().known());
74   ASSERT_TRUE(shape.width().known());
75
76   ASSERT_EQ(2, shape.count());
77   ASSERT_EQ(3, shape.depth());
78   ASSERT_EQ(4, shape.height());
79   ASSERT_EQ(5, shape.width());
80 }