ユニットテストをに、最新のAutotest.mkを反映
[YACASL2.git] / test / unit / linetok / cmd.c
1 #include <stdio.h>
2 #include "assemble.h"
3 #include "cmem.h"
4 #include "cerr.h"
5 #include "word.h"
6
7 int main(){
8     int i, j;
9     char *testline[] = {
10         "IOTEST START\n",
11         "       OUT OBUF1,OLEN1\n",
12         "       OUT OBUF2,OLEN2 ;comment\n",
13         "       OUT OBUF1,OLEN1 \n",
14         "       OUT OBUF1,OLEN1 \n",
15         "       OUT OBUF2,OLEN2 \n",
16         "       OUT OBUF1, OLEN1 \n",
17         "BEGIN  LD      GR1, A\n",
18         "\n",
19         "       ;comment\n"
20     };
21
22     CMDLINE *testcl = malloc(sizeof(CMDLINE));
23     cerr_init();    /* エラーの初期化 */
24     addcerrlist_tok();
25     for(i = 0; i < sizeof testline /sizeof testline[0]; i++) {
26         printf("%d: %s", i, testline[i]);
27         testcl = linetok(testline[i]);
28         if(testcl == NULL) {
29             puts("cl is NULL");
30         } else {
31             if(testcl->label != NULL){
32                 printf("cl->label: %s\n", testcl->label);
33             }
34             if(testcl->cmd != NULL){
35                 printf("cl->cmd: %s\n", testcl->cmd);
36                 printf("cl->opdc: %d\n", testcl->opd->opdc);
37                 for(j = 0; j < testcl->opd->opdc; j++) {
38                     printf("cl->opdv[%d]: %s\n", j, testcl->opd->opdv[j]);
39                 }
40             }
41         }
42         if(cerr->num != 0) {
43             printf("\terror - %d: %s\n", cerr->num, cerr->msg);
44         }
45         printf("\n");
46     }
47     freecerr();
48     return 0;
49 }