diff options
| author | RafaĆ <91rafalc@gmail.com> | 2025-08-30 10:23:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-30 11:23:55 +0300 |
| commit | e7aaccca3fa3dbde9818ab8313250f3da4976e37 (patch) | |
| tree | 3f95dc77e48d7d254d5b4a8578994491e4fc081c /tests | |
| parent | bf869b0e075c65aa0f81d148b42a90dcce2f95c5 (diff) | |
| download | Project-Tick-e7aaccca3fa3dbde9818ab8313250f3da4976e37.tar.gz Project-Tick-e7aaccca3fa3dbde9818ab8313250f3da4976e37.zip | |
Formatter flag to force multi-line arrays (#282)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/manipulating_tables.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/manipulating_tables.cpp b/tests/manipulating_tables.cpp index afed60450e..56f7b3bf3c 100644 --- a/tests/manipulating_tables.cpp +++ b/tests/manipulating_tables.cpp @@ -614,6 +614,94 @@ key8 = [ ])"sv; CHECK(to_string(input, toml_formatter::default_flags, format_flags::indentation) == expected_without_indentation); + + // forcing multiline arrays: even short arrays become one-per-line (with array elements indented) + constexpr auto expected_forced_multiline = R"(key1 = 'val1' +key2 = [ + 1, + 2, + 3, + 4, + '5' +] +key3 = [ + 'this is a really long array', + 'and should be split over multiple lines', + 'by the formatter', + 'unless i dun goofed', + 'i guess thats what tests are for' +] + +[sub1] +key4 = 'val' + +[sub2] +key5 = 'val' + + [sub2.sub3] + key6 = 'val' + key7 = [ + 1, + 2, + 3, + 4, + '5' + ] + key8 = [ + 'this is a really long array', + 'and should be split over multiple lines', + 'by the formatter', + 'unless i dun goofed', + 'i guess thats what tests are for' + ])"sv; + + CHECK(to_string(input, toml_formatter::default_flags | format_flags::force_multiline_arrays) + == expected_forced_multiline); + + // forcing multiline arrays without indenting array elements + constexpr auto expected_forced_without_indented_arrays = R"(key1 = 'val1' +key2 = [ +1, +2, +3, +4, +'5' +] +key3 = [ +'this is a really long array', +'and should be split over multiple lines', +'by the formatter', +'unless i dun goofed', +'i guess thats what tests are for' +] + +[sub1] +key4 = 'val' + +[sub2] +key5 = 'val' + + [sub2.sub3] + key6 = 'val' + key7 = [ + 1, + 2, + 3, + 4, + '5' + ] + key8 = [ + 'this is a really long array', + 'and should be split over multiple lines', + 'by the formatter', + 'unless i dun goofed', + 'i guess thats what tests are for' + ])"sv; + + CHECK(to_string(input, + toml_formatter::default_flags | format_flags::force_multiline_arrays, + format_flags::indent_array_elements) + == expected_forced_without_indented_arrays); } } |
