Skip to content

Commit d482924

Browse files
authored
test(detected_object_validation): add unit tests of utils (#7144)
test: add unit tests Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
1 parent f28a757 commit d482924

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

perception/detected_object_validation/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ rclcpp_components_register_node(occupancy_grid_based_validator
8585
EXECUTABLE occupancy_grid_based_validator_node
8686
)
8787

88+
if(BUILD_TESTING)
89+
ament_auto_add_gtest(detection_object_validation_tests
90+
test/test_utils.cpp
91+
)
92+
endif()
93+
8894
ament_auto_package(INSTALL_TO_SHARE
8995
launch
9096
config
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2024 TIER IV, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "detected_object_validation/utils/utils.hpp"
16+
17+
#include <autoware_auto_perception_msgs/msg/object_classification.hpp>
18+
19+
#include <gtest/gtest.h>
20+
21+
using AutowareLabel = autoware_auto_perception_msgs::msg::ObjectClassification;
22+
23+
utils::FilterTargetLabel createFilterTargetAll()
24+
{
25+
utils::FilterTargetLabel filter;
26+
filter.UNKNOWN = true;
27+
filter.CAR = true;
28+
filter.TRUCK = true;
29+
filter.BUS = true;
30+
filter.TRAILER = true;
31+
filter.MOTORCYCLE = true;
32+
filter.BICYCLE = true;
33+
filter.PEDESTRIAN = true;
34+
return filter;
35+
}
36+
37+
utils::FilterTargetLabel createFilterTargetVehicle()
38+
{
39+
utils::FilterTargetLabel filter;
40+
filter.UNKNOWN = false;
41+
filter.CAR = true;
42+
filter.TRUCK = true;
43+
filter.BUS = true;
44+
filter.TRAILER = true;
45+
filter.MOTORCYCLE = false;
46+
filter.BICYCLE = false;
47+
filter.PEDESTRIAN = false;
48+
return filter;
49+
}
50+
51+
TEST(IsTargetTest, AllTarget)
52+
{
53+
auto filter = createFilterTargetAll();
54+
auto label = AutowareLabel::CAR;
55+
EXPECT_TRUE(filter.isTarget(label));
56+
}
57+
58+
TEST(IsTargetTest, VehicleTarget)
59+
{
60+
auto filter = createFilterTargetVehicle();
61+
62+
auto car_label = AutowareLabel::CAR;
63+
EXPECT_TRUE(filter.isTarget(car_label));
64+
65+
auto unknown_label = AutowareLabel::UNKNOWN;
66+
EXPECT_FALSE(filter.isTarget(unknown_label));
67+
}

0 commit comments

Comments
 (0)