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/CircleSelectV2.h"
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
22 #include <gtest/gtest.h>
24 TEST(CircleSelectV2Test, constructor)
26 luci::CircleSelectV2 select_node;
28 ASSERT_EQ(luci::CircleDialect::get(), select_node.dialect());
29 ASSERT_EQ(luci::CircleOpcode::SELECT_V2, select_node.opcode());
31 ASSERT_EQ(nullptr, select_node.condition());
32 ASSERT_EQ(nullptr, select_node.t());
33 ASSERT_EQ(nullptr, select_node.e());
36 TEST(CircleSelectV2Test, input_NEG)
38 luci::CircleSelectV2 select_v2_node;
39 luci::CircleSelectV2 node;
41 select_v2_node.condition(&node);
42 select_v2_node.t(&node);
43 select_v2_node.e(&node);
44 ASSERT_NE(nullptr, select_v2_node.condition());
45 ASSERT_NE(nullptr, select_v2_node.t());
46 ASSERT_NE(nullptr, select_v2_node.e());
48 select_v2_node.condition(nullptr);
49 select_v2_node.t(nullptr);
50 select_v2_node.e(nullptr);
51 ASSERT_EQ(nullptr, select_v2_node.condition());
52 ASSERT_EQ(nullptr, select_v2_node.t());
53 ASSERT_EQ(nullptr, select_v2_node.e());
56 TEST(CircleSelectV2Test, arity_NEG)
58 luci::CircleSelectV2 select_v2_node;
60 ASSERT_NO_THROW(select_v2_node.arg(2));
61 ASSERT_THROW(select_v2_node.arg(3), std::out_of_range);
64 TEST(CircleSelectV2Test, visit_mutable_NEG)
66 struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
70 luci::CircleSelectV2 select_v2_node;
73 ASSERT_THROW(select_v2_node.accept(&tv), std::exception);
76 TEST(CircleSelectV2Test, visit_NEG)
78 struct TestVisitor final : public luci::CircleNodeVisitor<void>
82 luci::CircleSelectV2 select_v2_node;
85 ASSERT_THROW(select_v2_node.accept(&tv), std::exception);