18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 09:36:48 +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
+21 -1
View File
@@ -186,6 +186,24 @@ void expect_records(std::string const &What, std::istringstream &Words)
expectation(count == wanted, What, std::to_string(count), std::to_string(wanted));
}
// expect shaped <switch> <yes|no>: the switch keeps the shape its record says, or was bent out of it
void expect_shaped(std::string const &What, std::istringstream &Words)
{
std::string name;
std::string wanted;
Words >> name >> wanted;
if (malformed(What, Words))
return;
auto const *track{simulation::Paths.find(name)};
if (track == nullptr || track->m_editorremoved)
{
expectation(false, What, "no track " + name, "a switch");
return;
}
auto const shaped{switch_store::of(*track).has_value()};
expectation(shaped == (wanted == "yes"), What, shaped ? "yes" : "no", wanted);
}
// expect speed <track> <km/h> [tolerance], expect gauge <track> <m> [tolerance]
void expect_track_value(std::string const &What, std::string const &Kind, std::istringstream &Words)
{
@@ -342,6 +360,8 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com
expect_joint(what, words, &editor_mode::cant_of_roll);
else if (kind == "records")
expect_records(what, words);
else if (kind == "shaped")
expect_shaped(what, words);
else if (kind == "speed" || kind == "gauge")
expect_track_value(what, kind, words);
else if (kind == "track")
@@ -355,6 +375,6 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com
else if (kind == "includes")
expect_includes(what, words);
else
expectation(false, what, "no expectation " + kind, "cant, joint, records, speed, gauge, track, route, norms, height, lift or includes");
expectation(false, what, "no expectation " + kind, "cant, joint, records, shaped, speed, gauge, track, route, norms, height, lift or includes");
return selftest_result::handled;
}