strip_casl2_commentのユニットテストを追加
authorj8takagi <j8takagi@nifty.com>
Sat, 16 Feb 2019 03:01:18 +0000 (12:01 +0900)
committerj8takagi <j8takagi@nifty.com>
Sat, 16 Feb 2019 03:01:18 +0000 (12:01 +0900)
test/unit/strip_casl2_comment/0.txt [new file with mode: 0644]
test/unit/strip_casl2_comment/Makefile [new file with mode: 0644]
test/unit/strip_casl2_comment/cmd.c [new file with mode: 0644]

diff --git a/test/unit/strip_casl2_comment/0.txt b/test/unit/strip_casl2_comment/0.txt
new file mode 100644 (file)
index 0000000..c92a5cd
--- /dev/null
@@ -0,0 +1,6 @@
+        LD      GR1,GR2::
+        LD      GR1,GR2 ::
+        LD      GR1,='#' ::
+        LD      GR1,=';'::
+        LD      GR1,=''';'::
+        LD      GR1,=''';' ::
diff --git a/test/unit/strip_casl2_comment/Makefile b/test/unit/strip_casl2_comment/Makefile
new file mode 100644 (file)
index 0000000..3961b08
--- /dev/null
@@ -0,0 +1,20 @@
+include ../Define.mk
+include ../Test.mk
+
+CC := gcc
+CFLAGS := -Wall -Wextra
+
+.INTERMEDIATE: $(CMD_FILE)
+
+CMDSRC_FILE := cmd.c
+TARGETDIR := ../../../src
+INCLUDEDIR := ../../../include
+TESTTARGET_FILES := $(TARGETDIR)/token.c $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c         # Set test target files
+
+$(CMD_FILE): $(CMDSRC_FILE) $(TESTTARGET_FILES)
+       $(CC) $(CFLAGS) -I $(INCLUDEDIR) -o $@ $^
+
+clean_cmd:
+       @rm -rf cmd.dSYM cmd
+
+clean: clean_cmd
diff --git a/test/unit/strip_casl2_comment/cmd.c b/test/unit/strip_casl2_comment/cmd.c
new file mode 100644 (file)
index 0000000..bd6fdc5
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include "token.h"
+
+int main(){
+    char s[][50] = {
+        "        LD      GR1,GR2",
+        "        LD      GR1,GR2 ; CASL II comment",
+        "        LD      GR1,='#' ; CASL II comment",
+        "        LD      GR1,=';'",
+        "        LD      GR1,=''';'",
+        "        LD      GR1,=''';' ; CASL II comment",
+    };
+
+    for(size_t i = 0; i < sizeof(s) / sizeof(s[0]); i++) {
+        printf("%s::\n", strip_casl2_comment(s[i]));
+    }
+    return 0;
+}