From 909af50002c09cf437ef9d3cbe46362e1c6527ad Mon Sep 17 00:00:00 2001 From: j8takagi Date: Tue, 28 Dec 2010 16:01:44 +0900 Subject: [PATCH] =?utf8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86?= =?utf8?q?=E3=82=B9=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- test/unit/getgr/0.txt | 30 ++++++++++++++++++++++++++++++ test/unit/getgr/Makefile | 11 +++++++++++ test/unit/getgr/cmd.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 test/unit/getgr/0.txt create mode 100644 test/unit/getgr/Makefile create mode 100644 test/unit/getgr/cmd.c diff --git a/test/unit/getgr/0.txt b/test/unit/getgr/0.txt new file mode 100644 index 0000000..8b7ead1 --- /dev/null +++ b/test/unit/getgr/0.txt @@ -0,0 +1,30 @@ +== Generel Register == + #FFFF +0 #FFFF +aaa #FFFF +GR #FFFF +GR8 #FFFF +GR20 #FFFF +GR0 #0000 +GR1 #0001 +GR2 #0002 +GR3 #0003 +GR4 #0004 +GR5 #0005 +GR6 #0006 +GR7 #0007 +== Index Register == + #FFFF +0 #FFFF +aaa #FFFF +GR #FFFF +GR8 #FFFF +GR20 #FFFF +GR0 #0000 Error - 120 GR0 in operand x +GR1 #0001 +GR2 #0002 +GR3 #0003 +GR4 #0004 +GR5 #0005 +GR6 #0006 +GR7 #0007 diff --git a/test/unit/getgr/Makefile b/test/unit/getgr/Makefile new file mode 100644 index 0000000..1e7d9a2 --- /dev/null +++ b/test/unit/getgr/Makefile @@ -0,0 +1,11 @@ +include ../Define.mk +include ../Define_test.mk +include ../Test.mk + +.INTERMEDIATE: cmd + +SRCDIR = ../../../src +SRCFILES = $(SRCDIR)/hash.c $(SRCDIR)/cmem.c $(SRCDIR)/cerr.c $(SRCDIR)/cmd.c $(SRCDIR)/assemble.c $(SRCDIR)/word.c $(SRCDIR)/label.c $(SRCDIR)/struct.c $(SRCDIR)/token.c + +cmd: cmd.c $(SRCFILES) + gcc -g -Wall -I ../../../include -o $@ $^ diff --git a/test/unit/getgr/cmd.c b/test/unit/getgr/cmd.c new file mode 100644 index 0000000..bdd89f4 --- /dev/null +++ b/test/unit/getgr/cmd.c @@ -0,0 +1,39 @@ +#include +#include "assemble.h" +#include "cerr.h" + +WORD getgr(const char *str, bool is_x); + +int main(){ + int i, j; + char *title = malloc(64); + WORD r; + bool is_x[] = { + false, true + }; + char *str[] = { + "", "0", "aaa", "GR", "GR8", "GR20", + "GR0", "GR1", "GR2", "GR3", "GR4", "GR5", "GR6", "GR7" + }; + static CERR cerr_getgr[] = { + { 120, "GR0 in operand x" }, + }; + + cerr_init(); /* エラーの初期化 */ + addcerrlist(ARRAYSIZE(cerr_getgr), cerr_getgr); + for(i = 0; i <= 1; i++) { + title = (is_x[i] == false) ? "Generel Register" : "Index Register"; + printf("== %s ==\n", title); + for(j = 0; j < ARRAYSIZE(str); j++) { + cerr->num = 0; + r = getgr(str[j], is_x[i]); + printf("%s\t#%04X", str[j], r); + if(cerr->num > 0) { + printf("\tError - %d\t%s", cerr->num, cerr->msg); + } + printf("\n"); + } + } + freecerr(); + return 0; +} -- 2.18.0