Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test improvements #3408

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/test/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@

enum { BATTLE_TEST_SINGLES, BATTLE_TEST_DOUBLES };

typedef void (*SingleBattleTestFunction)(void *, u32, struct BattlePokemon *, struct BattlePokemon *);
typedef void (*DoubleBattleTestFunction)(void *, u32, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *);
typedef void (*SingleBattleTestFunction)(void *, const u32, struct BattlePokemon *, struct BattlePokemon *);
typedef void (*DoubleBattleTestFunction)(void *, const u32, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *);

struct BattleTest
{
Expand Down Expand Up @@ -660,7 +660,7 @@ extern struct BattleTestRunnerState *gBattleTestRunnerState;

#define SINGLE_BATTLE_TEST(_name, ...) \
struct CAT(Result, __LINE__) { MEMBERS(__VA_ARGS__) }; \
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *, u32, struct BattlePokemon *, struct BattlePokemon *); \
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *, const u32, struct BattlePokemon *, struct BattlePokemon *); \
__attribute__((section(".tests"))) static const struct Test CAT(sTest, __LINE__) = \
{ \
.name = _name, \
Expand All @@ -674,11 +674,11 @@ extern struct BattleTestRunnerState *gBattleTestRunnerState;
.resultsSize = sizeof(struct CAT(Result, __LINE__)), \
}, \
}; \
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *results, u32 i, struct BattlePokemon *player, struct BattlePokemon *opponent)
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *results, const u32 i, struct BattlePokemon *player, struct BattlePokemon *opponent)

#define DOUBLE_BATTLE_TEST(_name, ...) \
struct CAT(Result, __LINE__) { MEMBERS(__VA_ARGS__) }; \
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *, u32, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *); \
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *, const u32, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *, struct BattlePokemon *); \
__attribute__((section(".tests"))) static const struct Test CAT(sTest, __LINE__) = \
{ \
.name = _name, \
Expand All @@ -692,7 +692,7 @@ extern struct BattleTestRunnerState *gBattleTestRunnerState;
.resultsSize = sizeof(struct CAT(Result, __LINE__)), \
}, \
}; \
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *results, u32 i, struct BattlePokemon *playerLeft, struct BattlePokemon *opponentLeft, struct BattlePokemon *playerRight, struct BattlePokemon *opponentRight)
static void CAT(Test, __LINE__)(struct CAT(Result, __LINE__) *results, const u32 i, struct BattlePokemon *playerLeft, struct BattlePokemon *opponentLeft, struct BattlePokemon *playerRight, struct BattlePokemon *opponentRight)

/* Parametrize */

Expand Down
5 changes: 3 additions & 2 deletions test/battle/move_effect/salt_cure.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ ASSUMPTIONS

SINGLE_BATTLE_TEST("Salt Cure inflicts 1/8 of the target's maximum HP as damage per turn")
{
u32 j;
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_SALT_CURE); }
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
TURN {}
} SCENE {
s32 maxHP = GetMonData(&OPPONENT_PARTY[0], MON_DATA_MAX_HP);
ANIMATION(ANIM_TYPE_MOVE, MOVE_SALT_CURE, player);
MESSAGE("Foe Wobbuffet is being salt cured!");
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SALT_CURE_DAMAGE, opponent);
HP_BAR(opponent, damage: maxHP / 8);
MESSAGE("Foe Wobbuffet is hurt by Salt Cure!");
Expand Down
16 changes: 9 additions & 7 deletions test/battle/status1/bad_poison.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@

SINGLE_BATTLE_TEST("Bad poison deals 1/16th cumulative damage per turn")
{
u32 j;
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_TOXIC_POISON); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
TURN {}
} SCENE {
s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP);
for (i = 0; i < 4; i++)
HP_BAR(player, damage: maxHP / 16 * (i + 1));
for (j = 0; j < 4; j++)
HP_BAR(player, damage: maxHP / 16 * (j + 1));
}
}

SINGLE_BATTLE_TEST("Bad poison cumulative damage resets on switch")
{
u32 j;
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_TOXIC_POISON); }
PLAYER(SPECIES_WYNAUT);
Expand All @@ -31,9 +33,9 @@ SINGLE_BATTLE_TEST("Bad poison cumulative damage resets on switch")
TURN {}
} SCENE {
s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP);
for (i = 0; i < 2; i++)
HP_BAR(player, damage: maxHP / 16 * (i + 1));
for (i = 0; i < 2; i++)
HP_BAR(player, damage: maxHP / 16 * (i + 1));
for (j = 0; j < 2; j++)
HP_BAR(player, damage: maxHP / 16 * (j + 1));
for (j = 0; j < 2; j++)
HP_BAR(player, damage: maxHP / 16 * (j + 1));
}
}
5 changes: 3 additions & 2 deletions test/battle/status1/burn.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

SINGLE_BATTLE_TEST("Burn deals 1/16th damage per turn")
{
u32 j;
GIVEN {
ASSUME(B_BURN_DAMAGE >= GEN_LATEST);
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_BURN); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
TURN {}
} SCENE {
s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP);
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
HP_BAR(player, damage: maxHP / 16);
}
}
Expand Down
5 changes: 3 additions & 2 deletions test/battle/status1/poison.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

SINGLE_BATTLE_TEST("Poison deals 1/8th damage per turn")
{
u32 j;
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_POISON); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
TURN {}
} SCENE {
s32 maxHP = GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP);
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
HP_BAR(player, damage: maxHP / 8);
}
}
6 changes: 3 additions & 3 deletions test/battle/status1/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

SINGLE_BATTLE_TEST("Sleep prevents the battler from using a move")
{
u32 turns;
u32 turns, j;
PARAMETRIZE { turns = 1; }
PARAMETRIZE { turns = 2; }
PARAMETRIZE { turns = 3; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_SLEEP_TURN(turns)); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
for (i = 0; i < turns; i++)
for (j = 0; j < turns; j++)
TURN { MOVE(player, MOVE_CELEBRATE); }
} SCENE {
for (i = 0; i < turns - 1; i++)
for (j = 0; j < turns - 1; j++)
MESSAGE("Wobbuffet is fast asleep.");
MESSAGE("Wobbuffet woke up!");
STATUS_ICON(player, none: TRUE);
Expand Down
2 changes: 1 addition & 1 deletion test/test_runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static u32 AssignCostToRunner(void)
u32 minCostProcess;

if (gTestRunnerState.test->runner == &gAssumptionsRunner)
return 0;
return gTestRunnerI;

minCostProcess = MinCostProcess();

Expand Down
Loading