Skip to content

Commit

Permalink
fixup! tests: add integration tests for arrival on stop signal
Browse files Browse the repository at this point in the history
  • Loading branch information
woshilapin committed May 30, 2024
1 parent c4f4f8d commit 3ad325e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ package fr.sncf.osrd.stdcm.infra_exploration
import fr.sncf.osrd.api.pathfinding.constraints.ElectrificationConstraints
import fr.sncf.osrd.graph.PathfindingEdgeLocationId
import fr.sncf.osrd.sim_infra.api.BlockId
import fr.sncf.osrd.sim_infra.api.BlockInfra
import fr.sncf.osrd.sim_infra.api.DirDetectorId
import fr.sncf.osrd.sim_infra.utils.getBlockExit
import fr.sncf.osrd.sim_infra.utils.routesOnBlock
import fr.sncf.osrd.train.TestTrains
import fr.sncf.osrd.utils.Direction
import fr.sncf.osrd.utils.DummyInfra
import fr.sncf.osrd.utils.Helpers
import fr.sncf.osrd.utils.units.Offset
import fr.sncf.osrd.utils.units.meters
import fr.sncf.osrd.utils.units.sumOffsets
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotEquals
Expand All @@ -27,13 +30,14 @@ class InfraExplorerTests {
*/
val infra = DummyInfra()
val block = infra.addBlock("a", "b")
val endOffset = infra.getBlockLength(block)

val explorers =
initInfraExplorer(
infra,
infra,
PathfindingEdgeLocationId(block, Offset(0.meters)),
listOf(block)
listOf(setOf(PathfindingEdgeLocationId(block, endOffset)))
)
assertEquals(1, explorers.size)
val explorer = explorers.first()
Expand All @@ -54,14 +58,15 @@ class InfraExplorerTests {
infra.addBlock("c", "d"),
infra.addBlock("d", "e"),
)
val endOffset = blocks.map { infra.getBlockLength(it) }.sumOffsets()

// a --> b
val firstExplorers =
initInfraExplorer(
infra,
infra,
PathfindingEdgeLocationId(blocks[0], Offset(0.meters)),
listOf(blocks.last())
listOf(setOf(PathfindingEdgeLocationId(blocks.last(), endOffset)))
)
assertEquals(1, firstExplorers.size)
var explorer = firstExplorers.first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import fr.sncf.osrd.utils.Direction
import fr.sncf.osrd.utils.Helpers
import fr.sncf.osrd.utils.units.Offset
import fr.sncf.osrd.utils.units.meters
import fr.sncf.osrd.utils.units.sumOffsets
import kotlin.Double.Companion.POSITIVE_INFINITY
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
Expand Down Expand Up @@ -109,11 +110,12 @@ class BlockAvailabilityTests {
assert(nBlocksInPath >= nBlocksSimulated)
assert(nBlocksInPath <= 5)

val endOffset = blocks.map { infra.blockInfra.getBlockLength(it) }.sumOffsets()
var infraExplorer =
initInfraExplorerWithEnvelope(
infra,
PathfindingEdgeLocationId(blocks[0], Offset(0.meters)),
listOf(blocks.last()),
listOf(setOf(PathfindingEdgeLocationId(blocks.last(), endOffset))),
rollingStock
)
.find { filterExplorer(it) }!!
Expand Down Expand Up @@ -583,11 +585,12 @@ class BlockAvailabilityTests {
*/
@Test
fun testNotStartingOnRouteFirstBlock() {
val endOffset = blocks.map { infra.blockInfra.getBlockLength(it) }.sumOffsets()
var explorer =
initInfraExplorerWithEnvelope(
infra,
PathfindingEdgeLocationId(blocks[2], Offset(50.meters)),
listOf(blocks.last()),
listOf(setOf(PathfindingEdgeLocationId(blocks.last(), endOffset))),
REALISTIC_FAST_TRAIN
)
.first { filterExplorer(it) }
Expand Down

0 comments on commit 3ad325e

Please sign in to comment.