2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "luci/IR/Nodes/CircleSplitV.h"
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
22 #include <gtest/gtest.h>
24 TEST(CircleSplitVTest, constructor)
26 luci::CircleSplitV splitv_node;
28 ASSERT_EQ(luci::CircleDialect::get(), splitv_node.dialect());
29 ASSERT_EQ(luci::CircleOpcode::SPLIT_V, splitv_node.opcode());
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());
37 TEST(CircleSplitVTest, input_NEG)
39 luci::CircleSplitV splitv_node;
40 luci::CircleSplitV node;
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());
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());
56 splitv_node.num_split(100);
57 ASSERT_NE(0, splitv_node.num_split());
60 TEST(CircleSplitVTest, arity_NEG)
62 luci::CircleSplitV splitv_node;
64 ASSERT_NO_THROW(splitv_node.arg(2));
65 ASSERT_THROW(splitv_node.arg(3), std::out_of_range);
68 TEST(CircleSplitVTest, visit_mutable_NEG)
70 struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
74 luci::CircleSplitV splitv_node;
77 ASSERT_THROW(splitv_node.accept(&tv), std::exception);
80 TEST(CircleSplitVTest, visit_NEG)
82 struct TestVisitor final : public luci::CircleNodeVisitor<void>
86 luci::CircleSplitV splitv_node;
89 ASSERT_THROW(splitv_node.accept(&tv), std::exception);