From 9fa6cd6a4cd10fb370c489959d7fa2e3317bb755 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sat, 25 Oct 2025 14:38:58 +0200 Subject: [PATCH] Add test to detect save file shifting (#8030) --- test/save.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/save.c diff --git a/test/save.c b/test/save.c new file mode 100644 index 0000000000..4e3000a794 --- /dev/null +++ b/test/save.c @@ -0,0 +1,35 @@ +#include "global.h" +#include "pokemon_storage_system.h" +#include "test/test.h" + +// If you would like to ensure save compatibility, update the values below with those for your hack. You can find these through the debug menu. +// Please note that this simple check is not 100% foolproof, but should be able to catch most unintended shifts. +#define T_SAVEBLOCK1_SIZE 15568 +#define T_SAVEBLOCK2_SIZE 3884 +#define T_SAVEBLOCK3_SIZE 4 +#define T_POKEMONSTORAGE_SIZE 34144 + +TEST("SaveBlock1 is backwards compatible") +{ + EXPECT_EQ(sizeof(struct SaveBlock1), T_SAVEBLOCK1_SIZE); +} + +TEST("SaveBlock2 is backwards compatible") +{ + EXPECT_EQ(sizeof(struct SaveBlock2), T_SAVEBLOCK2_SIZE); +} + +TEST("SaveBlock3 is backwards compatible") +{ + EXPECT_EQ(sizeof(struct SaveBlock3), T_SAVEBLOCK3_SIZE); +} + +TEST("PokemonStorage is backwards compatible") +{ + EXPECT_EQ(sizeof(struct PokemonStorage), T_POKEMONSTORAGE_SIZE); +} + +#undef T_SAVEBLOCK1_SIZE +#undef T_SAVEBLOCK2_SIZE +#undef T_SAVEBLOCK3_SIZE +#undef T_POKEMONSTORAGE_SIZE