From: j8takagi Date: Sat, 13 Feb 2010 16:49:47 +0000 (+0900) Subject: ユニットテストを有効な状態に X-Git-Tag: v0.1~42 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8734038470680c50615c8f71bd4934f44c5f39f6;p=YACASL2.git ユニットテストを有効な状態に --- diff --git a/test/unit/CERRARRAY.c b/test/unit/CERRARRAY.c new file mode 100644 index 0000000..3f3570e --- /dev/null +++ b/test/unit/CERRARRAY.c @@ -0,0 +1,38 @@ +#include "cerr.h" + +/* エラー番号とエラーメッセージ */ +CERRARRAY cerr[] = { + { 101, "label already defined" }, + { 102, "label table is full" }, + { 103, "label not found" }, + { 104, "label length is too long" }, + { 105, "no command in the line" }, + { 106, "operand count mismatch" }, + { 107, "no label in START" }, + { 108, "not command of operand \"r\"" }, + { 109, "not command of operand \"r1,r2\"" }, + { 110, "not command of operand \"r,adr[,x]\"" }, + { 111, "not command of operand \"adr[,x]\"" }, + { 112, "not command of no operand" }, + { 113, "command not defined" }, + { 114, "not integer" }, + { 115, "not hex" }, + { 116, "out of hex range" }, + { 117, "operand is too many" }, + { 118, "operand length is too long" }, + { 119, "out of COMET II memory" }, + { 120, "GR0 in operand x" }, + { 121, "cannot get operand token" }, + { 122, "cannot create hash table" }, + { 123, "unclosed quote" }, + { 124, "more than one character in literal" }, + { 125, "not GR in operand x" }, + { 201, "execute - out of COMET II memory" }, + { 202, "SVC input - out of Input memory" }, + { 203, "SVC output - out of COMET II memory" }, + { 204, "Program Register (PR) - out of COMET II memory" }, + { 205, "Stack Pointer (SP) - cannot allocate stack buffer" }, + { 206, "Address - out of COMET II memory" }, + { 207, "Stack Pointer (SP) - out of COMET II memory" }, + { 0, NULL }, +}; diff --git a/test/unit/TEST.mk b/test/unit/TEST.mk index 4d473e9..4e506fc 100644 --- a/test/unit/TEST.mk +++ b/test/unit/TEST.mk @@ -33,8 +33,8 @@ clean: cleanall: clean @rm -f 0.txt a.out: $(SRC) $(TESTSRCFILE) - @make -C $(SRCDIR) - @gcc $(CFLAGS) $(SRC) $(TESTSRCFILE) + @make -sC $(SRCDIR) + gcc $(CFLAGS) $(SRC) $(TESTSRCFILE) 0.txt 1.txt: a.out @./a.out >$@ 2>&1 diff.txt: 1.txt diff --git a/test/unit/cerrtest/0.txt b/test/unit/cerrtest/0.txt index 0183602..fcbc023 100644 --- a/test/unit/cerrtest/0.txt +++ b/test/unit/cerrtest/0.txt @@ -20,8 +20,8 @@ 120: (null) - 120 GR0 in operand x 121: (null) - 121 cannot get operand token 122: (null) - 122 cannot create hash table -123: (null) - 123 unkown error -124: (null) - 124 unkown error +123: (null) - 123 unclosed quote +124: (null) - 124 more than one character in literal 201: (null) - 201 execute - out of COMET II memory 202: (null) - 202 SVC input - out of Input memory 203: (null) - 203 SVC output - out of COMET II memory @@ -52,8 +52,8 @@ 120: foobar - 120 foobar: GR0 in operand x 121: foobar - 121 foobar: cannot get operand token 122: foobar - 122 foobar: cannot create hash table -123: foobar - 123 foobar: unkown error -124: foobar - 124 foobar: unkown error +123: foobar - 123 foobar: unclosed quote +124: foobar - 124 foobar: more than one character in literal 201: foobar - 201 foobar: execute - out of COMET II memory 202: foobar - 202 foobar: SVC input - out of Input memory 203: foobar - 203 foobar: SVC output - out of COMET II memory diff --git a/test/unit/cerrtest/Makefile b/test/unit/cerrtest/Makefile index 6d8b231..afb6e27 100644 --- a/test/unit/cerrtest/Makefile +++ b/test/unit/cerrtest/Makefile @@ -1,3 +1,3 @@ UCLASS = COMMON -TESTSRCFILE = cerrtest.c +TESTSRCFILE = ../CERRARRAY.c cerrtest.c include ../TEST.mk diff --git a/test/unit/getcmdcode/Makefile b/test/unit/getcmdcode/Makefile index ab85bfa..3c9287a 100644 --- a/test/unit/getcmdcode/Makefile +++ b/test/unit/getcmdcode/Makefile @@ -1,3 +1,3 @@ UCLASS = COMMON -TESTSRCFILE = getcmdcode.c +TESTSRCFILE = ../CERRARRAY.c getcmdcode.c include ../TEST.mk diff --git a/test/unit/getcmdtype/Makefile b/test/unit/getcmdtype/Makefile index ce4bf22..9bbc2ae 100644 --- a/test/unit/getcmdtype/Makefile +++ b/test/unit/getcmdtype/Makefile @@ -1,3 +1,3 @@ UCLASS = COMMON -TESTSRCFILE = getcmdtype.c +TESTSRCFILE = ../CERRARRAY.c getcmdtype.c include ../TEST.mk diff --git a/test/unit/getgr/Makefile b/test/unit/getgr/Makefile index 32db8d8..9ae5e12 100644 --- a/test/unit/getgr/Makefile +++ b/test/unit/getgr/Makefile @@ -1,3 +1,3 @@ UCLASS = AS -TESTSRCFILE = getgr.c +TESTSRCFILE = ../CERRARRAY.c getgr.c include ../TEST.mk diff --git a/test/unit/getgr/getgr.c b/test/unit/getgr/getgr.c index fe6ac18..e342501 100644 --- a/test/unit/getgr/getgr.c +++ b/test/unit/getgr/getgr.c @@ -15,7 +15,7 @@ int main(){ for(i = 0; i <= 1; i++) { title = (is_x[i] == false) ? "Generel Register" : "Index Register"; printf("== %s ==\n", title); - for(j = 0; j < sizeof(str)/sizeof(str[0]); j++) { + for(j = 0; j < ARRAYSIZE(str); j++) { r = getgr(str[j], is_x[i]); printf("%s\t#%04X", str[j], r); if(cerrno > 0) { diff --git a/test/unit/h2word/Makefile b/test/unit/h2word/Makefile index 3990009..a04ab54 100644 --- a/test/unit/h2word/Makefile +++ b/test/unit/h2word/Makefile @@ -1,3 +1,3 @@ UCLASS = AS -TESTSRCFILE = gethex.c +TESTSRCFILE = ../CERRARRAY.c h2word.c include ../TEST.mk diff --git a/test/unit/h2word/gethex.c b/test/unit/h2word/h2word.c similarity index 100% rename from test/unit/h2word/gethex.c rename to test/unit/h2word/h2word.c diff --git a/test/unit/hash/0.txt b/test/unit/hash/0.txt index 66daee2..f21e3f4 100644 --- a/test/unit/hash/0.txt +++ b/test/unit/hash/0.txt @@ -1,3 +1,3 @@ HASH VALUE: 20 HASH VALUE: 11 -HASH VALUE: 21 +HASH VALUE: 1 diff --git a/test/unit/hash/Makefile b/test/unit/hash/Makefile index 4a129e1..3a6807e 100644 --- a/test/unit/hash/Makefile +++ b/test/unit/hash/Makefile @@ -1,3 +1,3 @@ UCLASS = COMMON -TESTSRCFILE = hash.c +TESTSRCFILE = ../CERRARRAY.c hash.c include ../TEST.mk diff --git a/test/unit/linetok/Makefile b/test/unit/linetok/Makefile index e24b848..f38bdf0 100644 --- a/test/unit/linetok/Makefile +++ b/test/unit/linetok/Makefile @@ -1,3 +1,3 @@ UCLASS = AS -TESTSRCFILE = linetok.c +TESTSRCFILE = ../CERRARRAY.c linetok.c include ../TEST.mk diff --git a/test/unit/n2word/Makefile b/test/unit/n2word/Makefile index 80734e7..5d07682 100644 --- a/test/unit/n2word/Makefile +++ b/test/unit/n2word/Makefile @@ -1,3 +1,3 @@ UCLASS = AS -TESTSRCFILE = getint.c +TESTSRCFILE = ../CERRARRAY.c getint.c include ../TEST.mk diff --git a/test/unit/opdtok/0.txt b/test/unit/opdtok/0.txt index 7bb505e..6930eb2 100644 --- a/test/unit/opdtok/0.txt +++ b/test/unit/opdtok/0.txt @@ -1,5 +1,6 @@ OPDC:0 +Error - 121: cannot get operand token GR0,GR1 OPDC:2 @@ -133,5 +134,5 @@ OPDC[0]:'1234567890123456789012345678901234567890' '12345678901234567890123456789012345678901' OPDC:0 -Error - 118: '12345678901234567890123456789012345678901': operand length is too long +Error - 118: operand length is too long diff --git a/test/unit/opdtok/Makefile b/test/unit/opdtok/Makefile index 5225297..2b496bf 100644 --- a/test/unit/opdtok/Makefile +++ b/test/unit/opdtok/Makefile @@ -1,3 +1,3 @@ UCLASS = AS -TESTSRCFILE = opdtok.c +TESTSRCFILE = ../CERRARRAY.c opdtok.c include ../TEST.mk diff --git a/test/unit/print_cmdtype_code/Makefile b/test/unit/print_cmdtype_code/Makefile index 4687747..2b1571f 100644 --- a/test/unit/print_cmdtype_code/Makefile +++ b/test/unit/print_cmdtype_code/Makefile @@ -1,3 +1,3 @@ -TESTSRCFILE = print_cmdtype_code.c UCLASS = COMMON +TESTSRCFILE = ../CERRARRAY.c print_cmdtype_code.c include ../TEST.mk diff --git a/test/unit/print_cmdtype_code/print_cmdtype_code.c b/test/unit/print_cmdtype_code/print_cmdtype_code.c index 35dba2c..9410051 100644 --- a/test/unit/print_cmdtype_code/print_cmdtype_code.c +++ b/test/unit/print_cmdtype_code/print_cmdtype_code.c @@ -11,39 +11,3 @@ int main(){ } return 0; } - -/* エラー番号とエラーメッセージ */ -CERRARRAY cerr[] = { - { 101, "label already defined" }, - { 102, "label table is full" }, - { 103, "label not found" }, - { 104, "label length is too long" }, - { 105, "no command in the line" }, - { 106, "operand count mismatch" }, - { 107, "no label in START" }, - { 108, "not command of operand \"r\"" }, - { 109, "not command of operand \"r1,r2\"" }, - { 110, "not command of operand \"r,adr[,x]\"" }, - { 111, "not command of operand \"adr[,x]\"" }, - { 112, "not command of no operand" }, - { 113, "command not defined" }, - { 114, "not integer" }, - { 115, "not hex" }, - { 116, "out of hex range" }, - { 117, "operand is too many" }, - { 118, "operand length is too long" }, - { 119, "out of COMET II memory" }, - { 120, "GR0 in operand x" }, - { 121, "cannot get operand token" }, - { 122, "cannot create hash table" }, - { 123, "illegal string" }, - { 124, "more than one character in literal" }, - { 201, "execute - out of COMET II memory" }, - { 202, "SVC input - out of Input memory" }, - { 203, "SVC output - out of COMET II memory" }, - { 204, "Program Register (PR) - out of COMET II memory" }, - { 205, "Stack Pointer (SP) - cannot allocate stack buffer" }, - { 206, "Address - out of COMET II memory" }, - { 207, "Stack Pointer (SP) - out of COMET II memory" }, - { 0, NULL }, -}; diff --git a/test/unit/print_code_type/Makefile b/test/unit/print_code_type/Makefile index 57c87c3..17eb22a 100644 --- a/test/unit/print_code_type/Makefile +++ b/test/unit/print_code_type/Makefile @@ -1,3 +1,3 @@ UCLASS = COMMON -TESTSRCFILE = print_code_type.c +TESTSRCFILE = ../CERRARRAY.c print_code_type.c include ../TEST.mk diff --git a/test/unit/print_code_type/print_code_type.c b/test/unit/print_code_type/print_code_type.c index 7a925ff..9635beb 100644 --- a/test/unit/print_code_type/print_code_type.c +++ b/test/unit/print_code_type/print_code_type.c @@ -14,39 +14,3 @@ int main() } return 0; } - -/* エラー番号とエラーメッセージ */ -CERRARRAY cerr[] = { - { 101, "label already defined" }, - { 102, "label table is full" }, - { 103, "label not found" }, - { 104, "label length is too long" }, - { 105, "no command in the line" }, - { 106, "operand count mismatch" }, - { 107, "no label in START" }, - { 108, "not command of operand \"r\"" }, - { 109, "not command of operand \"r1,r2\"" }, - { 110, "not command of operand \"r,adr[,x]\"" }, - { 111, "not command of operand \"adr[,x]\"" }, - { 112, "not command of no operand" }, - { 113, "command not defined" }, - { 114, "not integer" }, - { 115, "not hex" }, - { 116, "out of hex range" }, - { 117, "operand is too many" }, - { 118, "operand length is too long" }, - { 119, "out of COMET II memory" }, - { 120, "GR0 in operand x" }, - { 121, "cannot get operand token" }, - { 122, "cannot create hash table" }, - { 123, "illegal string" }, - { 124, "more than one character in literal" }, - { 201, "execute - out of COMET II memory" }, - { 202, "SVC input - out of Input memory" }, - { 203, "SVC output - out of COMET II memory" }, - { 204, "Program Register (PR) - out of COMET II memory" }, - { 205, "Stack Pointer (SP) - cannot allocate stack buffer" }, - { 206, "Address - out of COMET II memory" }, - { 207, "Stack Pointer (SP) - out of COMET II memory" }, - { 0, NULL }, -};