/* * Copyright (c) 2022, MacDue * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include struct TestCase { StringView markdown; StringView expected_html; }; static constexpr Array image_size_tests { // No image size: TestCase { .markdown = "![](foo.png)"sv, .expected_html = R"(

)"sv }, // Only width given: TestCase { .markdown = "![](foo.png =100x)"sv, .expected_html = R"(

)"sv }, // Only height given: TestCase { .markdown = "![](foo.png =x200)"sv, .expected_html = R"(

)"sv }, // Both width and height given TestCase { .markdown = "![](foo.png =50x25)"sv, .expected_html = R"(

)"sv }, // Size contains invalid width TestCase { .markdown = "![](foo.png =1oox50)"sv, .expected_html = R"(

)"sv }, // Size contains invalid height TestCase { .markdown = "![](foo.png =900xfour)"sv, .expected_html = R"(

)"sv }, }; TEST_CASE(test_image_size_markdown_extension) { for (auto const& test_case : image_size_tests) { auto document = Markdown::Document::parse(test_case.markdown); auto raw_rendered_html = document->render_to_inline_html(); auto rendered_html = StringView(raw_rendered_html).trim_whitespace(); EXPECT_EQ(rendered_html, test_case.expected_html); } }