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/CircleSparseToDense.h"
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
22 #include <gtest/gtest.h>
24 TEST(CircleSparseToDenseTest, constructor)
26 luci::CircleSparseToDense stb_node;
28 ASSERT_EQ(luci::CircleDialect::get(), stb_node.dialect());
29 ASSERT_EQ(luci::CircleOpcode::SPARSE_TO_DENSE, stb_node.opcode());
31 ASSERT_EQ(nullptr, stb_node.indices());
32 ASSERT_EQ(nullptr, stb_node.output_shape());
33 ASSERT_EQ(nullptr, stb_node.values());
34 ASSERT_EQ(nullptr, stb_node.default_value());
36 ASSERT_EQ(true, stb_node.validate_indices());
39 TEST(CircleSparseToDenseTest, input_NEG)
41 luci::CircleSparseToDense stb_node;
42 luci::CircleSparseToDense node;
44 stb_node.indices(&node);
45 stb_node.output_shape(&node);
46 stb_node.values(&node);
47 stb_node.default_value(&node);
48 ASSERT_NE(nullptr, stb_node.indices());
49 ASSERT_NE(nullptr, stb_node.output_shape());
50 ASSERT_NE(nullptr, stb_node.values());
51 ASSERT_NE(nullptr, stb_node.default_value());
53 stb_node.indices(nullptr);
54 stb_node.output_shape(nullptr);
55 stb_node.values(nullptr);
56 stb_node.default_value(nullptr);
57 ASSERT_EQ(nullptr, stb_node.indices());
58 ASSERT_EQ(nullptr, stb_node.output_shape());
59 ASSERT_EQ(nullptr, stb_node.values());
60 ASSERT_EQ(nullptr, stb_node.default_value());
63 TEST(CircleSparseToDenseTest, arity_NEG)
65 luci::CircleSparseToDense stb_node;
67 ASSERT_NO_THROW(stb_node.arg(3));
68 ASSERT_THROW(stb_node.arg(4), std::out_of_range);
71 TEST(CircleSparseToDenseTest, visit_mutable_NEG)
73 struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
77 luci::CircleSparseToDense stb_node;
80 ASSERT_THROW(stb_node.accept(&tv), std::exception);
83 TEST(CircleSparseToDenseTest, visit_NEG)
85 struct TestVisitor final : public luci::CircleNodeVisitor<void>
89 luci::CircleSparseToDense stb_node;
92 ASSERT_THROW(stb_node.accept(&tv), std::exception);