diff --git a/test/distance_router_test.cc b/test/distance_router_test.cc index d97ca64..91af2cd 100644 --- a/test/distance_router_test.cc +++ b/test/distance_router_test.cc @@ -160,7 +160,7 @@ class TShapeRoadRoutingTest : public ::testing::Test { }; // Defines the test cases for the TShapeRoad where the start and end positions are on the very same Lane. -class RoutingInTheSameSegmentTest : public TShapeRoadRoutingTest { +class RoutingInTheSameLaneTest : public TShapeRoadRoutingTest { public: void SetUp() override { TShapeRoadRoutingTest::SetUp(); @@ -173,7 +173,7 @@ class RoutingInTheSameSegmentTest : public TShapeRoadRoutingTest { }; // No constraints are provided and the only possible route is returned. -TEST_F(RoutingInTheSameSegmentTest, WithDefaultConstraintsReturnsTheLane) { +TEST_F(RoutingInTheSameLaneTest, WithDefaultConstraintsReturnsTheLane) { const std::vector kPhaseLaneSRanges{api::LaneSRange(kLaneId_0_0_m1, api::SRange(1., 10.)), api::LaneSRange(kLaneId_0_0_1, api::SRange(1., 10.))}; @@ -188,21 +188,21 @@ TEST_F(RoutingInTheSameSegmentTest, WithDefaultConstraintsReturnsTheLane) { } // The maximum cost of the phase is smaller than the solution's phase cost, so no routes can be found. -TEST_F(RoutingInTheSameSegmentTest, WithConstrainedPhaseCostReturnsEmpty) { +TEST_F(RoutingInTheSameLaneTest, WithConstrainedPhaseCostReturnsEmpty) { const std::vector routes = dut_->ComputeRoutes(start_, end_, kSmallPhaseCostConstraint); ASSERT_TRUE(routes.empty()); } // The maximum cost of the route is smaller than the solution's phase cost, so no routes can be found. -TEST_F(RoutingInTheSameSegmentTest, WithConstrainedRouteCostReturnsEmpty) { +TEST_F(RoutingInTheSameLaneTest, WithConstrainedRouteCostReturnsEmpty) { const std::vector routes = dut_->ComputeRoutes(start_, end_, kSmallRouteCostConstraint); ASSERT_TRUE(routes.empty()); } -// Because the start and end positions are on the same Lane, no lane switch is required thus there is a solution. -TEST_F(RoutingInTheSameSegmentTest, WithConstrainedLaneSwitchReturnsTheLane) { +// Because the start and end positions are on the same Lane, no lane switch is required and thus there is a solution. +TEST_F(RoutingInTheSameLaneTest, WithConstrainedLaneSwitchReturnsTheLane) { const std::vector kPhaseLaneSRanges{api::LaneSRange(kLaneId_0_0_m1, api::SRange(1., 10.)), api::LaneSRange(kLaneId_0_0_1, api::SRange(1., 10.))}; @@ -216,11 +216,22 @@ TEST_F(RoutingInTheSameSegmentTest, WithConstrainedLaneSwitchReturnsTheLane) { std::vector{end_}, kPhaseLaneSRanges); } +// Similar to RoutingInTheSameLaneTest, but the end position is in another api::Lane. +class RoutingInTheSameSegmentTest : public TShapeRoadRoutingTest { + public: + void SetUp() override { + TShapeRoadRoutingTest::SetUp(); + start_ = api::RoadPosition(lane_0_0_1_, api::LanePosition(1., 0., 0.)); + end_ = api::RoadPosition(lane_0_0_m1_, api::LanePosition(10., 0., 0.)); + } + + api::RoadPosition start_; + api::RoadPosition end_; +}; + // The lane switch constraint with start and end positions in different api::Lanes produces no possible routes. TEST_F(RoutingInTheSameSegmentTest, WithConstrainedLaneSwitchInDifferentLaneReturnsEmpty) { - const api::RoadPosition end(lane_0_0_m1_, api::LanePosition(10., 0., 0.)); - - const std::vector routes = dut_->ComputeRoutes(start_, end, kDontAllowLaneSwitchRoutingConstraint); + const std::vector routes = dut_->ComputeRoutes(start_, end_, kDontAllowLaneSwitchRoutingConstraint); ASSERT_TRUE(routes.empty()); }