Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Zulfaqar Azmi <[email protected]>
  • Loading branch information
zulfaqar-azmi-t4 committed May 10, 2024
1 parent bf4125c commit 7ea9152
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
8 changes: 3 additions & 5 deletions planning/route_handler/test/test_route_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@

#include "ament_index_cpp/get_package_share_directory.hpp"
#include "gtest/gtest.h"
#include <route_handler/route_handler.hpp>

#include <lanelet2_extension/io/autoware_osm_parser.hpp>
#include <lanelet2_extension/projection/mgrs_projector.hpp>
#include <lanelet2_extension/utility/message_conversion.hpp>
#include <lanelet2_extension/utility/utilities.hpp>
#include <rclcpp/clock.hpp>
#include <rclcpp/logging.hpp>
#include <route_handler/route_handler.hpp>

#include <autoware_auto_mapping_msgs/msg/had_map_bin.hpp>

#include <lanelet2_io/Io.h>

#include <string>
#include <memory>
#include <string>
namespace route_handler::test
{

Expand All @@ -40,9 +40,7 @@ using autoware_auto_mapping_msgs::msg::HADMapBin;
class TestRouteHandler : public ::testing::Test
{
public:
TestRouteHandler(){
route_handler_ = std::make_shared<RouteHandler>(makeMapBinMsg());
}
TestRouteHandler() { route_handler_ = std::make_shared<RouteHandler>(makeMapBinMsg()); }
TestRouteHandler(const TestRouteHandler &) = delete;
TestRouteHandler(TestRouteHandler &&) = delete;
TestRouteHandler & operator=(const TestRouteHandler &) = delete;
Expand Down
76 changes: 39 additions & 37 deletions planning/route_handler/test/test_route_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace route_handler::test
{
// Example YAML structure as a string for testing
const std::string g_complete_yaml = R"(
const char g_complete_yaml[] = R"(
start_pose:
position:
x: 1.0
Expand Down Expand Up @@ -91,42 +91,44 @@ TEST(ParseFunctions, CompleteYAMLTest)
EXPECT_EQ(segment0.primitives[1].primitive_type, "lane");
}

TEST(ParseFunction, CompleteFromFilename){
const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("route_handler");
const auto parser_test_route = planning_test_utils_dir + "/test_route/parser_test.route";


const auto lanelet_route = parse_route_file(parser_test_route);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.position.x, 1.0);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.position.y, 2.0);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.position.z, 3.0);

EXPECT_DOUBLE_EQ(lanelet_route.start_pose.orientation.x, 0.1);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.orientation.y, 0.2);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.orientation.z, 0.3);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.orientation.w, 0.4);

EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.position.x, 4.0);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.position.y, 5.0);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.position.z, 6.0);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.orientation.x, 0.5);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.orientation.y, 0.6);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.orientation.z, 0.7);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.orientation.w, 0.8);

ASSERT_EQ(lanelet_route.segments.size(), 2); // Assuming only one segment in the provided YAML for this test
const auto & segment1 = lanelet_route.segments[1];
EXPECT_EQ(segment1.preferred_primitive.id, 44);
EXPECT_EQ(segment1.primitives.size(), 4);
EXPECT_EQ(segment1.primitives[0].id, 55);
EXPECT_EQ(segment1.primitives[0].primitive_type, "lane");
EXPECT_EQ(segment1.primitives[1].id, 66);
EXPECT_EQ(segment1.primitives[1].primitive_type, "lane");
EXPECT_EQ(segment1.primitives[2].id, 77);
EXPECT_EQ(segment1.primitives[2].primitive_type, "lane");
EXPECT_EQ(segment1.primitives[3].id, 88);
EXPECT_EQ(segment1.primitives[3].primitive_type, "lane");
TEST(ParseFunction, CompleteFromFilename)
{
const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("route_handler");
const auto parser_test_route = planning_test_utils_dir + "/test_route/parser_test.route";

const auto lanelet_route = parse_route_file(parser_test_route);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.position.x, 1.0);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.position.y, 2.0);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.position.z, 3.0);

EXPECT_DOUBLE_EQ(lanelet_route.start_pose.orientation.x, 0.1);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.orientation.y, 0.2);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.orientation.z, 0.3);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.orientation.w, 0.4);

EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.position.x, 4.0);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.position.y, 5.0);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.position.z, 6.0);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.orientation.x, 0.5);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.orientation.y, 0.6);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.orientation.z, 0.7);
EXPECT_DOUBLE_EQ(lanelet_route.goal_pose.orientation.w, 0.8);

ASSERT_EQ(
lanelet_route.segments.size(),
2); // Assuming only one segment in the provided YAML for this test
const auto & segment1 = lanelet_route.segments[1];
EXPECT_EQ(segment1.preferred_primitive.id, 44);
EXPECT_EQ(segment1.primitives.size(), 4);
EXPECT_EQ(segment1.primitives[0].id, 55);
EXPECT_EQ(segment1.primitives[0].primitive_type, "lane");
EXPECT_EQ(segment1.primitives[1].id, 66);
EXPECT_EQ(segment1.primitives[1].primitive_type, "lane");
EXPECT_EQ(segment1.primitives[2].id, 77);
EXPECT_EQ(segment1.primitives[2].primitive_type, "lane");
EXPECT_EQ(segment1.primitives[3].id, 88);
EXPECT_EQ(segment1.primitives[3].primitive_type, "lane");
}
int main(int argc, char ** argv)
{
Expand Down
2 changes: 1 addition & 1 deletion planning/route_handler/test_route/rh_test.route
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ segments:
- id: 4870
primitive_type: lane
- id: 5156
primitive_type: lane
primitive_type: lane

0 comments on commit 7ea9152

Please sign in to comment.