Skip to content

Commit

Permalink
Clean up test comments
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 21, 2023
1 parent 7a38747 commit 428970b
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class TransferTest {
Coordinates.BERLIN_BRANDENBURG_GATE
);
private static final IntersectionVertex BOSTON_V = intersectionVertex(Coordinates.BOSTON);
private static final int MAX_RAPTOR_TRANSFER_COST = RaptorCostConverter.toRaptorCost(
Transfer.MAX_TRANSFER_COST
);

@Nested
class WithEdges {
Expand All @@ -33,7 +36,7 @@ void limitMaxCost() {

var veryLongTransfer = new Transfer(0, List.of(edge));
assertTrue(veryLongTransfer.getDistanceMeters() > 1_000_000);
// cost would be too high, so it should not be included in RAPTOR search
// cost would be too high, so it should be capped to a maximum value
assertMaxCost(veryLongTransfer.asRaptorTransfer(StreetSearchRequest.of().build()).get());
}

Expand All @@ -45,7 +48,7 @@ void allowLowCost() {
final Optional<RaptorTransfer> raptorTransfer = transfer.asRaptorTransfer(
StreetSearchRequest.of().build()
);
// cost is below max limit and included in RAPTOR unchanged
// cost is below max limit and included as is in RAPTOR unchanged
assertBelowMaxCost(raptorTransfer.get());
}
}
Expand All @@ -68,7 +71,7 @@ void negativeCost() {
@Test
void limitMaxCost() {
var veryLongTransfer = new Transfer(0, 8_000_000);
// cost would be too high, so it should not be included in RAPTOR search
// cost would be too high, so it will be capped before passing to RAPTOR
assertMaxCost(veryLongTransfer.asRaptorTransfer(StreetSearchRequest.of().build()).get());
}

Expand All @@ -78,21 +81,16 @@ void allowLowCost() {
final Optional<RaptorTransfer> raptorTransfer = transfer.asRaptorTransfer(
StreetSearchRequest.of().build()
);
// cost is below max limit and should be included in RAPTOR
// cost is below max limit and should be included as is in RAPTOR
assertBelowMaxCost(raptorTransfer.get());
}
}

private static void assertMaxCost(RaptorTransfer transfer) {
assertEquals(
RaptorCostConverter.toRaptorCost(Transfer.MAX_TRANSFER_COST),
transfer.generalizedCost()
);
assertEquals(MAX_RAPTOR_TRANSFER_COST, transfer.generalizedCost());
}

private static void assertBelowMaxCost(RaptorTransfer transfer) {
assertTrue(
RaptorCostConverter.toRaptorCost(Transfer.MAX_TRANSFER_COST) > transfer.generalizedCost()
);
assertTrue(MAX_RAPTOR_TRANSFER_COST > transfer.generalizedCost());
}
}

0 comments on commit 428970b

Please sign in to comment.