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