17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-02 22:06:21 +01:00

test: SonarCloud issues of the unit tests

- test::definition_error for unusable test vehicle definitions instead of
  std::runtime_error (S112)
- the rows of a table section written by a function of their own, less
  nesting in definition::text() (S134)
- std::less<> for the section table (S6045)
- comments in the empty methods of the reseeding listener and stub (S1186)
- NOSONAR where the engine's headers fix the stubs: the extern globals
  and the member function signatures (S5421, S5817, S1238)
- NOSONAR on LoadFIZ_Parse(): the cognitive complexity is the former body
  of LoadFIZ(), moved as it was (S3776)
- a comment Sonar took for code reworded (S125)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jerrrrycho
2026-10-15 06:30:31 +02:00
parent 7b77e4cef8
commit 533746324b
5 changed files with 52 additions and 36 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <memory>
#include <stdexcept>
#include <string>
#include <nlohmann/json.hpp>
@@ -9,6 +10,12 @@
namespace test {
// thrown for a test vehicle definition which can't be used: missing, malformed, or not taken by the loader
class definition_error : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
// definition of a test vehicle: one of the JSON files in tests/unit/data, with the sections and keys
// of the game's vehicle definitions, changed by the test where it needs to:
// auto heavy = definition::load("wagon").set("Param", "M", 60000).set("Brake", "BrakeValve", "ESt3");
@@ -53,7 +60,7 @@ public:
// advances the physics by Seconds in steps of Dt
void run(double Seconds, track const &Track = {}, double Dt = 0.01);
// vehicle speed [km/h], signed
// vehicle speed in kilometres per hour, negative when moving backwards
double speed() const { return m_mover->V * 3.6; }
private: