diff options
| author | Cody Logan <cody@lokken.dev> | 2023-11-29 10:41:24 -0800 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-11-29 10:41:24 -0800 |
| commit | 9e90de0981a9c6c12e81f24b9f4d1428a26a090a (patch) | |
| tree | f58050d9b30bdaf4b9fa9d656ed04151640f41e0 | |
| parent | 6da4166469e52d278a63fd94bc6c3e1abed76114 (diff) | |
| download | convert-markdown-9e90de0981a9c6c12e81f24b9f4d1428a26a090a.tar.gz convert-markdown-9e90de0981a9c6c12e81f24b9f4d1428a26a090a.zip | |
Refine test runner to account for multiline output
| -rw-r--r-- | test-convert-markdown.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/test-convert-markdown.c b/test-convert-markdown.c index 09a3d18..d2eb1a7 100644 --- a/test-convert-markdown.c +++ b/test-convert-markdown.c @@ -36,7 +36,12 @@ static int test_parse_file(const char* testname, const char* input, const char* const int tmp_length = ftell(outstream) + 1; rewind(outstream); - fgets(buffer, length, outstream); + char* result; + size_t len = 0; + do { + result = fgets(buffer + len, length - len, outstream); + len = strlen(buffer); + } while (result); fclose(instream); fclose(outstream); @@ -45,7 +50,7 @@ static int test_parse_file(const char* testname, const char* input, const char* return 0; } else { printf("%s test failed\n", testname); - printf("%s !=\n%s\n", buffer, output); + printf("%s\n !=\n%s\n", buffer, output); return 1; } } @@ -54,8 +59,15 @@ int main(void) { 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**", "<p><strong>bold</strong></p>\n"); + errors += test_parse_file("1. Header", + "# header", + "<h1 id=\"header\">header</h1>\n"); + errors += test_parse_file("2. Bold", + "**bold**", + "<p><strong>bold</strong></p>\n"); + errors += test_parse_file("3. Multiline", + "# header\n`code`", + "<h1 id=\"header\">header</h1>\n\n<p><code>code</code></p>\n"); printf("\n============\nTest Summary\n============\n"); |
