aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--test-convert-markdown.c17
2 files changed, 13 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 1bc340d..870970d 100644
--- a/Makefile
+++ b/Makefile
@@ -13,13 +13,13 @@ convert-markdown: $(OBJS)
$(OBJS): config.h
clean:
- rm -f convert-markdown $(OBJS) test-convert-markdown
+ rm -f convert-markdown $(OBJS) test-convert-markdown $(TESTOBJS)
distclean: clean
rm -f Makefile.configure config.h config.log config.h.old config.log.old
check: tests
- @echo "# header" | ./test-convert-markdown
+ @./test-convert-markdown
tests: test-convert-markdown
diff --git a/test-convert-markdown.c b/test-convert-markdown.c
index 403a68a..09a3d18 100644
--- a/test-convert-markdown.c
+++ b/test-convert-markdown.c
@@ -20,14 +20,19 @@ static int test_parse_file(const char* testname, const char* input, const char*
FILE* instream = tmpfile();
FILE* outstream = tmpfile();
- /* for some reason, input isn't properly written to instream */
- fprintf(instream, "%s\n", input);
+ if (instream == NULL || outstream == NULL) {
+ printf("Error opening temporary file(s)");
+ return 1;
+ }
+
+ fprintf(instream, "%s", input);
+ rewind(instream);
const int length = strlen(output) + 1;
char buffer[length];
- /* TODO: use instream instead of stdin */
- _parse_file(stdin, outstream);
+ _parse_file(instream, outstream);
+
const int tmp_length = ftell(outstream) + 1;
rewind(outstream);
@@ -46,11 +51,11 @@ static int test_parse_file(const char* testname, const char* input, const char*
}
int main(void) {
- printf("=============\nRunning Tests\n=============\n");
+ printf("\n=============\nRunning Tests\n=============\n");
int errors = 0;
errors += test_parse_file("1. Header", "# header", "<h1 id=\"header\">header</h1>\n");
- //errors += test_parse_file("2. Bold", "*bold*", "<strong>bold</strong>\n");
+ errors += test_parse_file("2. Bold", "**bold**", "<p><strong>bold</strong></p>\n");
printf("\n============\nTest Summary\n============\n");