diff --git a/core/src/test/kotlin/fr/sncf/osrd/stdcm/infra_exploration/InfraExplorerTests.kt b/core/src/test/kotlin/fr/sncf/osrd/stdcm/infra_exploration/InfraExplorerTests.kt index 73d8d24f102..f2f17b64e50 100644 --- a/core/src/test/kotlin/fr/sncf/osrd/stdcm/infra_exploration/InfraExplorerTests.kt +++ b/core/src/test/kotlin/fr/sncf/osrd/stdcm/infra_exploration/InfraExplorerTests.kt @@ -3,7 +3,9 @@ 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 @@ -11,6 +13,7 @@ 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 @@ -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() @@ -54,6 +58,7 @@ class InfraExplorerTests { infra.addBlock("c", "d"), infra.addBlock("d", "e"), ) + val endOffset = blocks.map { infra.getBlockLength(it) }.sumOffsets() // a --> b val firstExplorers = @@ -61,7 +66,7 @@ class InfraExplorerTests { 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() diff --git a/core/src/test/kotlin/fr/sncf/osrd/stdcm/preprocessing/BlockAvailabilityTests.kt b/core/src/test/kotlin/fr/sncf/osrd/stdcm/preprocessing/BlockAvailabilityTests.kt index 6f7efaab8e4..da208ebbd0b 100644 --- a/core/src/test/kotlin/fr/sncf/osrd/stdcm/preprocessing/BlockAvailabilityTests.kt +++ b/core/src/test/kotlin/fr/sncf/osrd/stdcm/preprocessing/BlockAvailabilityTests.kt @@ -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 @@ -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) }!! @@ -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) }