ユニットテストに、最新版のAutotest.mkを反映
[YACASL2.git] / test / unit / n2word / cmd.c
diff --git a/test/unit/n2word/cmd.c b/test/unit/n2word/cmd.c
new file mode 100644 (file)
index 0000000..8d1d04e
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include "casl2.h"
+#include "assemble.h"
+
+int main(){
+    int i;
+    WORD r;
+    char *str[] = {
+        "0", "01", "1a", "-5G", "123", "32767", "32768", "32769",
+        "-1", "-2345", "-32768", "-32769", "-32770"
+    };
+
+    cerr = malloc_chk(sizeof(CERR), "cerr");    /* エラーの初期化 */
+    addcerrlist_word();
+    for(i = 0; i < sizeof(str)/sizeof(str[0]); i++) {
+        cerr->num = 0;
+        r = n2word(str[i]);
+        printf("%s\t0x%04x", str[i], r);
+        if(cerr->num > 0) {
+            printf("\tError - %d\t%s", cerr->num, cerr->msg);
+        }
+        printf("\n");
+    }
+    freecerr();
+    return 0;
+}