@@ -180,7 +180,7 @@ pub fn path_item_respect_margins<T: TrainScheduleLike>(
180180 path_item_time_provisional - prev_path_item_time_provisional;
181181 let margin_diff = interval_duration_final - interval_duration_provisional;
182182
183- res[ path_item_index ] = margin_diff >= -TIME_APPROX_ERROR . num_milliseconds ( ) ;
183+ res[ prev_path_item_index ] = margin_diff >= -TIME_APPROX_ERROR . num_milliseconds ( ) ;
184184 } ) ;
185185
186186 res
@@ -727,18 +727,20 @@ mod tests {
727727 }
728728
729729 fn shallow_sim_too_fast_on_interval ( ) -> SimulationResponseSuccess {
730+ // Too fast from A to B and from D to E
731+ // Respects margins from A to C as B to C compensates A to B, too fast on C to E as not compensated
730732 SimulationResponseSuccess {
731733 base : ReportTrain {
732- path_item_times : vec ! [ 0 , 4_730_243 , 13_828_795 ] ,
734+ path_item_times : vec ! [ 0 , 100_000 , 200_000 , 300_000 , 400_000 ] ,
733735 ..Default :: default ( )
734736 } ,
735737 provisional : ReportTrain {
736- path_item_times : vec ! [ 0 , 5_222_392 , 15_267_584 ] ,
738+ path_item_times : vec ! [ 0 , 100_000 , 200_000 , 300_000 , 400_000 ] ,
737739 ..Default :: default ( )
738740 } ,
739741 final_output : CompleteReportTrain {
740742 report_train : ReportTrain {
741- path_item_times : vec ! [ 0 , 5_280_030 , 15_300_915 ] ,
743+ path_item_times : vec ! [ 0 , 95_000 , 201_000 , 301_000 , 396_000 ] ,
742744 ..Default :: default ( )
743745 } ,
744746 ..Default :: default ( )
@@ -801,7 +803,7 @@ mod tests {
801803 & sim. provisional . path_item_times ,
802804 & schedule,
803805 ) ;
804- assert_eq ! ( * respect, [ true , false , true ] ) ;
806+ assert_eq ! ( * respect, [ false , true , true ] ) ;
805807 }
806808
807809 #[ test]
@@ -813,7 +815,7 @@ mod tests {
813815 & sim. provisional . path_item_times ,
814816 & schedule,
815817 ) ;
816- assert_eq ! ( * respect, [ true , true , false ] ) ;
818+ assert_eq ! ( * respect, [ true , true , false , true , true ] ) ;
817819 }
818820
819821 #[ test]
0 commit comments