From 7cd398d4a752ee953aee56318cfd9a11522db88d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 15 Jan 2022 13:20:33 +0900 Subject: [PATCH] [gamecodee] Add tests for move and memset --- libs/gamecode/test/Makemodule.am | 6 ++++ libs/gamecode/test/test-mem.c | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 libs/gamecode/test/test-mem.c diff --git a/libs/gamecode/test/Makemodule.am b/libs/gamecode/test/Makemodule.am index ba3bc174a..58552d1b9 100644 --- a/libs/gamecode/test/Makemodule.am +++ b/libs/gamecode/test/Makemodule.am @@ -12,6 +12,7 @@ libs_gamecode_tests = \ libs/gamecode/test/test-int \ libs/gamecode/test/test-load \ libs/gamecode/test/test-long \ + libs/gamecode/test/test-mem \ libs/gamecode/test/test-scale \ libs/gamecode/test/test-stack \ libs/gamecode/test/test-store \ @@ -94,6 +95,11 @@ libs_gamecode_test_test_long_SOURCES= \ libs_gamecode_test_test_long_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_long_DEPENDENCIES= $(test_gamecode_libs) +libs_gamecode_test_test_mem_SOURCES= \ + libs/gamecode/test/test-mem.c +libs_gamecode_test_test_mem_LDADD= $(test_gamecode_libs) +libs_gamecode_test_test_mem_DEPENDENCIES= $(test_gamecode_libs) + libs_gamecode_test_test_scale_SOURCES= \ libs/gamecode/test/test-scale.c libs_gamecode_test_test_scale_LDADD= $(test_gamecode_libs) diff --git a/libs/gamecode/test/test-mem.c b/libs/gamecode/test/test-mem.c new file mode 100644 index 000000000..1bba532e8 --- /dev/null +++ b/libs/gamecode/test/test-mem.c @@ -0,0 +1,51 @@ +#include "head.c" + +#define DB 0xdeadbeef + +static pr_int_t mem_globals_init[] = { + 0, 8, 68, 9, 80, 112, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, + 0, 0, 68, 6, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 + + DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, + DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, + DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, + DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, + DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, + DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, +}; + +static pr_int_t mem_globals_expect[] = { + 0, 8, 68, 9, 80, 112, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, // 0 + 0, 0, 68, 6, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 + + DB, 0, 0, 0, 0, 0, DB, DB, 9, 9, DB, DB, DB, DB, DB, DB, // 32 + 1, 2, 3, 4, 5, 6, 7, 8, DB, DB, DB, DB, 5, 6, 7, 8, // 48 + DB, DB, DB, DB, 1, 2, 1, 2, 3, 4, 5, 6, DB, DB, DB, DB, // 64 + 68, 68, 68, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, // 80 + DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, // 96 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, DB, // 112 +}; + +static dstatement_t mem_statements[] = { + {OP(0, 0, 0, OP_MEMSET_I), 0, 5, 33}, + {OP(0, 0, 0, OP_MEMSET_I), 3, 2, 40}, + {OP(0, 0, 0, OP_MOVE_I), 8, 8, 48}, + {OP(0, 0, 0, OP_MOVE_I), 12, 4, 60}, + {OP(0, 0, 0, OP_MOVE_PI), 1, 8, 2}, + {OP(0, 0, 0, OP_MEMSET_P), 2, 10, 4}, + {OP(0, 0, 0, OP_MEMSET_PI), 1, 15, 5}, + {OP(0, 0, 0, OP_MOVE_P), 18, 19, 20}, +}; + +test_t tests[] = { + { + .desc = "mem", + .num_globals = num_globals (mem_globals_init, mem_globals_expect), + .num_statements = num_statements (mem_statements), + .statements = mem_statements, + .init_globals = mem_globals_init, + .expect_globals = mem_globals_expect, + }, +}; + +#include "main.c"