Skip to content

Commit 0fc5ad7

Browse files
author
ochafik
committed
minja: avoid c++20 struct initializers in test
1 parent 277f385 commit 0fc5ad7

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

tests/test-minja.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,26 @@ static void test_error_contains(const std::string & template_str, const json & b
119119
cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build -t test-minja -j && ./build/bin/test-minja
120120
*/
121121
int main() {
122+
const minja::Options lstrip_blocks {
123+
/* .trim_blocks = */ false,
124+
/* .lstrip_blocks = */ true,
125+
/* .keep_trailing_newline = */ false,
126+
};
127+
const minja::Options trim_blocks {
128+
/* .trim_blocks = */ true,
129+
/* .lstrip_blocks = */ false,
130+
/* .keep_trailing_newline = */ false,
131+
};
132+
const minja::Options lstrip_trim_blocks {
133+
/* .trim_blocks = */ true,
134+
/* .lstrip_blocks = */ true,
135+
/* .keep_trailing_newline = */ false,
136+
};
137+
122138
test_render("{% set txt = 'a\\nb\\n' %}{{ txt | indent(2) }}|{{ txt | indent(2, first=true) }}", {}, {}, "a\n b\n| a\n b\n");
123139
test_render(R"({%- if True %} {% set _ = x %}{%- endif %}{{ 1 }})",
124140
{},
125-
{
126-
/* .lstrip_blocks = */ true,
127-
/* .trim_blocks = */ true,
128-
/* .keep_trailing_newline = */ false,
129-
},
141+
lstrip_trim_blocks,
130142
" 1"
131143
);
132144
test_render(R"( {{- 'a' -}}{{ ' ' }}{{- 'b' -}} )", {}, {}, "a b");
@@ -159,23 +171,23 @@ int main() {
159171
"\n";
160172
test_render(
161173
trim_tmpl,
162-
{}, { .trim_blocks = true }, "\n Hello...\n");
174+
{}, trim_blocks, "\n Hello...\n");
163175
test_render(
164176
trim_tmpl,
165177
{}, {}, "\n Hello \n...\n");
166178
test_render(
167179
trim_tmpl,
168-
{}, { .lstrip_blocks = true }, "\nHello \n...\n");
180+
{}, lstrip_blocks, "\nHello \n...\n");
169181
test_render(
170182
trim_tmpl,
171-
{}, { .trim_blocks = true, .lstrip_blocks = true }, "\nHello...\n");
183+
{}, lstrip_trim_blocks, "\nHello...\n");
172184

173185
test_render(
174186
R"({%- set separator = joiner(' | ') -%}
175187
{%- for item in ["a", "b", "c"] %}{{ separator() }}{{ item }}{% endfor -%})",
176188
{}, {}, "a | b | c");
177189
test_render("a\nb\n", {}, {}, "a\nb");
178-
test_render(" {{- ' a\n'}}", {}, {.trim_blocks = true}, " a\n");
190+
test_render(" {{- ' a\n'}}", {}, trim_blocks, " a\n");
179191

180192
test_render(
181193
R"(

0 commit comments

Comments
 (0)