エラー処理にリストを使うよう仕様変更
[YACASL2.git] / test / unit / cerrtest / cerrtest.c
1 #include <stdio.h>
2 #include "casl2.h"
3
4 /* エラー番号とエラーメッセージ */
5 static CERRARRAY cerr_utest[] = {
6     { 101, "label already defined" },
7     { 102, "label table is full" },
8     { 103, "label not found" },
9     { 104, "label length is too long" },
10     { 105, "no command in the line" },
11     { 106, "operand count mismatch" },
12     { 107, "no label in START" },
13     { 108, "not command of operand \"r\"" },
14     { 109, "not command of operand \"r1,r2\"" },
15     { 110, "not command of operand \"r,adr[,x]\"" },
16     { 111, "not command of operand \"adr[,x]\"" },
17     { 112, "not command of no operand" },
18     { 113, "command not defined" },
19     { 114, "not integer" },
20     { 115, "not hex" },
21     { 116, "out of hex range" },
22     { 117, "operand is too many" },
23     { 118, "operand length is too long" },
24     { 119, "out of COMET II memory" },
25     { 120, "GR0 in operand x" },
26     { 121, "cannot get operand token" },
27     { 122, "cannot create hash table" },
28     { 123, "unclosed quote" },
29     { 124, "more than one character in literal" },
30     { 125, "not GR in operand x" },
31     { 201, "execute - out of COMET II memory" },
32     { 202, "SVC input - out of Input memory" },
33     { 203, "SVC output - out of COMET II memory" },
34     { 204, "Program Register (PR) - out of COMET II memory" },
35     { 205, "Stack Pointer (SP) - cannot allocate stack buffer" },
36     { 206, "Address - out of COMET II memory" },
37     { 207, "Stack Pointer (SP) - out of COMET II memory" },
38 };
39
40 int main(){
41     int i, j;
42     int code[] = {
43         101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
44         111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
45         121, 122, 123, 124, 201, 202, 203, 204, 205, 206, 207, 999
46     };
47     const char *str[] = {NULL, "foobar"};
48     addcerrlist(ARRAYSIZE(cerr_utest), cerr_utest);
49     for(i = 0; i < ARRAYSIZE(str); i++) {
50         for(j = 0; j < ARRAYSIZE(code); j++) {
51             setcerr(code[j], str[i]);
52             printf("%d: %s - %d\t%s\n", code[j], str[i], cerrno, cerrmsg);
53             if(cerrno != 0) {
54                 freecerr();
55             }
56         }
57     }
58     return 0;
59 }