mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 06:19:19 +02:00
- 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>
41 lines
1.8 KiB
C++
41 lines
1.8 KiB
C++
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
|
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
|
|
#include "utilities/Globals.h"
|
|
|
|
namespace {
|
|
|
|
// the simulation draws random numbers (brake delays, pressures, wheel damage) from engines shared by
|
|
// everything. reseeding them before every run of a test case, subcases included, gives each test the
|
|
// same numbers whether it runs alone from the IDE or among all the others
|
|
class deterministic_random : public doctest::IReporter {
|
|
public:
|
|
explicit deterministic_random(doctest::ContextOptions const &) {}
|
|
|
|
void test_case_start(doctest::TestCaseData const &) override { reseed(); }
|
|
void test_case_reenter(doctest::TestCaseData const &) override { reseed(); }
|
|
|
|
// the rest of doctest's reporter interface: a listener reports nothing, the console reporter does that
|
|
void report_query(doctest::QueryData const &) override { /* nothing to report */ }
|
|
void test_run_start() override { /* nothing to report */ }
|
|
void test_run_end(doctest::TestRunStats const &) override { /* nothing to report */ }
|
|
void test_case_end(doctest::CurrentTestCaseStats const &) override { /* nothing to report */ }
|
|
void test_case_exception(doctest::TestCaseException const &) override { /* nothing to report */ }
|
|
void subcase_start(doctest::SubcaseSignature const &) override { /* nothing to report */ }
|
|
void subcase_end() override { /* nothing to report */ }
|
|
void log_assert(doctest::AssertData const &) override { /* nothing to report */ }
|
|
void log_message(doctest::MessageData const &) override { /* nothing to report */ }
|
|
void test_case_skipped(doctest::TestCaseData const &) override { /* nothing to report */ }
|
|
|
|
private:
|
|
static void reseed() {
|
|
Global.random_engine.seed(1);
|
|
Global.local_random_engine.seed(1);
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
DOCTEST_REGISTER_LISTENER("deterministic_random", 1, deterministic_random);
|