@@ -614,6 +614,94 @@ key8 = [
614
614
])" sv;
615
615
CHECK (to_string (input, toml_formatter::default_flags, format_flags::indentation)
616
616
== expected_without_indentation);
617
+
618
+ // forcing multiline arrays: even short arrays become one-per-line (with array elements indented)
619
+ constexpr auto expected_forced_multiline = R"( key1 = 'val1'
620
+ key2 = [
621
+ 1,
622
+ 2,
623
+ 3,
624
+ 4,
625
+ '5'
626
+ ]
627
+ key3 = [
628
+ 'this is a really long array',
629
+ 'and should be split over multiple lines',
630
+ 'by the formatter',
631
+ 'unless i dun goofed',
632
+ 'i guess thats what tests are for'
633
+ ]
634
+
635
+ [sub1]
636
+ key4 = 'val'
637
+
638
+ [sub2]
639
+ key5 = 'val'
640
+
641
+ [sub2.sub3]
642
+ key6 = 'val'
643
+ key7 = [
644
+ 1,
645
+ 2,
646
+ 3,
647
+ 4,
648
+ '5'
649
+ ]
650
+ key8 = [
651
+ 'this is a really long array',
652
+ 'and should be split over multiple lines',
653
+ 'by the formatter',
654
+ 'unless i dun goofed',
655
+ 'i guess thats what tests are for'
656
+ ])" sv;
657
+
658
+ CHECK (to_string (input, toml_formatter::default_flags | format_flags::force_multiline_arrays)
659
+ == expected_forced_multiline);
660
+
661
+ // forcing multiline arrays without indenting array elements
662
+ constexpr auto expected_forced_without_indented_arrays = R"( key1 = 'val1'
663
+ key2 = [
664
+ 1,
665
+ 2,
666
+ 3,
667
+ 4,
668
+ '5'
669
+ ]
670
+ key3 = [
671
+ 'this is a really long array',
672
+ 'and should be split over multiple lines',
673
+ 'by the formatter',
674
+ 'unless i dun goofed',
675
+ 'i guess thats what tests are for'
676
+ ]
677
+
678
+ [sub1]
679
+ key4 = 'val'
680
+
681
+ [sub2]
682
+ key5 = 'val'
683
+
684
+ [sub2.sub3]
685
+ key6 = 'val'
686
+ key7 = [
687
+ 1,
688
+ 2,
689
+ 3,
690
+ 4,
691
+ '5'
692
+ ]
693
+ key8 = [
694
+ 'this is a really long array',
695
+ 'and should be split over multiple lines',
696
+ 'by the formatter',
697
+ 'unless i dun goofed',
698
+ 'i guess thats what tests are for'
699
+ ])" sv;
700
+
701
+ CHECK (to_string (input,
702
+ toml_formatter::default_flags | format_flags::force_multiline_arrays,
703
+ format_flags::indent_array_elements)
704
+ == expected_forced_without_indented_arrays);
617
705
}
618
706
}
619
707
0 commit comments