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

+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);
+2 -1
View File
@@ -5,9 +5,10 @@
#include <iostream>
#include <stdexcept>
#include <utility>
#include "testing/check.hpp"
namespace {
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
using bmh::test_support::check;
bmh::GameState fixture(int slot, int age, bool foreign = false) {
bmh::GameState g;
constexpr uint32_t data_begin = 0xa0000;
+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;
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
@@ -10,9 +10,10 @@
#include "game/save.hpp"
#include "game/season.hpp"
#include "game/messages.hpp"
#include "testing/check.hpp"
using namespace bmh;
void check(bool value, const char* text) { if (!value) throw std::runtime_error(text); }
using bmh::test_support::check;
void put(GameState& g, size_t at, uint32_t v) {
for (size_t i=0;i<4;++i)g.manager_records.at(at+i)=uint8_t(v>>(8*i));
}
+2 -3
View File
@@ -8,13 +8,12 @@
#include <chrono>
#include <cstdio>
#include <stdexcept>
#include "testing/check.hpp"
using namespace bmh;
namespace {
void check(bool condition, const char* message) {
if (!condition) throw std::runtime_error(message);
}
using bmh::test_support::check;
struct Snapshot {
Bytes native;
+2 -1
View File
@@ -7,10 +7,11 @@
#include "app/career_session.hpp"
#include "game/save.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;
struct Snapshot {
Bytes native;
+2 -1
View File
@@ -4,9 +4,10 @@
#include "app/career_session.hpp"
#include "game/save.hpp"
#include "ui/sportschau.hpp"
#include "testing/check.hpp"
using namespace bmh;
static void check(bool b,const char* message) {if(!b) throw std::runtime_error(message);}
using bmh::test_support::check;
static void word(Bytes& b,size_t at,uint16_t v) {b.at(at)=uint8_t(v);b.at(at+1)=uint8_t(v>>8);}
static void controlled(const std::filesystem::path& data) {
+2 -1
View File
@@ -5,9 +5,10 @@
#include "game/matchday.hpp"
#include "game/save.hpp"
#include "game/turn.hpp"
#include "testing/check.hpp"
using namespace bmh;
static void check(bool b, const char* message) { if (!b) throw std::runtime_error(message); }
using bmh::test_support::check;
static void put16(Bytes& b,size_t at,uint16_t value) {b.at(at)=uint8_t(value);b.at(at+1)=uint8_t(value>>8);}
static void controlled(const LeImage& exe) {
+2 -1
View File
@@ -6,9 +6,10 @@
#include "game/save.hpp"
#include "ui/live_matchday.hpp"
#include "ui/sportschau.hpp"
#include "testing/check.hpp"
using namespace bmh;
static void check(bool b,const char* message) { if(!b) throw std::runtime_error(message); }
using bmh::test_support::check;
static void same_random(const WatcomRandom& a,const WatcomRandom& b) {
check(a.seed()==b.seed()&&a.calls()==b.calls(),"Source scene draw sequence matches existing animation functions");
}
+2 -1
View File
@@ -4,9 +4,10 @@
#include "app/career_session.hpp"
#include "game/save.hpp"
#include "ui/sportschau.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 void dword(Bytes& b, size_t at, uint32_t v) {
for (size_t i = 0; i < 4; ++i) b.at(at+i) = uint8_t(v >> (8*i));
}
+2 -3
View File
@@ -10,14 +10,13 @@
#include "formats/binary.hpp"
#include "formats/font.hpp"
#include "formats/le.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;
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 -3
View File
@@ -19,13 +19,12 @@
#include "game/schedule.hpp"
#include "ui/settings.hpp"
#include "ui/flow.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;
void start_career(const std::filesystem::path& data,ui::StartupFlow& flow,
std::unique_ptr<app::CareerSession>& session,uint64_t& revision,
+2 -3
View File
@@ -11,14 +11,13 @@
#include <iostream>
#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;
void copy_crop(Image& dst, const Image& src, int sx, int sy, int x, int y, int w, int h) {
for (int row = 0; row < h; ++row) for (int col = 0; col < w; ++col) {
+2 -1
View File
@@ -6,8 +6,9 @@
#include <iostream>
#include <numeric>
#include <stdexcept>
#include "testing/check.hpp"
namespace {
void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}
using bmh::test_support::check;
}
int main()try{
using namespace bmh;
+2 -1
View File
@@ -10,8 +10,9 @@
#include <memory>
#include <stdexcept>
#include <vector>
#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 frame(int width,int height,const std::filesystem::path& output) {
const std::unique_ptr<SDL_Surface,decltype(&SDL_FreeSurface)> surface(
SDL_CreateRGBSurfaceWithFormat(0,width,height,32,SDL_PIXELFORMAT_RGBA32),SDL_FreeSurface);
+2 -1
View File
@@ -11,12 +11,13 @@
#include "game/save.hpp"
#include "game/messages.hpp"
#include "ui/world_cup_statistics.hpp"
#include "testing/check.hpp"
using namespace bmh;
using namespace bmh::ui;
namespace {
void check(bool condition, const char* text) { if (!condition) throw std::runtime_error(text); }
using bmh::test_support::check;
void test_national_friendly_calendar_deadline(const std::filesystem::path& data,const std::filesystem::path& fixture) {
for(int kind=0;kind<3;++kind) {
+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 "ui/team_statistics.hpp"
@@ -14,7 +15,7 @@
#include "ui/setup.hpp"
namespace {
void check(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
using bmh::test_support::check;
uint8_t pixel(const bmh::Image& image, int x, int y) {
return image.pixels.at(size_t(y) * size_t(image.width) + size_t(x));
}
+2 -3
View File
@@ -18,14 +18,13 @@
#include "game/national.hpp"
#include "ui/flow.hpp"
#include "ui/manager.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;
GameState empty_game(std::vector<int> managers = {0}) {
GameState g;
+2 -1
View File
@@ -9,12 +9,13 @@
#include "formats/le.hpp"
#include "game/save.hpp"
#include "ui/flow.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 content_lifecycle(const std::filesystem::path& data) {
const auto exe = load_le(data / "BMH.exe");
+2 -1
View File
@@ -7,12 +7,13 @@
#include "formats/le.hpp"
#include "ui/flow.hpp"
#include "ui/training.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;
TrainingRequest request_for(const TrainingState& state, TrainingRequestKind kind) {
TrainingRequest request;
+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>
@@ -22,7 +23,7 @@
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 Snapshot {
Bytes native; GameRandom game; WatcomRandom rand; uint64_t revision;
Snapshot(app::CareerSession& s,uint64_t rev):native(save_stream(s.state())),game(s.game()),rand(s.rand()),revision(rev){}
+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>
@@ -22,7 +23,7 @@
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 Snapshot {
Bytes native; GameRandom game; WatcomRandom rand; uint64_t revision;
Snapshot(app::CareerSession& s,uint64_t rev):native(save_stream(s.state())),game(s.game()),rand(s.rand()),revision(rev){}
+2 -1
View File
@@ -12,10 +12,11 @@
#include "game/save.hpp"
#include "game/transfer_allocator.hpp"
#include "game/weekly.hpp"
#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;
void write32(std::vector<uint8_t>& bytes, size_t at, uint32_t value) {
for (size_t n = 0; n < 4; ++n) bytes.at(at + n) = uint8_t(value >> (n * 8));
}
+2 -3
View File
@@ -9,13 +9,12 @@
#include "game/schedule.hpp"
#include "game/state.hpp"
#include "game/world_layout.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;
// squad_range as it was written before the world layout existed (state.cpp up to 1.0.12).
SquadRange former_squad_range(int team) {