diff options
| author | Cody Logan <cody@lokken.dev> | 2023-11-29 10:12:53 -0800 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-11-29 10:13:46 -0800 |
| commit | 6da4166469e52d278a63fd94bc6c3e1abed76114 (patch) | |
| tree | f3a3baf905279d216ca8911578c862f255a3ab59 /test-convert-markdown.c | |
| parent | 8268ded04a20963f8e527b6106c6c0df388afde9 (diff) | |
| download | convert-markdown-6da4166469e52d278a63fd94bc6c3e1abed76114.tar.gz convert-markdown-6da4166469e52d278a63fd94bc6c3e1abed76114.zip | |
Rewind temp input stream before using it
Diffstat (limited to 'test-convert-markdown.c')
| -rw-r--r-- | test-convert-markdown.c | 17 |
1 files changed, 11 insertions, 6 deletions
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"); |
