Tests share one check helper; stale references in comments corrected

116 test files had their own identical copy of check(bool, const char*); they
use bmh::test_support::check from src/testing/check.hpp. Seven comments pointed
to documents that no longer exist or named a former author.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude committed 2026-11-11 14:52:42 +01:00
1 parent 205a543b40
commit 9870d90d65
123 files changed
+252 -179

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@ constexpr int kHighscorePrefix = 889; // the high score file prefix ("high/h.")
void Console::register_info_commands() {
// --- TopScorers (05-information 7, menu 20) -------------------------------------------
// Codex's read-only port of TopScorersFromGame (game/top_scorers.hpp): the best ten of the own
// The read-only port of TopScorersFromGame (game/top_scorers.hpp): the best ten of the own
// league by goals, assists or both (one point each), for the whole league or only the
// managers' clubs. No state changes and no random draws, so the console reads it directly.
struct ScorerView {
+1 -1
View File
@@ -166,7 +166,7 @@ void Console::register_squad_commands() {
});
// Moving a player, the formations and the automatic weights: the requests the SDL pitch
// screen builds (src/ui/pitch.cpp click / save_formation), dispatched through
// CareerSession::dispatch_pitch (PitchScreen pitch branch, Codex's source port).
// CareerSession::dispatch_pitch (PitchScreen pitch branch, the source port).
auto pitch_context = [this] {
const auto p = prep();
if (!p.pitch || !p.pitch->indoor.has_value()) fail("E_ENGINE_GAP", "no pitch mode projection");
+1 -1
View File
@@ -90,7 +90,7 @@ Json mailbox_record(const ui::MailboxState& m) {
} // namespace
// --- Advice and Scoreboard (for agents that learn: docs/CLI_CONCEPT/16-playbook.md) -------
// --- Advice and Scoreboard (for agents that learn: docs/CLI_CONCEPT/10-agenten-und-tests.md) -------
// Advice names what needs a decision now, from the engine's own data; it judges nothing
// the player could not see on his screens, it only collects it. Scoreboard compares the
// human managers. Both read only.
+1 -1
View File
@@ -642,7 +642,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
if (mem.u8(e + 0x17) != 0 && winners.size() > 1)
mem.set16(cup_entry_address(mem.u8(e + 0x17)) + 0x22, winners[1]);
// (the indoor tournament only: the English League Cup has no Masters; its winner
// would go to EN CupRuntimeField6 for Europe - not ported, see docs/fltd.md)
// would go to EN CupRuntimeField6 for Europe - not ported)
if (type != 0xb || league_system().english_competitions) return;
// the indoor tournament: the four places (CupRuntimeField7 picks them from the list
// champion..fourth) earn points for the Masters (CupRuntimeField8 x strength class
+1 -1
View File
@@ -6,7 +6,7 @@
// M3D.MAN. prepare_english_game() turns an English installation into such a data directory,
// once, in the launcher cache:
// - TEXTE.BLK -> TEXTD.BLK and M3E.MAN -> M3D.MAN (same formats, the text slots are the
// same variables; docs/formats/TEXTD_INVENTORY.md),
// same variables; docs/formats/TEXTD.md),
// - FLTD.EXE -> "BMH.exe" in the OpenBMH image format (formats/le.hpp): an image in the
// German address space. Every German data object the engine reads is filled from its
// English counterpart (src/launch/fltd_map.inc, generated by runtime verification), German
+13
View File
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// The check of the test programs: a failed expectation ends the test with its message (the main
// function of a test prints the message and returns 1). Until 1.0.12 every test file had its own copy.
#include <stdexcept>
namespace bmh::test_support {
inline void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
} // namespace bmh::test_support
+2 -1
View File
@@ -1,5 +1,6 @@
// Tests for the achievements projection and screen (ui/achievements.hpp).
#include "../../tests/test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "ui/achievements.hpp"
@@ -12,7 +13,7 @@
#include "game/messages.hpp"
namespace {
void check(bool ok, const char* why) { if (!ok) throw std::runtime_error(why); }
using bmh::test_support::check;
}
int main(int argc, char** argv) {
+2 -3
View File
@@ -19,14 +19,13 @@
#include "game/state.hpp"
#include "ui/manager.hpp"
#include "ui/setup.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
try { action(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected invalid advertising projection rejection");
+2 -1
View File
@@ -7,8 +7,9 @@
#include "ui/manager.hpp"
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
namespace {
void check(bool ok,const char* why){if(!ok)throw std::runtime_error(why);}
using bmh::test_support::check;
void put16(bmh::Bytes& b,uint32_t base,uint32_t a,uint16_t x){b.at(a-base)=uint8_t(x);b.at(a-base+1)=uint8_t(x>>8);}
void rec(bmh::GameState&g,int team,uint16_t points,uint16_t gf,uint16_t ga,uint16_t w,uint16_t d,uint16_t l){size_t p=size_t(team)*0x4a+0x1e;for(auto [o,v]:{std::pair{0,points},std::pair{2,gf},std::pair{4,ga},std::pair{6,w},std::pair{8,d},std::pair{10,l}}){g.club_table[p+o]=uint8_t(v);g.club_table[p+o+1]=uint8_t(v>>8);}}
}
+2 -1
View File
@@ -1,5 +1,6 @@
// Tests for the analytics projection, toggles and acknowledgement (ui/analytics.hpp).
#include "../../tests/test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "ui/analytics.hpp"
@@ -8,7 +9,7 @@
#include <stdexcept>
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void put32(std::vector<uint8_t>& b, size_t at, uint32_t v) {
for (int i = 0; i < 4; ++i) b.at(at + size_t(i)) = uint8_t(v >> (i * 8));
}
+2 -3
View File
@@ -7,13 +7,12 @@
#include "formats/textd.hpp"
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh::ui;
namespace {
void check(bool value, const char* message) {
if (!value) throw std::runtime_error(message);
}
using bmh::test_support::check;
}
int main(int argc, char** argv) {
+2 -1
View File
@@ -1,5 +1,6 @@
// Tests for the desk state projection, DesktopScreen input and request flow (ui/desktop.hpp, ui/desk_state.hpp).
#include "../../tests/runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "../../tests/test_inputs.hpp"
@@ -31,7 +32,7 @@ using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
static int index = 0; ++index;
try { action(); } catch (const FormatError&) { return; }
+2 -3
View File
@@ -1,5 +1,6 @@
// Tests for the environment view, rendering and requests (ui/environment.hpp).
#include "../../tests/runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "ui/environment.hpp"
@@ -21,9 +22,7 @@ using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
uint8_t pixel(const Image& image, int x, int y) {
return image.pixels.at(size_t(y) * size_t(image.width) + size_t(x));
}
+2 -1
View File
@@ -1,5 +1,6 @@
// Tests for the finance totals projection (ui/finance_totals.hpp).
#include "../../tests/runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "finance_totals.hpp"
@@ -15,7 +16,7 @@
#include "ui/setup.hpp"
namespace {
void check(bool b,const char* what){if(!b)throw std::runtime_error(what);}
using bmh::test_support::check;
uint32_t u32(const std::vector<uint8_t>& b,size_t at){return uint32_t(b.at(at))|uint32_t(b.at(at+1))<<8|uint32_t(b.at(at+2))<<16|uint32_t(b.at(at+3))<<24;}
uint16_t u16(const std::vector<uint8_t>& b,size_t at){return uint16_t(b.at(at))|uint16_t(b.at(at+1))<<8;}
int32_t si32(const std::vector<uint8_t>& b,size_t at){return int32_t(u32(b,at));}
+2 -3
View File
@@ -12,13 +12,12 @@
#include "game/schedule.hpp"
#include "game/state.hpp"
#include "game/messages.hpp"
#include "testing/check.hpp"
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
FriendlyMatchState fixture(const std::filesystem::path& data) {
FriendlyMatchState state;
+2 -3
View File
@@ -17,6 +17,7 @@
#include "ui/desktop.hpp"
#include "ui/manager.hpp"
#include "ui/setup.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
@@ -24,9 +25,7 @@ using namespace bmh::ui;
namespace {
int counted_draws = 0;
void count_draw(int) { ++counted_draws; }
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
try { action(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected rejected league table input");
+2 -1
View File
@@ -16,12 +16,13 @@
#include "game/lineup.hpp"
#include "game/save.hpp"
#include "game/state.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) { if(!ok)throw std::runtime_error(message); }
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
try { action(); } catch(const FormatError&) { return; }
throw std::runtime_error("expected rejected lineup operation");
+2 -1
View File
@@ -10,12 +10,13 @@
#include "game/messages.hpp"
#include "game/state.hpp"
#include "ui/setup.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool value, const char* reason) { if (!value) throw std::runtime_error(reason); }
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
try { action(); } catch (const FormatError&) { return; }
throw std::runtime_error("invalid mailbox screen state was accepted");
+2 -3
View File
@@ -10,14 +10,13 @@
#include "game/messages.hpp"
#include "game/state.hpp"
#include "ui/manager.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
try { action(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected rejected mailbox input");
+2 -3
View File
@@ -5,11 +5,10 @@
#include <numeric>
#include "ui/flow.hpp"
#include "testing/check.hpp"
using namespace bmh::ui;
static void check(bool condition, const char* message) {
if (!condition) throw std::runtime_error(message);
}
using bmh::test_support::check;
int main(int argc, char** argv) {
try {
+2 -1
View File
@@ -18,12 +18,13 @@
#include "game/schedule.hpp"
#include "game/match_engine.hpp"
#include "game/turn_driver.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* why) { if (!ok) throw std::runtime_error(why); }
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
try { action(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected rejected results input");
+2 -1
View File
@@ -1,4 +1,5 @@
#include "../../tests/test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
// Tests for OpportunitiesScreen and StatisticsMenuScreen: mode buttons, rank strip clipping, owner refresh and request guards.
#include "formats/executable_layout.hpp"
@@ -14,7 +15,7 @@ using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok,const char* what){if(!ok)throw std::runtime_error(what);}
using bmh::test_support::check;
OpportunitiesState fixture(){
OpportunitiesState s;s.identity={0,45,17,196,8,12,0};s.mode=1;s.league_size=18;
s.current_rank=3;s.ranks.fill(1);s.ranks[0]=0;s.ranks[2]=0xff;s.underlay=Image(320,240);return s;
+2 -1
View File
@@ -10,11 +10,12 @@
#include "formats/fbm.hpp"
#include "formats/savestate.hpp"
#include "game/state.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
using bmh::test_support::check;
void rejected(const std::function<void()>& fn){try{fn();}catch(const FormatError&){return;}throw std::runtime_error("expected pitch rejection");}
LineupState lineup(){LineupState s;s.manager_slot=0;s.runtime_club=12;s.revision=7;s.source="engine_projection";
s.club_name="UNITFC";s.entry_prepared=true;s.view=LineupView::data_b;
+2 -1
View File
@@ -10,11 +10,12 @@
#include "formats/fbm.hpp"
#include "formats/savestate.hpp"
#include "game/state.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}
using bmh::test_support::check;
void rejected(const std::function<void()>& action){try{action();}catch(const FormatError&){return;}throw std::runtime_error("expected rejected player card");}
GameState fixture(const LeImage& exe) {
GameState g;g.memory.add_block(::bmh::layout::ActiveManager,1);g.memory.add_block(::bmh::layout::CareerSession_AnyOf_ExecutableField,8);g.memory.add_block(::bmh::layout::LeaguePresentationOptions,0xb4);
+2 -1
View File
@@ -8,11 +8,12 @@
#include <functional>
#include <algorithm>
#include <iostream>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
try { action(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected rejected operation");
+2 -3
View File
@@ -8,14 +8,13 @@
#include <iostream>
#include <iterator>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool value, const char* message) {
if (!value) throw std::runtime_error(message);
}
using bmh::test_support::check;
}
int main(int argc, char** argv) {
+2 -3
View File
@@ -1,4 +1,5 @@
#include "../../tests/test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
// Tests for season_entrants_from_game(): footer order, untouched competition pools, and suppression in non-league mode.
#include "formats/executable_layout.hpp"
@@ -12,9 +13,7 @@
#include "ui/manager.hpp"
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
bmh::GameState fixture() {
bmh::GameState g;
+2 -3
View File
@@ -1,4 +1,5 @@
#include "../../tests/runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
// Tests for the settings screen: availability rules, edit requests, sound capabilities and the readme viewer paging.
#include "formats/executable_layout.hpp"
@@ -20,9 +21,7 @@ using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool condition, const char* why) {
if (!condition) throw std::runtime_error(why);
}
using bmh::test_support::check;
}
int main(int argc, char** argv) try {
+2 -3
View File
@@ -9,14 +9,13 @@
#include <stdexcept>
#include "ui/setup.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool condition, const char* message) {
if (!condition) throw std::runtime_error(message);
}
using bmh::test_support::check;
}
int main(int argc, char** argv) {
+2 -3
View File
@@ -1,4 +1,5 @@
#include "../../tests/test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
// Tests for StatisticsRankingsScreen: category selection requests, pressed-state cancel on move-off, and reachability of the oldest archived rows.
#include "formats/executable_layout.hpp"
@@ -13,9 +14,7 @@ using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool condition, const char* message) {
if (!condition) throw std::runtime_error(message);
}
using bmh::test_support::check;
GameState sample() {
GameState game;
+2 -1
View File
@@ -10,11 +10,12 @@
#include "formats/fbm.hpp"
#include "formats/savestate.hpp"
#include "game/state.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void rejected(const std::function<void()>& f) {
try { f(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected FormatError");
+2 -3
View File
@@ -5,14 +5,13 @@
#include <filesystem>
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
TopScorersState state_for(TopScorersMetric metric, TopScorersScope scope) {
TopScorersState state;
+2 -1
View File
@@ -10,12 +10,13 @@
#include <iostream>
#include <functional>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void rejected(const std::function<void()>& fn) {
try { fn(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected rejected operation");
+2 -1
View File
@@ -10,12 +10,13 @@
#include "formats/fbm.hpp"
#include "formats/savestate.hpp"
#include "game/state.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void rejected(const std::function<void()>& fn) {
try { fn(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected rejected operation");
+2 -1
View File
@@ -1,4 +1,5 @@
#include "test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "formats/league_visibility.hpp"
@@ -47,7 +48,7 @@ using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
using bmh::test_support::check;
uint8_t session_runtime_byte(const GameState& state,const std::map<uint32_t,uint8_t>& runtime,uint32_t address) {
if(state.memory.has(address))return state.memory.u8(address);
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "app/career_session.hpp"
@@ -13,7 +14,7 @@
#include <stdexcept>
using namespace bmh;
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void period_one(app::CareerSession& session, const std::filesystem::path& data, uint64_t& revision) {
const auto exe = bmh::test::load_executable(data / "BMH.exe");
+2 -1
View File
@@ -11,10 +11,11 @@
#include "game/balance_plan.hpp"
#include "game/save.hpp"
#include "ui/balance_plan.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace fs=std::filesystem;
static void check(bool value,const char* why){if(!value)throw std::runtime_error(why);}
using bmh::test_support::check;
static void immediate_close(const fs::path& data,const fs::path& save){
app::CareerSession session(data,911,save);uint64_t revision=23;std::string error;
const int manager=session.state().memory.u8(::bmh::layout::ActiveManager);auto& records=session.state().manager_records;
+2 -1
View File
@@ -9,10 +9,11 @@
#include "app/controller.hpp"
#include "game/bank_credit.hpp"
#include "game/save.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
struct TemporarySaves {
std::filesystem::path path = std::filesystem::temp_directory_path() /
+2 -3
View File
@@ -13,14 +13,13 @@
#include <memory>
#include <stdexcept>
#include <utility>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
std::unique_ptr<app::CareerSession> career(const std::filesystem::path& data, int manager_count) {
auto session = std::make_unique<app::CareerSession>(data, uint32_t(0x31415926 + manager_count));
+2 -1
View File
@@ -7,10 +7,11 @@
#include <chrono>
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* why){if(!ok)throw std::runtime_error(why);}
using bmh::test_support::check;
void cash(GameState& state,int manager,int32_t value) {
const size_t at=size_t(manager)*0xb0c+0x314;
for(size_t n=0;n<4;++n)state.manager_records.at(at+n)=uint8_t(uint32_t(value)>>(8*n));
+2 -1
View File
@@ -8,8 +8,9 @@
#include <iostream>
#include <stdexcept>
#include <utility>
#include "testing/check.hpp"
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
using bmh::test_support::check;
bmh::LeImage image(int year,int weekday) {
constexpr uint32_t base=0x10000;
constexpr size_t image_size=0xb0000;
+2 -1
View File
@@ -7,7 +7,8 @@
#include <filesystem>
#include <iostream>
#include <stdexcept>
void check(bool v,const char* m){if(!v)throw std::runtime_error(m);}
#include "testing/check.hpp"
using bmh::test_support::check;
int main()try {
using namespace bmh;
constexpr uint32_t image_base=0x10000;
+2 -1
View File
@@ -3,8 +3,9 @@
#include <stdexcept>
#include "game/club_info.hpp"
#include "game/random.hpp"
#include "testing/check.hpp"
using namespace bmh;
static void check(bool ok,const char* m){if(!ok)throw std::runtime_error(m);}
using bmh::test_support::check;
static GameState fixture(int n){GameState g;g.team_morale.resize(358);for(size_t i=0;i<g.team_morale.size();++i)g.team_morale[i]=uint8_t(i%64);for(int i=0;i<n;++i)g.team_morale[size_t(i)]|=0x80;return g;}
static int category(const GameState& g,int team){return g.team_morale[size_t(team)]>>6;}
int main(){try{
+2 -1
View File
@@ -3,8 +3,9 @@
#include <stdexcept>
#include "game/club_info.hpp"
#include "game/random.hpp"
#include "testing/check.hpp"
using namespace bmh;
static void check(bool ok,const char* m){if(!ok)throw std::runtime_error(m);}
using bmh::test_support::check;
static GameState fixture(int team,int count=20){GameState g;auto r=squad_range(team);g.squad_slots.assign(r.first+r.count,0x0fff);g.players.resize(64);for(int i=0;i<count;++i)g.squad_slots[r.first+size_t(i)]=uint16_t(i|(i<11?0x4000:i<17?0x8000:0x2000));return g;}
int main(){try{
int draws=0;auto prior=draw_hook;draw_hook=+[](int){};
+2 -1
View File
@@ -5,9 +5,10 @@
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
namespace {
void check(bool value, const char* what) { if (!value) throw std::runtime_error(what); }
using bmh::test_support::check;
bmh::ui::ClubInfoProjection projection(bool squad) {
bmh::ui::ClubInfoProjection p;
+2 -1
View File
@@ -6,10 +6,11 @@
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
using bmh::test_support::check;
GameState fixture() {
GameState g;
g.manager_teams = {0}; g.manager_records.resize(5 * 0xb0c); g.tactics.resize(5 * 0x840);
+2 -1
View File
@@ -5,11 +5,12 @@
#include "ui/manager.hpp"
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok,const char* why){if(!ok)throw std::runtime_error(why);}
using bmh::test_support::check;
GameState fixture(const LeImage& exe){
GameState g;g.manager_teams={0};g.manager_records.resize(5*0xb0c);g.manager_options.resize(20);
g.tactics.resize(5*0x840);g.squad_slots.assign(3096,0x0fff);
+2 -1
View File
@@ -9,8 +9,9 @@
#include "ui/sportschau.hpp"
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
void check(bool value,const char* why){if(!value)throw std::runtime_error(why);}
using bmh::test_support::check;
int main(int argc,char**argv){try{
check(argc==3,"winner tests data real-last-league-save");const std::filesystem::path data=argv[1],input=argv[2];
app::CareerSession plain(data,8128,input),observed(data,8128,input);auto& g=observed.state();
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <algorithm>
@@ -21,7 +22,7 @@
using namespace bmh;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
GameState load(const std::filesystem::path& path, const LeImage& exe, const TextDb& texts) {
const auto file=load_savegame(path);
check(file.checksum_ok && file.version=="V2.24", "native fixture checksum/version");
+2 -1
View File
@@ -1,5 +1,6 @@
#include "runtime_fixture_tables.hpp"
#include "test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "ui/cup_draw.hpp"
@@ -20,7 +21,7 @@
#include "ui/manager.hpp"
namespace {
void check(bool ok,const char* what){if(!ok)throw std::runtime_error(what);}
using bmh::test_support::check;
struct Native {
bmh::GameState game; bmh::LeImage exe; bmh::TextDb texts; bmh::Bytes native_stream;
Native(const std::filesystem::path& data,const std::filesystem::path& save)
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <algorithm>
@@ -18,7 +19,7 @@
using namespace bmh;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
GameState load(const std::filesystem::path& path, const LeImage& exe, const TextDb& texts) {
const auto file = load_savegame(path);
+2 -1
View File
@@ -1,4 +1,5 @@
#include "fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <algorithm>
@@ -11,7 +12,7 @@
using namespace bmh;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void entry(GameState& g, int index, int type, uint32_t teams, uint32_t results,
uint8_t flags, uint8_t team_count, uint8_t rounds, uint8_t played,
+2 -1
View File
@@ -4,10 +4,11 @@
#include <iostream>
#include <limits>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
using bmh::test_support::check;
void write(GameState& state,size_t at,int32_t value) {
for(int byte=0;byte<4;++byte)state.manager_records.at(at+byte)=uint8_t(uint32_t(value)>>(byte*8));
}
+2 -1
View File
@@ -10,9 +10,10 @@
#include <fstream>
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
using bmh::test_support::check;
void capture(const std::filesystem::path& dir,const char* name,const Image& image,const Palette& palette){
if(dir.empty())return;
std::filesystem::create_directories(dir);
+2 -1
View File
@@ -4,10 +4,11 @@
#include "ui/live_timing.hpp"
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
GameState fixture() {
GameState g;
g.manager_teams = {0, 1};
+2 -1
View File
@@ -6,10 +6,11 @@
#include <iostream>
#include <set>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
using bmh::test_support::check;
template<class F> void invalid(F action) {
try { action(); } catch (const std::invalid_argument&) { return; }
throw std::runtime_error("malformed fixture input was accepted");
+2 -2
View File
@@ -9,7 +9,7 @@
//
// The data directory is an original installation (supported game edition 2026/27 in development).
// The optional reference directory holds savegames recorded in the running original
// (see docs/REFERENCE.md): SP1VOR.FBM right before and SP2VOR.FBM right after
// (measured in the original): SP1VOR.FBM right before and SP2VOR.FBM right after
// matchday 1. Expected values in these tests were read off the original's screens.
#include <cstdio>
#include <filesystem>
@@ -221,7 +221,7 @@ static void test_schedule(const fs::path& data) {
for (size_t i = 0; i < kResultsSize; i++) CHECK(!decode_result(results[i]).played);
}
// Matchday 1 of the Bundesliga as shown by the original (docs/REFERENCE.md).
// Matchday 1 of the Bundesliga as shown by the original.
static void test_matchday1(const fs::path& refs) {
Savegame s = load_savegame(refs / "SP2VOR.FBM");
CHECK(s.checksum_ok);
+2 -1
View File
@@ -5,11 +5,12 @@
#include <algorithm>
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
size_t colored(const Image& image, uint8_t color) {
return size_t(std::count(image.pixels.begin(),image.pixels.end(),color));
}
+2 -1
View File
@@ -7,12 +7,13 @@
#include "app/career_session.hpp"
#include "game/save.hpp"
#include "testing/check.hpp"
using namespace bmh;
using cli::Json;
using Object = Json::Object;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
Json request(Object fields) { return Json(std::move(fields)); }
bool ok(const Json& response) { return *response.object()->at("ok").boolean(); }
std::string error(const Json& response) {
+2 -1
View File
@@ -7,11 +7,12 @@
#include <functional>
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void rejected(const std::function<void()>& action) {
try { action(); } catch (const FormatError&) { return; }
throw std::runtime_error("expected malformed animation rejection");
+2 -1
View File
@@ -21,11 +21,12 @@
#include "game/save.hpp"
#include "game/weekly.hpp"
#include "ui/pending_offer.hpp"
#include "testing/check.hpp"
namespace fs = std::filesystem;
using namespace bmh;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
uint32_t read32(const Bytes& b, size_t at) {
uint32_t result = 0;
for (size_t i = 0; i < 4; ++i) result |= uint32_t(b.at(at + i)) << (8 * i);
+2 -1
View File
@@ -12,11 +12,12 @@
#include "game/match_engine.hpp"
#include "game/save.hpp"
#include "ui/pending_offer.hpp"
#include "testing/check.hpp"
namespace fs = std::filesystem;
using namespace bmh;
namespace {
void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}
using bmh::test_support::check;
bool contains(const GameState& g,int team,int player){const auto r=squad_range(team);
for(size_t i=r.first;i<r.first+r.count;++i)if((g.squad_slots.at(i)&0xfff)==player)return true;
return false;
+2 -1
View File
@@ -18,6 +18,7 @@
#include "game/prediction.hpp"
#include "game/save.hpp"
#include "game/season.hpp"
#include "testing/check.hpp"
// Private QA composition of format field -> IncomingTransferScreen/ProjectTransferOfferList -> Void2 ->
// SettleHumanBuyerSale -> PendingOfferAnswer -> 42707. No production pending adapter is called.
@@ -428,7 +429,7 @@ using namespace bmh;
namespace {
constexpr uint32_t kOffers=::bmh::layout::OfferSlots, kList=::bmh::layout::EditorList+40*0x58;
constexpr size_t kPool=0xb70+40, kRecord=0xb0c, kBoard=0x840, kBoardSlot=0x58;
void check(bool v,const char* what){if(!v)throw std::runtime_error(what);}
using bmh::test_support::check;
uint32_t read32(const std::vector<uint8_t>& b,size_t at){uint32_t v=0;for(int i=0;i<4;++i)v|=uint32_t(b.at(at+size_t(i)))<<(8*i);return v;}
void write32(std::vector<uint8_t>& b,size_t at,uint32_t v){for(int i=0;i<4;++i)b.at(at+size_t(i))=uint8_t(v>>(i*8));}
bool contains(const GameState& g,int team,int player){const auto r=squad_range(team);for(size_t i=r.first;i<r.first+r.count;++i)if((g.squad_slots.at(i)&0x0fff)==player)return true;return false;}
+2 -1
View File
@@ -1,5 +1,6 @@
#include "runtime_fixture_tables.hpp"
#include "test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <algorithm>
@@ -21,7 +22,7 @@
#include "ui/strengths_state.hpp"
using namespace bmh; namespace fs=std::filesystem;
namespace {
void check(bool b,const char* why){if(!b)throw std::runtime_error(why);}
using bmh::test_support::check;
template<class F> void rejects(F f,const char* why){bool rejected=false;try{f();}catch(const std::exception&){rejected=true;}check(rejected,why);}
struct Oracle {uint32_t w;int32_t g;uint64_t wc,gc;
void stir(){++wc;w=w*0x41c64e6du+0x3039;const int n=int(((w>>16)&32767)*201u/32768)+100;
+2 -1
View File
@@ -10,11 +10,12 @@
#include "formats/le.hpp"
#include "ui/league_family_request.hpp"
#include "ui/league_table.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace fs = std::filesystem;
namespace {
void check(bool ok, const char* why) { if (!ok) throw std::runtime_error(why); }
using bmh::test_support::check;
struct Fixture {
app::CareerSession session;
uint64_t revision = 1;
+2 -3
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "testing/check.hpp"
// Controller/Flow integration coverage for the Source Table UI protocol.
// These tests simulate the SDL host's real-present callback sequence; they are
// not evidence of an actual SDL window run. The separate E37 root QA runner
@@ -23,9 +24,7 @@ using namespace bmh;
namespace fs = std::filesystem;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
struct Context {
fs::path data;
+2 -3
View File
@@ -3,11 +3,10 @@
#include <stdexcept>
#include "game/lineup.hpp"
#include "testing/check.hpp"
namespace {
void check(bool ok, const char* what) {
if (!ok) throw std::runtime_error(what);
}
using bmh::test_support::check;
bmh::GameState fixture(uint8_t style, uint8_t option, bool indoor) {
bmh::GameState g;
+2 -1
View File
@@ -6,9 +6,10 @@
#include "formats/executable_layout.hpp"
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
void enabled(bool value) {
auto exe = bmh::LeImage::from_bytes(bmh::layout::ForeignPlayerLimitEnabled, bmh::Bytes{uint8_t(value)});
bmh::install_lineup_rules(exe);
+2 -3
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <filesystem>
@@ -26,9 +27,7 @@ constexpr uint32_t kManagerPosition = ::bmh::layout::DeskPosition;
constexpr uint32_t kManagerOrder = ::bmh::layout::NextDeskManager;
constexpr uint32_t kOfferWords = ::bmh::layout::OfferSlots;
void check(bool value, const char* message) {
if (!value) throw std::runtime_error(message);
}
using bmh::test_support::check;
GameState load(const std::filesystem::path& path, const LeImage& exe, const TextDb& texts) {
const auto file = load_savegame(path);
+2 -1
View File
@@ -8,9 +8,10 @@
#include "game/matchday.hpp"
#include "game/national.hpp"
#include "game/save.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool yes, const char* why) { if (!yes) throw std::runtime_error(why); }
using bmh::test_support::check;
GameState fixture() {
GameState g; g.season = 0; g.manager_teams = {0};
g.manager_records.resize(5 * 0xb0c); g.tactics.resize(5 * 0x840);
+2 -1
View File
@@ -8,10 +8,11 @@
#include "formats/savestate.hpp"
#include "game/matchday_setup.hpp"
#include "game/save.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok, const char* reason) { if (!ok) throw std::runtime_error(reason); }
using bmh::test_support::check;
void set_f6(app::CareerSession& session, uint64_t& revision, uint8_t value) {
if (session.state().memory.u8(::bmh::layout::MatchdaySetup_MatchdayNeedsManagerDesks_RuntimeField) == value) return;
std::string error;
+2 -1
View File
@@ -5,11 +5,12 @@
#include <stdexcept>
#include "app/controller.hpp"
#include "game/save.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
using bmh::test_support::check;
struct Harness {
std::filesystem::path data, saves;
StartupFlow flow;
+2 -1
View File
@@ -7,9 +7,10 @@
#include "game/season.hpp"
#include "ui/sportschau.hpp"
#include "ui/live_reality.hpp"
#include "testing/check.hpp"
using namespace bmh;
static void check(bool b,const char* why){if(!b)throw std::runtime_error(why);}
using bmh::test_support::check;
static MatchGroup group(uint8_t type,uint32_t id=0){MatchGroup g;g.desc.assign(0xd0,0);g.desc[0]=type;
for(size_t i=0;i<4;++i)g.desc[0xcc+i]=uint8_t(id>>(8*i));return g;}
static void projection_and_pixels(const std::filesystem::path& data,const std::filesystem::path& input) {
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <algorithm>
@@ -19,7 +20,7 @@
using namespace bmh;
namespace {
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
using bmh::test_support::check;
struct Candidate { int player; int score; };
}
int main(int argc,char**argv){try{
+2 -1
View File
@@ -7,9 +7,10 @@
#include "app/career_session.hpp"
#include "game/save.hpp"
#include "national_coach_desk_pending_fixture.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* why){if(!ok)throw std::runtime_error(why);}
using bmh::test_support::check;
auto request(const GameState& g){return PendingOfferDeskRequest{
PendingOfferDeskRuntimeMode::normal_interactive,int(g.manager_teams.size()),int(g.memory.u8(::bmh::layout::DeskPosition))};}
TurnAdvanceResult advance(app::CareerSession& s,uint64_t& revision){
+2 -1
View File
@@ -7,9 +7,10 @@
#include <fstream>
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value,const char* why){if(!value)throw std::runtime_error(why);}
using bmh::test_support::check;
template<class F>void rejects(F function,const char* message){bool rejected=false;try{function();}catch(const FormatError&){rejected=true;}check(rejected,message);}
}
int main()try {
+2 -3
View File
@@ -21,6 +21,7 @@
#include "game/messages.hpp"
#include "ui/flow.hpp"
#include "ui/other_games_state.hpp"
#include "testing/check.hpp"
using namespace bmh;
@@ -29,9 +30,7 @@ uint32_t other_games_source_round_day_for_test(const GameState&,uint32_t,int);
}
namespace {
void check(bool value, const char* message) {
if (!value) throw std::runtime_error(message);
}
using bmh::test_support::check;
void start_career(const std::filesystem::path& data, ui::StartupFlow& flow,
std::unique_ptr<app::CareerSession>& session, uint64_t& revision,
+2 -3
View File
@@ -8,14 +8,13 @@
#include <functional>
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
void rejected(const std::function<void()>& action, const char* message) {
try { action(); } catch (const FormatError&) { return; }
throw std::runtime_error(message);
+2 -1
View File
@@ -8,9 +8,10 @@
#include "game/messages.hpp"
#include "game/save.hpp"
#include "ui/pending_offer.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}
using bmh::test_support::check;
constexpr ClubPlayerDetailSelection selection{33,14,5,5,-1};
struct Snapshot { Bytes native; uint32_t w; int32_t g; uint64_t wc,gc; };
Snapshot snap(app::CareerSession& s){return {save_stream(s.state()),s.rand().seed(),s.game().seed(),s.rand().calls(),s.game().calls()};}
+2 -1
View File
@@ -10,12 +10,13 @@
#include "formats/textd.hpp"
#include "game/pending_offer.hpp"
#include "game/save.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
constexpr uint32_t kOffers=::bmh::layout::OfferSlots, kOrder=::bmh::layout::NextDeskManager, kPosition=::bmh::layout::DeskPosition;
constexpr size_t kPool40=0xb70+40, kClickedBoard=5*0x58;
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
using bmh::test_support::check;
uint32_t read32(const std::vector<uint8_t>& bytes,size_t at){uint32_t v=0;for(int i=0;i<4;++i)v|=uint32_t(bytes.at(at+size_t(i)))<<(8*i);return v;}
PendingOfferDeskRequest request(const GameState& g,int position=0,
PendingOfferDeskRuntimeMode mode=PendingOfferDeskRuntimeMode::normal_interactive){
+2 -1
View File
@@ -15,12 +15,13 @@
#include "game/pending_offer.hpp"
#include "game/save.hpp"
#include "game/season.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
constexpr uint32_t offers=::bmh::layout::OfferSlots, list40=::bmh::layout::EditorList+40*0x58;
constexpr size_t pool40=0xb70+40, board5=5*0x58;
void check(bool v,const char* what){if(!v)throw std::runtime_error(what);}
using bmh::test_support::check;
uint32_t read(const std::vector<uint8_t>& b,size_t at){uint32_t v=0;for(int i=0;i<4;++i)v|=uint32_t(b.at(at+size_t(i)))<<(8*i);return v;}
void write(std::vector<uint8_t>& b,size_t at,uint32_t v){for(int i=0;i<4;++i)b.at(at+size_t(i))=uint8_t(v>>(8*i));}
bool contains(const GameState& g,int team,int player){const auto r=squad_range(team);for(size_t i=r.first;i<r.first+r.count;++i)if((g.squad_slots.at(i)&0xfff)==player)return true;return false;}
+2 -3
View File
@@ -1,5 +1,6 @@
#include "runtime_fixture_tables.hpp"
#include "test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <algorithm>
@@ -20,9 +21,7 @@
using namespace bmh;
namespace {
void check(bool ok, const char* message) {
if (!ok) throw std::runtime_error(message);
}
using bmh::test_support::check;
GameState retained_pending_context(const GameState& game) {
auto national = game;
+2 -3
View File
@@ -9,12 +9,11 @@
#include "game/save.hpp"
#include "ui/league_pairings.hpp"
#include "ui/other_games.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value, const char* message) {
if (!value) throw std::runtime_error(message);
}
using bmh::test_support::check;
uint64_t start(app::CareerSession& session) {
ui::SetupOptions options;
ui::ManagerChoice choice;
+2 -1
View File
@@ -4,10 +4,11 @@
#include "ui/manager.hpp"
#include <iostream>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
static void check(bool ok, const char* why) { if (!ok) throw std::runtime_error(why); }
using bmh::test_support::check;
int main(int argc,char**argv) {try {
if(argc!=2)throw std::runtime_error("data directory required");
const auto exe=load_le(asset_path(argv[1],"BMH.exe"));
+2 -1
View File
@@ -4,9 +4,10 @@
#include <iostream>
#include <stdexcept>
#include <string>
#include "testing/check.hpp"
namespace {
void check(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
using bmh::test_support::check;
void push(Uint32 type) {
SDL_Event event{}; event.type = type;
check(SDL_PushEvent(&event) == 1, "cannot enqueue authored event");
+2 -1
View File
@@ -3,10 +3,11 @@
#include <stdexcept>
#include "game/reality_ball.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* text) { if (!ok) throw std::runtime_error(text); }
using bmh::test_support::check;
GameState state_fixture() {
GameState state;state.players.resize(22);state.player_bonus.resize(22);state.team_morale={24,24};
for (auto& player:state.players) { player.w35c=48u|(100u<<7)|(100u<<14);player.w368=3u|(3u<<4)|(3u<<6); }
+2 -3
View File
@@ -5,12 +5,11 @@
#include "app/career_session.hpp"
#include "game/save.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value, const char* message) {
if (!value) throw std::runtime_error(message);
}
using bmh::test_support::check;
struct Coverage {
int scenes = 0, scene_humans = 0, ordinary_humans = 0, direct_penalties = 0;
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <cstdio>
@@ -9,7 +10,7 @@
#include "game/save.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* text){if(!ok)throw std::runtime_error(text);}
using bmh::test_support::check;
MatchGroup fixture(){MatchGroup g;g.desc.resize(0xd0);g.fixtures={0,1};g.results={0};g.spectators={12000};g.records={70,70,90,90,90,90,80,60,3,70,70,90,90,90,90,80,60,3};return g;}
}
int main(int argc,char** argv){try{
+2 -1
View File
@@ -3,10 +3,11 @@
#include <algorithm>
#include <stdexcept>
#include "game/reality_duel.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* text) { if (!ok) throw std::runtime_error(text); }
using bmh::test_support::check;
GameState state_fixture() {
GameState s;s.players.resize(22);s.player_bonus.resize(22);s.team_morale={24,24};s.squad_slots.resize(48,kEmptySlot);
for (int i=0;i<22;++i) {
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <cstdio>
@@ -13,7 +14,7 @@
using namespace bmh;
namespace {
void check(bool ok,const char* text) { if (!ok) throw std::runtime_error(text); }
using bmh::test_support::check;
MatchGroup fixture() {
MatchGroup g;g.desc.resize(0xd0);g.fixtures={0,1};g.results={0};g.spectators={12000};
g.records={70,70,90,90,90,90,80,60,3,70,70,90,90,90,90,80,60,3};return g;
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <cstdio>
@@ -9,7 +10,7 @@
#include "game/save.hpp"
using namespace bmh;
namespace {
void check(bool value,const char* text) { if (!value) throw std::runtime_error(text); }
using bmh::test_support::check;
MatchGroup fixture() {
MatchGroup g;g.desc.resize(0xd0);g.desc[1]=2;g.desc[2]=1;
g.fixtures={0,1};g.results={0};g.end_minute={0};g.spectators={12000};
+2 -1
View File
@@ -9,10 +9,11 @@
#include "ui/live_reality.hpp"
#include "ui/live_matchday.hpp"
#include "ui/setup.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
using bmh::test_support::check;
template<class F> void rejected(F f) {
bool failed = false; try { f(); } catch (const FormatError&) { failed = true; }
check(failed, "invalid Reality input must fail before drawing");
+2 -1
View File
@@ -3,10 +3,11 @@
#include <stdexcept>
#include "game/reality_movement.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* text) { if (!ok) throw std::runtime_error(text); }
using bmh::test_support::check;
GameState players() {
GameState state;state.players.resize(22);
for (auto& player:state.players) { player.w35c=127u<<14;player.w368=3u<<3; }
+2 -1
View File
@@ -1,4 +1,5 @@
#include "test_inputs.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <cstdio>
@@ -7,7 +8,7 @@
#include "ui/reality_reporter.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* text){if(!ok)throw std::runtime_error(text);}
using bmh::test_support::check;
Image background(){Image image(320,240);for(int y=0;y<240;++y)for(int x=0;x<320;++x)image.at(x,y)=uint8_t((x+3*y)%47);return image;}
}
int main(int argc,char** argv){try{
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <cstdio>
@@ -11,7 +12,7 @@
#include "game/save.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* text){if(!ok)throw std::runtime_error(text);}
using bmh::test_support::check;
// Independent Source cursor interpreter. Unlike the product's parsed tree,
// this walks # delimiters and skips unchosen nested expressions (legacy routine).
size_t skip(std::string_view text,size_t at) {
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <cstdio>
@@ -10,7 +11,7 @@
#include "game/save.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* text){if(!ok)throw std::runtime_error(text);}
using bmh::test_support::check;
GameState fixture(const std::filesystem::path& data,const LeImage& exe,const TextDb& texts) {
const DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField),exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3),exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2),exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
auto state=GameState::from_save(SaveState(load_savegame(data/"AUTOSAVE.FBM").stream,counts),counts);
+2 -1
View File
@@ -3,10 +3,11 @@
#include <stdexcept>
#include "game/reality_setup.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value, const char* text) { if (!value) throw std::runtime_error(text); }
using bmh::test_support::check;
void put16(Bytes& bytes,size_t at,uint16_t value) {
bytes.at(at)=uint8_t(value);bytes.at(at+1)=uint8_t(value>>8);
}
+2 -1
View File
@@ -4,10 +4,11 @@
#include <stdexcept>
#include "game/reality_space.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool value,const char* text) { if (!value) throw std::runtime_error(text); }
using bmh::test_support::check;
void player(RealitySetup& scene,int id,int x,int y) {
check(scene.grid.place(id,x,y,id/11),"fixture player placement");
scene.motion.figures[size_t(id)]={true,x,y,x,y,0};
+2 -1
View File
@@ -1,4 +1,5 @@
#include "runtime_fixture_tables.hpp"
#include "testing/check.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include <algorithm>
@@ -20,7 +21,7 @@
using namespace bmh;
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
GameState load(const std::filesystem::path& path, const LeImage& exe, const TextDb& texts) {
const auto file=load_savegame(path);
check(file.checksum_ok && file.version=="V2.24", "native fixture checksum/version");
+2 -1
View File
@@ -7,9 +7,10 @@
#include "game/month.hpp"
#include "game/save.hpp"
#include "game/turn_driver.hpp"
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool ok,const char* text){if(!ok)throw std::runtime_error(text);}
using bmh::test_support::check;
void install_contract_decisions(app::CareerSession& s){
s.set_contract_expiry_presenter([](GameState& g,WatcomRandom& w,int m,int row){
const auto demands=contract_demands(g,m,row,false,w);
Loaded 100 of 123 files, more files were not shown because too many files have changed in this diff. Show more