@@ -3793,6 +3793,189 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
3793
3793
" int i;// A Comment to be moved\n "
3794
3794
" // with indent\n " ,
3795
3795
Style));
3796
+
3797
+ Style = getLLVMStyleWithColumns (0 );
3798
+ EXPECT_EQ (" // Free comment without space\n "
3799
+ " \n "
3800
+ " // Free comment with 3 spaces\n "
3801
+ " \n "
3802
+ " /// Free Doxygen without space\n "
3803
+ " \n "
3804
+ " /// Free Doxygen with 3 spaces\n "
3805
+ " \n "
3806
+ " /// A Doxygen Comment with a nested list:\n "
3807
+ " /// - Foo\n "
3808
+ " /// - Bar\n "
3809
+ " /// - Baz\n "
3810
+ " /// - End\n "
3811
+ " /// of the inner list\n "
3812
+ " /// .\n "
3813
+ " /// .\n "
3814
+ " \n "
3815
+ " namespace Foo {\n "
3816
+ " bool bar(bool b) {\n "
3817
+ " bool ret1 = true; ///< Doxygenstyle without space\n "
3818
+ " bool ret2 = true; ///< Doxygenstyle with 3 spaces\n "
3819
+ " if (b) {\n "
3820
+ " // Foo\n "
3821
+ " \n "
3822
+ " // In function comment\n "
3823
+ " ret2 = false;\n "
3824
+ " } // End of if\n "
3825
+ " \n "
3826
+ " // if (ret1) {\n "
3827
+ " // return ret2;\n "
3828
+ " // }\n "
3829
+ " \n "
3830
+ " // if (ret1) {\n "
3831
+ " // return ret2;\n "
3832
+ " // }\n "
3833
+ " \n "
3834
+ " return ret1 && ret2;\n "
3835
+ " }\n "
3836
+ " } // namespace Foo\n "
3837
+ " \n "
3838
+ " namespace Bar {\n "
3839
+ " int foo();\n "
3840
+ " } // namespace Bar\n "
3841
+ " //@Nothing added because of the non ascii char\n "
3842
+ " \n "
3843
+ " //@ Nothing removed because of the non ascii char\n "
3844
+ " \n "
3845
+ " // Comment to move to the left\n "
3846
+ " // But not this?\n "
3847
+ " // @but this\n "
3848
+ " \n "
3849
+ " // Comment to move to the right\n "
3850
+ " //@ this stays\n "
3851
+ " \n "
3852
+ " //} will not move\n "
3853
+ " \n "
3854
+ " // vv will only move\n "
3855
+ " // } if the line above does\n " ,
3856
+ format (Code, Style));
3857
+
3858
+ Style.SpacesInLineCommentPrefix = {0 , 0 };
3859
+ EXPECT_EQ (" //Free comment without space\n "
3860
+ " \n "
3861
+ " //Free comment with 3 spaces\n "
3862
+ " \n "
3863
+ " ///Free Doxygen without space\n "
3864
+ " \n "
3865
+ " ///Free Doxygen with 3 spaces\n "
3866
+ " \n "
3867
+ " ///A Doxygen Comment with a nested list:\n "
3868
+ " ///- Foo\n "
3869
+ " ///- Bar\n "
3870
+ " /// - Baz\n " // Here we keep the relative indentation
3871
+ " /// - End\n "
3872
+ " /// of the inner list\n "
3873
+ " /// .\n "
3874
+ " ///.\n "
3875
+ " \n "
3876
+ " namespace Foo {\n "
3877
+ " bool bar(bool b) {\n "
3878
+ " bool ret1 = true; ///<Doxygenstyle without space\n "
3879
+ " bool ret2 = true; ///<Doxygenstyle with 3 spaces\n "
3880
+ " if (b) {\n "
3881
+ " //Foo\n "
3882
+ " \n "
3883
+ " //In function comment\n "
3884
+ " ret2 = false;\n "
3885
+ " } //End of if\n "
3886
+ " \n "
3887
+ " //if (ret1) {\n "
3888
+ " // return ret2;\n "
3889
+ " //}\n "
3890
+ " \n "
3891
+ " //if (ret1) {\n "
3892
+ " // return ret2;\n "
3893
+ " //}\n "
3894
+ " \n "
3895
+ " return ret1 && ret2;\n "
3896
+ " }\n "
3897
+ " } //namespace Foo\n "
3898
+ " \n "
3899
+ " namespace Bar {\n "
3900
+ " int foo();\n "
3901
+ " } //namespace Bar\n "
3902
+ " //@Nothing added because of the non ascii char\n "
3903
+ " \n "
3904
+ " //@ Nothing removed because of the non ascii char\n "
3905
+ " \n "
3906
+ " //Comment to move to the left\n "
3907
+ " //But not this?\n "
3908
+ " //@but this\n "
3909
+ " \n "
3910
+ " //Comment to move to the right\n "
3911
+ " //@ this stays\n "
3912
+ " \n "
3913
+ " //} will not move\n "
3914
+ " \n "
3915
+ " //vv will only move\n "
3916
+ " //} if the line above does\n " ,
3917
+ format (Code, Style));
3918
+
3919
+ Style.SpacesInLineCommentPrefix = {2 , -1u };
3920
+ EXPECT_EQ (" // Free comment without space\n "
3921
+ " \n "
3922
+ " // Free comment with 3 spaces\n "
3923
+ " \n "
3924
+ " /// Free Doxygen without space\n "
3925
+ " \n "
3926
+ " /// Free Doxygen with 3 spaces\n "
3927
+ " \n "
3928
+ " /// A Doxygen Comment with a nested list:\n "
3929
+ " /// - Foo\n "
3930
+ " /// - Bar\n "
3931
+ " /// - Baz\n "
3932
+ " /// - End\n "
3933
+ " /// of the inner list\n "
3934
+ " /// .\n "
3935
+ " /// .\n "
3936
+ " \n "
3937
+ " namespace Foo {\n "
3938
+ " bool bar(bool b) {\n "
3939
+ " bool ret1 = true; ///< Doxygenstyle without space\n "
3940
+ " bool ret2 = true; ///< Doxygenstyle with 3 spaces\n "
3941
+ " if (b) {\n "
3942
+ " // Foo\n "
3943
+ " \n "
3944
+ " // In function comment\n "
3945
+ " ret2 = false;\n "
3946
+ " } // End of if\n "
3947
+ " \n "
3948
+ " // if (ret1) {\n "
3949
+ " // return ret2;\n "
3950
+ " // }\n "
3951
+ " \n "
3952
+ " // if (ret1) {\n "
3953
+ " // return ret2;\n "
3954
+ " // }\n "
3955
+ " \n "
3956
+ " return ret1 && ret2;\n "
3957
+ " }\n "
3958
+ " } // namespace Foo\n "
3959
+ " \n "
3960
+ " namespace Bar {\n "
3961
+ " int foo();\n "
3962
+ " } // namespace Bar\n "
3963
+ " //@Nothing added because of the non ascii char\n "
3964
+ " \n "
3965
+ " //@ Nothing removed because of the non ascii char\n "
3966
+ " \n "
3967
+ " // Comment to move to the left\n "
3968
+ " // But not this?\n "
3969
+ " // @but this\n "
3970
+ " \n "
3971
+ " // Comment to move to the right\n "
3972
+ " //@ this stays\n "
3973
+ " \n "
3974
+ " //} will not move\n "
3975
+ " \n "
3976
+ " // vv will only move\n "
3977
+ " // } if the line above does\n " ,
3978
+ format (Code, Style));
3796
3979
}
3797
3980
3798
3981
} // end namespace
0 commit comments