Index: clang/unittests/Rewrite/RewriterTest.cpp =================================================================== --- clang/unittests/Rewrite/RewriterTest.cpp +++ clang/unittests/Rewrite/RewriterTest.cpp @@ -75,6 +75,21 @@ EXPECT_EQ(T.Rewrite.getRewrittenText(T.makeCharRange(42, 47)), "bar;"); T.Rewrite.ReplaceText(T.SRange, "0"); EXPECT_EQ(T.Rewrite.getRewrittenText(T.makeCharRange(42, 47)), "0;"); + +TEST(Rewriter, RangeSize) { + StringRef Code = "void foo(){ }"; + + RangeTypeTest T(Code, 0, 13); + const auto Len = T.Rewrite.getRangeSize(T.makeCharRange(5, 8).getAsRange(), Rewriter::RewriteOptions{}); + EXPECT_EQ(Len, 3); +} + +TEST(Rewriter, RewriteRegression) { + StringRef Code = "void foo(){ }"; + + RangeTypeTest T(Code, 0, 13); + T.Rewrite.ReplaceText(T.makeCharRange(5, 8).getAsRange(), "bar"); + EXPECT_EQ(T.Rewrite.getRewrittenText(T.makeCharRange(0, 13)), "void bar(){ }"); } } // anonymous namespace