Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / compiler / luci / lang / src / Nodes / CircleNonMaxSuppressionV4.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/CircleNonMaxSuppressionV4.h"
18
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
21
22 #include <gtest/gtest.h>
23
24 TEST(CircleNonMaxSuppressionV4Test, constructor)
25 {
26   luci::CircleNonMaxSuppressionV4 nmsv4_node;
27
28   ASSERT_EQ(luci::CircleDialect::get(), nmsv4_node.dialect());
29   ASSERT_EQ(luci::CircleOpcode::NON_MAX_SUPPRESSION_V4, nmsv4_node.opcode());
30
31   ASSERT_EQ(nullptr, nmsv4_node.boxes());
32   ASSERT_EQ(nullptr, nmsv4_node.scores());
33   ASSERT_EQ(nullptr, nmsv4_node.max_output_size());
34   ASSERT_EQ(nullptr, nmsv4_node.iou_threshold());
35   ASSERT_EQ(nullptr, nmsv4_node.score_threshold());
36 }
37
38 TEST(CircleNonMaxSuppressionV4Test, input_NEG)
39 {
40   luci::CircleNonMaxSuppressionV4 nmsv4_node;
41   luci::CircleNonMaxSuppressionV4 node;
42
43   nmsv4_node.boxes(&node);
44   nmsv4_node.scores(&node);
45   nmsv4_node.max_output_size(&node);
46   nmsv4_node.iou_threshold(&node);
47   nmsv4_node.score_threshold(&node);
48   ASSERT_NE(nullptr, nmsv4_node.boxes());
49   ASSERT_NE(nullptr, nmsv4_node.scores());
50   ASSERT_NE(nullptr, nmsv4_node.max_output_size());
51   ASSERT_NE(nullptr, nmsv4_node.iou_threshold());
52   ASSERT_NE(nullptr, nmsv4_node.score_threshold());
53
54   nmsv4_node.boxes(nullptr);
55   nmsv4_node.scores(nullptr);
56   nmsv4_node.max_output_size(nullptr);
57   nmsv4_node.iou_threshold(nullptr);
58   nmsv4_node.score_threshold(nullptr);
59   ASSERT_EQ(nullptr, nmsv4_node.boxes());
60   ASSERT_EQ(nullptr, nmsv4_node.scores());
61   ASSERT_EQ(nullptr, nmsv4_node.max_output_size());
62   ASSERT_EQ(nullptr, nmsv4_node.iou_threshold());
63   ASSERT_EQ(nullptr, nmsv4_node.score_threshold());
64 }
65
66 TEST(CircleNonMaxSuppressionV4Test, arity_NEG)
67 {
68   luci::CircleNonMaxSuppressionV4 nmsv4_node;
69
70   ASSERT_NO_THROW(nmsv4_node.arg(4));
71   ASSERT_THROW(nmsv4_node.arg(5), std::out_of_range);
72 }
73
74 TEST(CircleNonMaxSuppressionV4Test, visit_mutable_NEG)
75 {
76   struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
77   {
78   };
79
80   luci::CircleNonMaxSuppressionV4 nmsv4_node;
81
82   TestVisitor tv;
83   ASSERT_THROW(nmsv4_node.accept(&tv), std::exception);
84 }
85
86 TEST(CircleNonMaxSuppressionV4Test, visit_NEG)
87 {
88   struct TestVisitor final : public luci::CircleNodeVisitor<void>
89   {
90   };
91
92   luci::CircleNonMaxSuppressionV4 nmsv4_node;
93
94   TestVisitor tv;
95   ASSERT_THROW(nmsv4_node.accept(&tv), std::exception);
96 }