|
| 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