Skip to content

Commit

Permalink
Merge branch 'main' into feature/dont_insert_stop_point_crosswalk
Browse files Browse the repository at this point in the history
Signed-off-by: kyoichi-sugahara <[email protected]>
  • Loading branch information
kyoichi-sugahara committed Oct 3, 2023
2 parents 8ae43b7 + 1c2c59d commit 330c5b0
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
20 changes: 20 additions & 0 deletions common/component_interface_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,24 @@ project(component_interface_utils)

find_package(autoware_cmake REQUIRED)
autoware_package()

include_directories(
include
SYSTEM
${rclcpp_INCLUDE_DIRS}
${rosidl_runtime_cpp_INCLUDE_DIRS}
${rcl_INCLUDE_DIRS}
${autoware_adapi_v1_msgs_INCLUDE_DIRS}
)

if(BUILD_TESTING)
ament_add_ros_isolated_gtest(test_component_interface_utils
test/test_component_interface_utils.cpp
)

target_include_directories(test_component_interface_utils
PRIVATE include
)
endif()

ament_auto_package()
1 change: 1 addition & 0 deletions common/component_interface_utils/package.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>

<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2023 The Autoware Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "component_interface_utils/rclcpp/exceptions.hpp"
#include "component_interface_utils/specs.hpp"
#include "component_interface_utils/status.hpp"
#include "gtest/gtest.h"

TEST(interface, utils)
{
{
using component_interface_utils::ServiceException;
using ResponseStatus = autoware_adapi_v1_msgs::msg::ResponseStatus;
using ResponseStatusCode = ResponseStatus::_code_type;

ResponseStatusCode code = 10;
const std::string message = "test_exception";
ServiceException service(code, message);
ResponseStatus code_back;
code_back = service.status();
EXPECT_EQ(code_back.code, code);
EXPECT_EQ(code_back.message, message);
}

{
using component_interface_utils::ServiceException;
using ResponseStatus = autoware_adapi_v1_msgs::msg::ResponseStatus;
using ResponseStatusCode = ResponseStatus::_code_type;

ResponseStatusCode code = 10;
const std::string message = "test_exception";
ServiceException service(code, message);
ResponseStatus code_set;
service.set(code_set);
EXPECT_EQ(code_set.code, code);
EXPECT_EQ(code_set.message, message);
}

{
using component_interface_utils::ServiceException;
using ResponseStatus = autoware_adapi_v1_msgs::msg::ResponseStatus;
using ResponseStatusCode = ResponseStatus::_code_type;
using component_interface_utils::status::copy;

class status_test
{
public:
status_test(ResponseStatusCode code, const std::string & message, bool success = false)
{
status.code = code;
status.message = message;
status.success = success;
}
ResponseStatus status;
};

const status_test status_in(10, "test_exception", true);
auto status_copy = std::make_shared<status_test>(100, "test_exception_copy", false);
copy(&status_in, status_copy);

EXPECT_EQ(status_in.status.code, status_copy->status.code);
EXPECT_EQ(status_in.status.message, status_copy->status.message);
EXPECT_EQ(status_in.status.success, status_copy->status.success);
}
}

0 comments on commit 330c5b0

Please sign in to comment.