Make tests more indipendent from each other
This commit is contained in:
parent
9bb93ff7a0
commit
79893ad462
|
@ -36,6 +36,7 @@ $input_c_files =
|
|||
|
||||
$input_c_test_files =
|
||||
"src/c/tests/main_test.c",
|
||||
"src/c/tests/utils.c",
|
||||
"src/c/tests/battle_test.c",
|
||||
"src/c/tests/debug_printf/test_print.c",
|
||||
"src/c/tests/debug_printf/mgba.c",
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "battle_test.h"
|
||||
#include "utils.h"
|
||||
#include "debug_printf/test_print.h"
|
||||
#include "../locs.h"
|
||||
|
||||
bool text_stayed_inside(WINDOW* window);
|
||||
|
||||
void test_encounter_text()
|
||||
{
|
||||
|
@ -44,7 +42,7 @@ void test_death_text()
|
|||
assert_message(text_stayed_inside(window_pointers[2]), "Death text for Enemy %d", j);
|
||||
}
|
||||
|
||||
m2_btl_user_ptr->letter = 0x17;
|
||||
m2_btl_user_ptr->letter = W_LETTER - INITIAL_SYMBOL_ENEMY;
|
||||
m2_btl_user_ptr->unknown_3[0] = 0;
|
||||
|
||||
for(int j = 0; j <= 230; j++)
|
||||
|
@ -58,38 +56,10 @@ void test_death_text()
|
|||
|
||||
}
|
||||
|
||||
bool text_stayed_inside(WINDOW* window)
|
||||
{
|
||||
for(int i = 0; i < window->window_height; i++)
|
||||
if((*tilemap_pointer)[(0x20*(window->window_y + i))+window->window_x + window->window_width] != RIGHT_BORDER_TILE)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void setup_ness_name()
|
||||
{
|
||||
for(int i = 0; i < 5; i++)
|
||||
*(pc_names + i) = W_LETTER;
|
||||
*(pc_names + 5) = 0;
|
||||
*(pc_names + 6) = 0xFF;
|
||||
}
|
||||
|
||||
void setup_king_name()
|
||||
{
|
||||
for(int i = 0; i < 6; i++)
|
||||
*(pc_names + KING_OFFSET + i) = W_LETTER;
|
||||
*(pc_names + KING_OFFSET + 6) = 0;
|
||||
*(pc_names + KING_OFFSET + 7) = 0xFF;
|
||||
}
|
||||
|
||||
void setup_battle_tests()
|
||||
static void _setup()
|
||||
{
|
||||
(window_pointers[2]) = (struct WINDOW*)0x2029F88;
|
||||
(window_pointers[2])->window_x = 4;
|
||||
(window_pointers[2])->window_y = 1;
|
||||
(window_pointers[2])->window_width = 0x16;
|
||||
(window_pointers[2])->window_height = 4;
|
||||
(window_pointers[2])->window_area = (window_pointers[2])->window_width * (window_pointers[2])->window_height;
|
||||
m2_setupwindow((window_pointers[2]), 4, 1, 0x16, 4);
|
||||
m2_btl_user_ptr = (BATTLE_DATA*)0x2021110;
|
||||
m2_btl_target_ptr = (BATTLE_DATA*)0x2021110;
|
||||
setup_ness_name();
|
||||
|
@ -103,14 +73,8 @@ void setup_battle_tests()
|
|||
m2_script_readability = false;
|
||||
}
|
||||
|
||||
void do_battle_tests()
|
||||
{
|
||||
test_encounter_text();
|
||||
test_death_text();
|
||||
}
|
||||
|
||||
void start_battle_tests()
|
||||
{
|
||||
setup_battle_tests();
|
||||
do_battle_tests();
|
||||
run_test(test_encounter_text);
|
||||
run_test(test_death_text);
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
#include "../battle_data.h"
|
||||
#include "debug_printf/test_print.h"
|
||||
|
||||
#define W_LETTER 0x87
|
||||
#define KING_OFFSET 0x1C
|
||||
#define RIGHT_BORDER_TILE 0x0095
|
||||
#define INITIAL_SYMBOL_ENEMY 0x70
|
||||
|
||||
void start_battle_tests();
|
||||
|
||||
|
|
|
@ -6,20 +6,10 @@ void start_tests()
|
|||
{
|
||||
start_session();
|
||||
|
||||
blank_memory();
|
||||
start_battle_tests();
|
||||
|
||||
blank_memory();
|
||||
|
||||
end_session();
|
||||
|
||||
while(1)
|
||||
vblank();
|
||||
}
|
||||
|
||||
void blank_memory()
|
||||
{
|
||||
int blank_value = 0;
|
||||
cpufastset(&blank_value, (void*)IWRAM, CPUFASTSET_FILL | (IWRAM_SIZE >> 2));
|
||||
reg_ram_reset(NON_IWRAM_RESET);
|
||||
}
|
|
@ -1,14 +1,5 @@
|
|||
#include "debug_printf/test_print.h"
|
||||
|
||||
#define CPUFASTSET_FILL (0x1000000)
|
||||
#define IWRAM (0x3000000)
|
||||
#define IWRAM_SIZE (0x8000-0x2000)
|
||||
|
||||
#define NON_IWRAM_RESET 0xFD
|
||||
|
||||
void start_tests();
|
||||
void blank_memory();
|
||||
|
||||
extern void vblank();
|
||||
extern void cpufastset(void *source, void *dest, int mode);
|
||||
extern void reg_ram_reset(int flag);
|
||||
extern void vblank();
|
|
@ -0,0 +1,44 @@
|
|||
#include "utils.h"
|
||||
|
||||
#define CPUFASTSET_FILL (0x1000000)
|
||||
#define IWRAM (0x3000000)
|
||||
#define IWRAM_SIZE (0x8000-0x2000)
|
||||
|
||||
#define NON_IWRAM_RESET 0xFD
|
||||
|
||||
#define RIGHT_BORDER_TILE 0x0095
|
||||
|
||||
void blank_memory()
|
||||
{
|
||||
int blank_value = 0;
|
||||
cpufastset(&blank_value, (void*)IWRAM, CPUFASTSET_FILL | (IWRAM_SIZE >> 2));
|
||||
reg_ram_reset(NON_IWRAM_RESET);
|
||||
}
|
||||
|
||||
void setup_ness_name()
|
||||
{
|
||||
for(int i = 0; i < 5; i++)
|
||||
*(pc_names + i) = W_LETTER;
|
||||
*(pc_names + 5) = 0;
|
||||
*(pc_names + 6) = 0xFF;
|
||||
}
|
||||
|
||||
void setup_king_name()
|
||||
{
|
||||
for(int i = 0; i < 6; i++)
|
||||
*(pc_names + KING_OFFSET + i) = W_LETTER;
|
||||
*(pc_names + KING_OFFSET + 6) = 0;
|
||||
*(pc_names + KING_OFFSET + 7) = 0xFF;
|
||||
}
|
||||
|
||||
bool text_stayed_inside(WINDOW* window)
|
||||
{
|
||||
if(window->redraw)
|
||||
return true;
|
||||
|
||||
for(int i = 0; i < window->window_height; i++)
|
||||
if((*tilemap_pointer)[(0x20*(window->window_y + i))+window->window_x + window->window_width] != RIGHT_BORDER_TILE)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef TEST_UTILS
|
||||
#define TEST_UTILS
|
||||
|
||||
#include "../window.h"
|
||||
#include "../locs.h"
|
||||
|
||||
#define W_LETTER 0x87
|
||||
#define KING_OFFSET 0x1C
|
||||
|
||||
#define run_test(func) \
|
||||
blank_memory();\
|
||||
_setup();\
|
||||
func();
|
||||
|
||||
void setup_ness_name();
|
||||
void setup_king_name();
|
||||
void blank_memory();
|
||||
bool text_stayed_inside(WINDOW* window);
|
||||
|
||||
extern void cpufastset(void *source, void *dest, int mode);
|
||||
extern void reg_ram_reset(int flag);
|
||||
extern int m2_setupwindow(WINDOW* window, short window_x, short window_y, short window_width, short window_height);
|
||||
|
||||
#endif
|
|
@ -2390,11 +2390,14 @@ disclaimer_map:
|
|||
.definelabel m2_psitargetwindow ,0x80B8AE0
|
||||
.definelabel m2_isequipped ,0x80BC670
|
||||
.definelabel m2_swapwindowbuf ,0x80BD7AC
|
||||
.definelabel m2_setup_window ,0x80BD844
|
||||
.definelabel m2_setup_bg_window ,0x80BD844
|
||||
.definelabel m2_setupwindow ,0x80BE188
|
||||
.definelabel m2_strlookup ,0x80BE260
|
||||
.definelabel m2_initwindow ,0x80BE458
|
||||
.definelabel m2_resetwindow ,0x80BE490
|
||||
.definelabel m2_initwindow_cursor ,0x80BE4C8
|
||||
.definelabel m2_statuswindow_numbers,0x80C0A5C
|
||||
.definelabel m2_menuwindow ,0x80C1C98
|
||||
.definelabel m2_psiwindow ,0x80C1FBC
|
||||
.definelabel m2_drawwindow ,0x80C87D0
|
||||
.definelabel m2_print_window ,0x80C8BE4
|
||||
|
@ -2405,9 +2408,6 @@ disclaimer_map:
|
|||
.definelabel m2_scrolltext ,0x80CA4BC
|
||||
.definelabel m2_formatnumber ,0x80CA65C
|
||||
.definelabel m2_clearwindowtiles ,0x80CA834
|
||||
.definelabel m2_menuwindow ,0x80C1C98
|
||||
.definelabel m2_setupwindow ,0x80BE188
|
||||
.definelabel m2_resetwindow ,0x80BE490
|
||||
.definelabel m2_sub_d3c50 ,0x80D3C50
|
||||
.definelabel m2_hpwindow_up ,0x80D3F0C
|
||||
.definelabel m2_curhpwindow_down ,0x80D41D8
|
||||
|
|
Loading…
Reference in New Issue