18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-27 21:45:16 +01:00
Files
maszyna/tests/unit/test_timetable_start.cpp
jerrrrycho 2f12768815 fix(timetable): the station of departure written in capitals is still a stop (#343)
The first row of a timetable, which usually gives only the departure time,
became a stop only when its name matched the relation's first station
case-sensitively. Os33733 of linia_107_poludnie.scn writes ZAGORZ in the rows
and Zagorz in the relation, so its driver counted Zagorz as passed at the
start, left before its departure time and the train manager never gave the
departure signal. The names are now compared regardless of case
(timetable::starts_at in the core library).

Tests: unit test of the rule; td.scn scenario cases with a timetable of the
case's own (first row STACJA1, and Stacja1 as control) and the td.scn train
started with its head 80 m past the W4 of Stacja1; the scenario runner can
copy a timetable of the case into the game for the run.
2026-11-20 16:35:59 +01:00

40 lines
2.0 KiB
C++

#include "stdafx.h"
#include "doctest.h"
#include "world/timetablestart.h"
// the first row of a timetable is the station of departure, a stop the train waits at for its departure time,
// when it names the station the relation starts at. the loader then takes the departure time for the arrival
// one, which the row usually leaves out; a row without an arrival time is otherwise a station passed through
TEST_CASE("timetable: the first row naming the station of the relation is the station of departure") {
CHECK(timetable::starts_at("Stacja1", "Stacja1"));
CHECK(timetable::starts_at("Zagorz", "Zagorz"));
}
TEST_CASE("timetable: the station of departure written in capitals in the rows is still the one of the relation") {
// linia_107_poludnie.scn, Os33733: ZAGORZ in the rows, Zagorz in the relation (both with the polish letters
// stripped by the loader). taken for a station passed through, the AI left before its departure time and the
// train manager never gave the departure signal
CHECK(timetable::starts_at("ZAGORZ", "Zagorz"));
CHECK(timetable::starts_at("LEOSIN", "Leosin"));
CHECK(timetable::starts_at("Warszawa_Wschodnia", "WARSZAWA_WSCHODNIA"));
}
TEST_CASE("timetable: a first row naming another station is not the station of departure") {
// a timetable which starts on the way, at a station the train passes through
CHECK_FALSE(timetable::starts_at("Tarnawa_Dolna", "Zagorz"));
CHECK_FALSE(timetable::starts_at("Nowy_Zagorz", "Zagorz"));
CHECK_FALSE(timetable::starts_at("Zagorz", "Nowy_Zagorz"));
// a name which only begins like the other one
CHECK_FALSE(timetable::starts_at("Zagorz_Towarowy", "Zagorz"));
CHECK_FALSE(timetable::starts_at("Zagorz", "Zagorz_Towarowy"));
}
TEST_CASE("timetable: the station names are compared as a whole, letters and the rest") {
CHECK_FALSE(timetable::starts_at("Stacja1", "Stacja2"));
CHECK_FALSE(timetable::starts_at("Stacja_1", "Stacja-1"));
CHECK_FALSE(timetable::starts_at("Stacja1", ""));
CHECK_FALSE(timetable::starts_at("", "Stacja1"));
}