@@ -876,6 +876,64 @@ TEST_F(
876
876
EXPECT_EQ (44u , newCursor (Code, 48 ));
877
877
}
878
878
879
+ TEST_F (
880
+ SortIncludesTest,
881
+ CalculatesCorrectCursorPositionWhenNewLineReplacementsWithRegroupingAndCRLF) {
882
+ Style.IncludeBlocks = Style.IBS_Regroup ;
883
+ FmtStyle.LineEnding = FormatStyle::LE_CRLF;
884
+ Style.IncludeCategories = {
885
+ {" ^\" a\" " , 0 , 0 , false }, {" ^\" b\" " , 1 , 1 , false }, {" .*" , 2 , 2 , false }};
886
+ std::string Code = " #include \" a\"\r\n " // Start of line: 0
887
+ " #include \" b\"\r\n " // Start of line: 14
888
+ " #include \" c\"\r\n " // Start of line: 28
889
+ " \r\n " // Start of line: 42
890
+ " int i;" ; // Start of line: 44
891
+ std::string Expected = " #include \" a\"\r\n " // Start of line: 0
892
+ " \r\n " // Start of line: 14
893
+ " #include \" b\"\r\n " // Start of line: 16
894
+ " \r\n " // Start of line: 30
895
+ " #include \" c\"\r\n " // Start of line: 32
896
+ " \r\n " // Start of line: 46
897
+ " int i;" ; // Start of line: 48
898
+ EXPECT_EQ (Expected, sort (Code));
899
+ EXPECT_EQ (0u , newCursor (Code, 0 ));
900
+ EXPECT_EQ (15u , newCursor (Code, 16 ));
901
+ EXPECT_EQ (30u , newCursor (Code, 32 ));
902
+ EXPECT_EQ (44u , newCursor (Code, 46 ));
903
+ EXPECT_EQ (46u , newCursor (Code, 48 ));
904
+ }
905
+
906
+ TEST_F (
907
+ SortIncludesTest,
908
+ CalculatesCorrectCursorPositionWhenNoNewLineReplacementsWithRegroupingAndCRLF) {
909
+ Style.IncludeBlocks = Style.IBS_Regroup ;
910
+ FmtStyle.LineEnding = FormatStyle::LE_CRLF;
911
+ Style.IncludeCategories = {
912
+ {" ^\" a\" " , 0 , 0 , false }, {" ^\" b\" " , 1 , 1 , false }, {" .*" , 2 , 2 , false }};
913
+ std::string Code = " #include \" a\"\r\n " // Start of line: 0
914
+ " \r\n " // Start of line: 14
915
+ " #include \" c\"\r\n " // Start of line: 16
916
+ " \r\n " // Start of line: 30
917
+ " #include \" b\"\r\n " // Start of line: 32
918
+ " \r\n " // Start of line: 46
919
+ " int i;" ; // Start of line: 48
920
+ std::string Expected = " #include \" a\"\r\n " // Start of line: 0
921
+ " \r\n " // Start of line: 14
922
+ " #include \" b\"\r\n " // Start of line: 16
923
+ " \r\n " // Start of line: 30
924
+ " #include \" c\"\r\n " // Start of line: 32
925
+ " \r\n " // Start of line: 46
926
+ " int i;" ; // Start of line: 48
927
+ EXPECT_EQ (Expected, sort (Code));
928
+ EXPECT_EQ (0u , newCursor (Code, 0 ));
929
+ EXPECT_EQ (14u , newCursor (Code, 14 ));
930
+ EXPECT_EQ (30u , newCursor (Code, 32 ));
931
+ EXPECT_EQ (30u , newCursor (Code, 30 ));
932
+ EXPECT_EQ (15u , newCursor (Code, 15 ));
933
+ EXPECT_EQ (44u , newCursor (Code, 46 ));
934
+ EXPECT_EQ (46u , newCursor (Code, 48 ));
935
+ }
936
+
879
937
TEST_F (SortIncludesTest, DeduplicateIncludes) {
880
938
EXPECT_EQ (" #include <a>\n "
881
939
" #include <b>\n "
0 commit comments