dos-vga-arena-shooter-game/combat_test.c

72 lines
2.0 KiB
C
Raw Normal View History

#include "cutest-1.5/CuTest.h"
#include "combat.h"
#include "game.h"
#include "movement.h"
#include "const.h"
#include "powerup.h"
int processEnemyKillStates(struct EnemyPosition[]);
void TestProcessEmenyKillStates(CuTest *tc) {
struct EnemyPosition enemyPosition[ENEMY_MAX_COUNT];
int i, result;
for (i = 0; i < ENEMY_MAX_COUNT; ++i) {
enemyPosition[i].wasKilled = 0;
}
enemyPosition[0].wasKilled = 1;
enemyPosition[ENEMY_MAX_COUNT - 1].wasKilled = 1;
result = processEnemyKillStates(enemyPosition);
CuAssertIntEquals(tc, 2, result);
}
void TestFireCurrentWeaponOnce_NoRoundsRemaining(CuTest *tc) {
struct RabbitWeaponry rabbitWeaponry;
rabbitWeaponry.currentWeaponRemainingRounds = 0;
rabbitWeaponry.currentWeapon = 99;
fireCurrentWeaponOnce(&rabbitWeaponry);
CuAssertIntEquals(tc, 99, rabbitWeaponry.currentWeapon);
CuAssertIntEquals(tc, 0, rabbitWeaponry.currentWeaponRemainingRounds);
}
void TestFireCurrentWeaponOnce_OneRoundRemaining(CuTest *tc) {
struct RabbitWeaponry rabbitWeaponry;
rabbitWeaponry.currentWeaponRemainingRounds = 1;
rabbitWeaponry.currentWeapon = 99;
fireCurrentWeaponOnce(&rabbitWeaponry);
CuAssertIntEquals(tc, WEAPON_TYPE_SINGLE_SHOT_GUN, rabbitWeaponry.currentWeapon);
CuAssertIntEquals(tc, 0, rabbitWeaponry.currentWeaponRemainingRounds);
}
void TestFireCurrentWeaponOnce_TwoRoundsRemaining(CuTest *tc) {
struct RabbitWeaponry rabbitWeaponry;
rabbitWeaponry.currentWeaponRemainingRounds = 2;
rabbitWeaponry.currentWeapon = 99;
fireCurrentWeaponOnce(&rabbitWeaponry);
CuAssertIntEquals(tc, 99, rabbitWeaponry.currentWeapon);
CuAssertIntEquals(tc, 1, rabbitWeaponry.currentWeaponRemainingRounds);
}
CuSuite *CombatGetSuite() {
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, TestProcessEmenyKillStates);
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_NoRoundsRemaining);
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_OneRoundRemaining);
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_TwoRoundsRemaining);
return suite;
}