mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-18 03:19:19 +02:00
fix(ai): release horn when human driver takes over from AI
This commit is contained in:
40
tests/unit/main.cpp
Normal file
40
tests/unit/main.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#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);
|
||||
Reference in New Issue
Block a user