From ef22f048087a79d99ac7e1cf7c7a3d83d7b66a7a Mon Sep 17 00:00:00 2001 From: dx Date: Wed, 6 May 2020 03:44:02 +0100 Subject: +test for header depths --- Converter/src/test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Converter/src/test.c') diff --git a/Converter/src/test.c b/Converter/src/test.c index ff42fb3..82f8cd0 100644 --- a/Converter/src/test.c +++ b/Converter/src/test.c @@ -5,5 +5,23 @@ void test_header_depths(void) { + const int test_size = 5; + string test_strings[] = {"Header", "#Header", "##Header", "#Header#", + "#####Header"}; + string expected_results[] = {"Header", "

Header

", "

Header

", + "

Header#

", "
Header
"}; + for (int i = 0; i < test_size; ++i) + { + const string test_string = test_strings[i]; + const string expected_result = expected_results[i]; + const int length_of_test = strnlen(test_string, 512); + const int length_of_expected = strnlen(expected_result, 512); + const string test_result = compile_line(test_string, length_of_test); + + fprintf(stderr, "Testing %s => %s\n", test_string, expected_result); + fprintf(stderr, "Result: %s\n\n", test_result); + + assert(strncmp(test_result, expected_result, length_of_expected) == 0); + } } -- cgit v1.2.3-13-gbd6f