|
| 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 <image_projection_based_fusion/pointpainting_fusion/node.hpp> |
| 16 | + |
| 17 | +#include <gtest/gtest.h> |
| 18 | + |
| 19 | +sensor_msgs::msg::RegionOfInterest createRoi( |
| 20 | + const int32_t x_offset, const int32_t y_offset, const int32_t width, const int32_t height) |
| 21 | +{ |
| 22 | + sensor_msgs::msg::RegionOfInterest roi; |
| 23 | + roi.x_offset = x_offset; |
| 24 | + roi.y_offset = y_offset; |
| 25 | + roi.width = width; |
| 26 | + roi.height = height; |
| 27 | + return roi; |
| 28 | +} |
| 29 | + |
| 30 | +TEST(isInsideBboxTest, Inside) |
| 31 | +{ |
| 32 | + const sensor_msgs::msg::RegionOfInterest roi = createRoi(20, 20, 10, 10); |
| 33 | + bool result = image_projection_based_fusion::isInsideBbox(25.0, 25.0, roi, 1.0); |
| 34 | + EXPECT_TRUE(result); |
| 35 | +} |
| 36 | + |
| 37 | +TEST(isInsideBboxTest, Border) |
| 38 | +{ |
| 39 | + const sensor_msgs::msg::RegionOfInterest roi = createRoi(20, 20, 10, 10); |
| 40 | + bool result = image_projection_based_fusion::isInsideBbox(20.0, 30.0, roi, 1.0); |
| 41 | + EXPECT_TRUE(result); |
| 42 | +} |
| 43 | + |
| 44 | +TEST(isInsideBboxTest, Outside) |
| 45 | +{ |
| 46 | + const sensor_msgs::msg::RegionOfInterest roi = createRoi(20, 20, 10, 10); |
| 47 | + bool result = image_projection_based_fusion::isInsideBbox(15.0, 15.0, roi, 1.0); |
| 48 | + EXPECT_FALSE(result); |
| 49 | +} |
| 50 | + |
| 51 | +TEST(isInsideBboxTest, Zero) |
| 52 | +{ |
| 53 | + const sensor_msgs::msg::RegionOfInterest roi = createRoi(0, 0, 0, 0); |
| 54 | + bool result = image_projection_based_fusion::isInsideBbox(0.0, 0.0, roi, 1.0); |
| 55 | + EXPECT_TRUE(result); |
| 56 | +} |
0 commit comments