From 0fc5ad7ae11833ba4dff8810887b4b2294f3afc4 Mon Sep 17 00:00:00 2001 From: ochafik Date: Mon, 30 Sep 2024 03:51:48 +0100 Subject: [PATCH] `minja`: avoid c++20 struct initializers in test --- tests/test-minja.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/test-minja.cpp b/tests/test-minja.cpp index 9730ffc65..2a8e92848 100644 --- a/tests/test-minja.cpp +++ b/tests/test-minja.cpp @@ -119,14 +119,26 @@ static void test_error_contains(const std::string & template_str, const json & b cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build -t test-minja -j && ./build/bin/test-minja */ int main() { + const minja::Options lstrip_blocks { + /* .trim_blocks = */ false, + /* .lstrip_blocks = */ true, + /* .keep_trailing_newline = */ false, + }; + const minja::Options trim_blocks { + /* .trim_blocks = */ true, + /* .lstrip_blocks = */ false, + /* .keep_trailing_newline = */ false, + }; + const minja::Options lstrip_trim_blocks { + /* .trim_blocks = */ true, + /* .lstrip_blocks = */ true, + /* .keep_trailing_newline = */ false, + }; + test_render("{% set txt = 'a\\nb\\n' %}{{ txt | indent(2) }}|{{ txt | indent(2, first=true) }}", {}, {}, "a\n b\n| a\n b\n"); test_render(R"({%- if True %} {% set _ = x %}{%- endif %}{{ 1 }})", {}, - { - /* .lstrip_blocks = */ true, - /* .trim_blocks = */ true, - /* .keep_trailing_newline = */ false, - }, + lstrip_trim_blocks, " 1" ); test_render(R"( {{- 'a' -}}{{ ' ' }}{{- 'b' -}} )", {}, {}, "a b"); @@ -159,23 +171,23 @@ int main() { "\n"; test_render( trim_tmpl, - {}, { .trim_blocks = true }, "\n Hello...\n"); + {}, trim_blocks, "\n Hello...\n"); test_render( trim_tmpl, {}, {}, "\n Hello \n...\n"); test_render( trim_tmpl, - {}, { .lstrip_blocks = true }, "\nHello \n...\n"); + {}, lstrip_blocks, "\nHello \n...\n"); test_render( trim_tmpl, - {}, { .trim_blocks = true, .lstrip_blocks = true }, "\nHello...\n"); + {}, lstrip_trim_blocks, "\nHello...\n"); test_render( R"({%- set separator = joiner(' | ') -%} {%- for item in ["a", "b", "c"] %}{{ separator() }}{{ item }}{% endfor -%})", {}, {}, "a | b | c"); test_render("a\nb\n", {}, {}, "a\nb"); - test_render(" {{- ' a\n'}}", {}, {.trim_blocks = true}, " a\n"); + test_render(" {{- ' a\n'}}", {}, trim_blocks, " a\n"); test_render( R"(