Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,21 @@ public String toString() {

public void incrementWeight(double weight) {
if (Double.isInfinite(weight) || Double.isNaN(weight)) {
throw new IllegalArgumentException(
"A state's weight is being incremented by " + weight + " while traversing edge " + backEdge
LOG.warn(
"A state's weight is being incremented by {} while traversing edge {}",
weight,
backEdge
);
}
if (weight < 0) {
throw new IllegalArgumentException(
"A state's weight is being incremented by a negative amount while traversing edge " +
backEdge
defectiveTraversal = true;
return;
} else if (weight < 0) {
LOG.warn(
"A state's weight is being incremented by negative amount {} while traversing edge {}",
weight,
backEdge
);
defectiveTraversal = true;
return;
}
this.weight += weight;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Nested;
Expand Down Expand Up @@ -45,17 +45,17 @@ public final void testNanWeightIncrement() {
StateEditor stateEditor = new StateEditor(vertex, StreetSearchRequest.of().build());

stateEditor.setTimeSeconds(0);
assertThrows(IllegalArgumentException.class, () -> stateEditor.incrementWeight(Double.NaN));
stateEditor.incrementWeight(Double.NaN);
assertNull(stateEditor.makeState());
}

@Test
public final void testInfinityWeightIncrement() {
StateEditor stateEditor = new StateEditor(vertex, StreetSearchRequest.of().build());

stateEditor.setTimeSeconds(0);
assertThrows(IllegalArgumentException.class, () ->
stateEditor.incrementWeight(Double.NEGATIVE_INFINITY)
);
stateEditor.incrementWeight(Double.NEGATIVE_INFINITY);
assertNull(stateEditor.makeState());
}

@Nested
Expand Down
Loading