Skip to content

Commit

Permalink
Addresses review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Agustin Alba Chicar <[email protected]>
  • Loading branch information
agalbachicar committed Oct 1, 2024
1 parent 9f8d0d1 commit 9a6e1ae
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions test/distance_router_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<api::LaneSRange> kPhaseLaneSRanges{api::LaneSRange(kLaneId_0_0_m1, api::SRange(1., 10.)),
api::LaneSRange(kLaneId_0_0_1, api::SRange(1., 10.))};

Expand All @@ -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<routing::Route> 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<routing::Route> 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<api::LaneSRange> kPhaseLaneSRanges{api::LaneSRange(kLaneId_0_0_m1, api::SRange(1., 10.)),
api::LaneSRange(kLaneId_0_0_1, api::SRange(1., 10.))};

Expand All @@ -216,11 +216,22 @@ TEST_F(RoutingInTheSameSegmentTest, WithConstrainedLaneSwitchReturnsTheLane) {
std::vector<api::RoadPosition>{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<routing::Route> routes = dut_->ComputeRoutes(start_, end, kDontAllowLaneSwitchRoutingConstraint);
const std::vector<routing::Route> routes = dut_->ComputeRoutes(start_, end_, kDontAllowLaneSwitchRoutingConstraint);

ASSERT_TRUE(routes.empty());
}
Expand Down

0 comments on commit 9a6e1ae

Please sign in to comment.