-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
347283e
commit 2292d0d
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
core/src/test/java/fr/sncf/osrd/standalone_sim/EnvelopeStopWrapperTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package fr.sncf.osrd.standalone_sim; | ||
|
||
import fr.sncf.osrd.envelope.EnvelopeTimeInterpolate; | ||
import fr.sncf.osrd.envelope.Envelope; | ||
import fr.sncf.osrd.envelope.EnvelopeTestUtils; | ||
import fr.sncf.osrd.train.TrainStop; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import java.util.List; | ||
|
||
public class EnvelopeStopWrapperTests { | ||
@Test | ||
public void iteratePointsWithoutStops() { | ||
var envelopeFloor = Envelope.make(EnvelopeTestUtils.generateTimes( | ||
new double[]{0, 1, 2, 3, 4, 5, 6}, | ||
new double[]{1, 1, 1, 1, 1, 1, 1} | ||
)); | ||
var envelopeStopWrapper = new EnvelopeStopWrapper(envelopeFloor, List.of()); | ||
Assertions.assertEquals(List.of( | ||
new EnvelopeTimeInterpolate.EnvelopePoint(0, 1, 0), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(1, 1, 1), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(2, 1, 2), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(3, 1, 3), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(4, 1, 4), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(5, 1, 5), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(6, 1, 6) | ||
), envelopeStopWrapper.iteratePoints()); | ||
} | ||
|
||
@Test | ||
public void iteratePointsWithStops() { | ||
var envelopeFloor = Envelope.make(EnvelopeTestUtils.generateTimes( | ||
new double[]{0, 1, 2, 3, 4, 5, 6}, | ||
new double[]{1, 1, 1, 0, 1, 1, 1} | ||
)); | ||
var envelopeStopWrapper = new EnvelopeStopWrapper(envelopeFloor, List.of( | ||
new TrainStop(1.5, 0), | ||
new TrainStop(3, 10) | ||
)); | ||
Assertions.assertEquals(List.of( | ||
new EnvelopeTimeInterpolate.EnvelopePoint(0, 1, 0), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(1, 1, 1), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(2, 1, 2), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(4, 0, 3), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(6 + 10, 1, 4), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(7 + 10, 1, 5), | ||
new EnvelopeTimeInterpolate.EnvelopePoint(8 + 10, 1, 6) | ||
), envelopeStopWrapper.iteratePoints()); | ||
} | ||
} |