18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 19:57:06 +01:00

test(editor): a mistyped track fails the self-test, indented comments are skipped, case 7b checks the switch got bent

- A blank line or an indented `#` comment in a script is no longer a command no group takes.
- `trackcant`, `routegauge` and `tracksetdelete` with a track that isn't there count as a failed expectation.
- `expect shaped <switch> <yes|no>`: 7b checks that the gizmo drag bent the switch out of its record before deleting it.
- The ramp-length loop of test_alignment counts in an integer (Sonar S2193).
This commit is contained in:
maj00r
2026-11-24 18:34:25 +01:00
parent fd5bdd7ce4
commit 65e4870318
7 changed files with 59 additions and 6 deletions
+8 -2
View File
@@ -218,6 +218,7 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c
// expect joint <track> <start|end> <gap m> <angle deg> <cant step mm> the end of the first path against the end of another track
// nearest to it within 1 m: the gap, the kink and the step of the cant between them, each at most
// expect records <name> <count> [kind] the records of the switch store of the name, with the connections having the switch among theirs
// expect shaped <switch> <yes|no> the switch keeps the shape its record says, or was bent out of it
// expect speed <track> <km/h> [tolerance], expect gauge <track> <m> [tolerance] as editor_track::velocity gives it / the gauge
// expect track <name> <present|removed>
// expect route <track> <in|out> the track is a part of the line open in the route tool, or not
@@ -240,8 +241,13 @@ void editor_mode::selftest_step()
std::ifstream stream(file);
std::string line;
while (std::getline(stream, line))
if (false == line.empty() && line.front() != '#')
test.lines.push_back(line);
{
// an indented comment or a line of blanks is no command either
auto const first{line.find_first_not_of(" \t\r")};
if (first == std::string::npos || line[first] == '#')
continue;
test.lines.push_back(line.substr(first));
}
WriteLog("SELFTEST: " + std::to_string(test.lines.size()) + " steps from " + file);
}
++editor_selftest::frames();