[gamecode] Add tests for lea

This commit is contained in:
Bill Currie 2022-01-15 16:07:11 +09:00
parent fae432f46e
commit 11e89c8c97
2 changed files with 47 additions and 0 deletions

View file

@ -11,6 +11,7 @@ libs_gamecode_tests = \
libs/gamecode/test/test-double \
libs/gamecode/test/test-float \
libs/gamecode/test/test-int \
libs/gamecode/test/test-lea \
libs/gamecode/test/test-load \
libs/gamecode/test/test-long \
libs/gamecode/test/test-mem \
@ -91,6 +92,11 @@ libs_gamecode_test_test_int_SOURCES= \
libs_gamecode_test_test_int_LDADD= $(test_gamecode_libs)
libs_gamecode_test_test_int_DEPENDENCIES= $(test_gamecode_libs)
libs_gamecode_test_test_lea_SOURCES= \
libs/gamecode/test/test-lea.c
libs_gamecode_test_test_lea_LDADD= $(test_gamecode_libs)
libs_gamecode_test_test_lea_DEPENDENCIES= $(test_gamecode_libs)
libs_gamecode_test_test_load_SOURCES= \
libs/gamecode/test/test-load.c
libs_gamecode_test_test_load_LDADD= $(test_gamecode_libs)

View file

@ -0,0 +1,41 @@
#include "head.c"
static pr_int_t lea_globals_init[] = {
// pointers
24, 26, 28, 29,
32, -4, -2, 0,
1, 4, 0xdeadbeef, 0xfeedf00d,
0, 0, 0, 0, 0,
};
static pr_int_t lea_globals_expect[] = {
// pointers
24, 26, 28, 29,
32, -4, -2, 0,
1, 4, 0xdeadbeef, 0xfeedf00d,
7, 29, 34, 26, 88,
};
static dstatement_t lea_statements[] = {
{OP(0, 0, 0, OP_LEA_A), 7, 9, 12},
{OP(0, 0, 0, OP_LEA_B), 3, 8, 13},
{OP(0, 0, 0, OP_LEA_C), 2, 6, 14},
{OP(0, 0, 0, OP_LEA_D), 2, 6, 15},
{OP(0, 0, 0, OP_LEA_E), 4, 2, 16},
};
test_t tests[] = {
{
.desc = "lea",
.num_globals = num_globals (lea_globals_init, lea_globals_expect),
.num_statements = num_statements (lea_statements),
.statements = lea_statements,
.init_globals = lea_globals_init,
.expect_globals = lea_globals_expect,
.edict_area = 28,
},
};
#include "main.c"