Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / compiler / luci / lang / src / Nodes / CircleSplitV.test.cpp
1 /*
2  * Copyright (c) 2020 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 "luci/IR/Nodes/CircleSplitV.h"
18
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
21
22 #include <gtest/gtest.h>
23
24 TEST(CircleSplitVTest, constructor)
25 {
26   luci::CircleSplitV splitv_node;
27
28   ASSERT_EQ(luci::CircleDialect::get(), splitv_node.dialect());
29   ASSERT_EQ(luci::CircleOpcode::SPLIT_V, splitv_node.opcode());
30
31   ASSERT_EQ(nullptr, splitv_node.input());
32   ASSERT_EQ(nullptr, splitv_node.size_splits());
33   ASSERT_EQ(nullptr, splitv_node.split_dim());
34   ASSERT_EQ(0, splitv_node.num_split());
35 }
36
37 TEST(CircleSplitVTest, input_NEG)
38 {
39   luci::CircleSplitV splitv_node;
40   luci::CircleSplitV node;
41
42   splitv_node.input(&node);
43   splitv_node.size_splits(&node);
44   splitv_node.split_dim(&node);
45   ASSERT_NE(nullptr, splitv_node.input());
46   ASSERT_NE(nullptr, splitv_node.size_splits());
47   ASSERT_NE(nullptr, splitv_node.split_dim());
48
49   splitv_node.input(nullptr);
50   splitv_node.size_splits(nullptr);
51   splitv_node.split_dim(nullptr);
52   ASSERT_EQ(nullptr, splitv_node.input());
53   ASSERT_EQ(nullptr, splitv_node.size_splits());
54   ASSERT_EQ(nullptr, splitv_node.split_dim());
55
56   splitv_node.num_split(100);
57   ASSERT_NE(0, splitv_node.num_split());
58 }
59
60 TEST(CircleSplitVTest, arity_NEG)
61 {
62   luci::CircleSplitV splitv_node;
63
64   ASSERT_NO_THROW(splitv_node.arg(2));
65   ASSERT_THROW(splitv_node.arg(3), std::out_of_range);
66 }
67
68 TEST(CircleSplitVTest, visit_mutable_NEG)
69 {
70   struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
71   {
72   };
73
74   luci::CircleSplitV splitv_node;
75
76   TestVisitor tv;
77   ASSERT_THROW(splitv_node.accept(&tv), std::exception);
78 }
79
80 TEST(CircleSplitVTest, visit_NEG)
81 {
82   struct TestVisitor final : public luci::CircleNodeVisitor<void>
83   {
84   };
85
86   luci::CircleSplitV splitv_node;
87
88   TestVisitor tv;
89   ASSERT_THROW(splitv_node.accept(&tv), std::exception);
90 }