summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clangd/SourceCodeTests.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2018-08-13 08:23:01 +0000
committerKadir Cetinkaya <kadircet@google.com>2018-08-13 08:23:01 +0000
commita9c9d000162b2c54a11091a42fe67e28ef32995d (patch)
treee21672cc5b1d1578ee305d9b604ae6f14262d339 /clang-tools-extra/unittests/clangd/SourceCodeTests.cpp
parent9b9c27490d24584bcb282f5ae873febe1612268a (diff)
downloadbcm5719-llvm-a9c9d000162b2c54a11091a42fe67e28ef32995d.tar.gz
bcm5719-llvm-a9c9d000162b2c54a11091a42fe67e28ef32995d.zip
[clangd] Support textEdit in addition to insertText.
Summary: Completion replies contains textEdits as well. Note that this change relies on https://reviews.llvm.org/D50443. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgrang, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50449 llvm-svn: 339543
Diffstat (limited to 'clang-tools-extra/unittests/clangd/SourceCodeTests.cpp')
-rw-r--r--clang-tools-extra/unittests/clangd/SourceCodeTests.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang-tools-extra/unittests/clangd/SourceCodeTests.cpp b/clang-tools-extra/unittests/clangd/SourceCodeTests.cpp
index 57276affe61..4a97fa00a09 100644
--- a/clang-tools-extra/unittests/clangd/SourceCodeTests.cpp
+++ b/clang-tools-extra/unittests/clangd/SourceCodeTests.cpp
@@ -37,6 +37,13 @@ Position position(int line, int character) {
return Pos;
}
+Range range(const std::pair<int, int> p1, const std::pair<int, int> p2) {
+ Range range;
+ range.start = position(p1.first, p1.second);
+ range.end = position(p2.first, p2.second);
+ return range;
+}
+
TEST(SourceCodeTests, PositionToOffset) {
// line out of bounds
EXPECT_THAT_EXPECTED(positionToOffset(File, position(-1, 2)), Failed());
@@ -119,6 +126,14 @@ TEST(SourceCodeTests, OffsetToPosition) {
EXPECT_THAT(offsetToPosition(File, 30), Pos(2, 9)) << "out of bounds";
}
+TEST(SourceCodeTests, IsRangeConsecutive) {
+ EXPECT_TRUE(IsRangeConsecutive(range({2, 2}, {2, 3}), range({2, 3}, {2, 4})));
+ EXPECT_FALSE(
+ IsRangeConsecutive(range({0, 2}, {0, 3}), range({2, 3}, {2, 4})));
+ EXPECT_FALSE(
+ IsRangeConsecutive(range({2, 2}, {2, 3}), range({2, 4}, {2, 5})));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
OpenPOWER on IntegriCloud