summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2016-01-09 20:57:11 +0200
committerOrgad Shaneh <orgads@gmail.com>2016-03-01 13:20:49 +0000
commitd9a57623afb7331e9c8ec064b3f047eb32b73b94 (patch)
treeab65cf95e12ab47f8601fb2eef82635438711a26 /tests/unit
parentc2dfd0f53bbe3b93ac898f0b0ae34e419426351e (diff)
downloadqt-creator-d9a57623afb7331e9c8ec064b3f047eb32b73b94.tar.gz
Clang: Add some tests for lambda highlighting
Test that local, argument and member variables are highlighted correctly when referenced inside a lambda struct LambdaTester { int member = 0; void func() { const int var = 42, var2 = 84; auto lambda = [var, this](int input) { return var + input + member; // All variables here }; lambda(var2); } }; Change-Id: I3b7b86c57a91f0f254715770dd870033be928b28 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/unittest/highlightinginformationstest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unit/unittest/highlightinginformationstest.cpp b/tests/unit/unittest/highlightinginformationstest.cpp
index ce4b8a173e..379319ec1d 100644
--- a/tests/unit/unittest/highlightinginformationstest.cpp
+++ b/tests/unit/unittest/highlightinginformationstest.cpp
@@ -976,6 +976,27 @@ TEST_F(HighlightingInformations, LambdaCapture)
ASSERT_THAT(infos[4], HasType(HighlightingType::LocalVariable));
}
+TEST_F(HighlightingInformations, LambdaCapturedVarUsage)
+{
+ const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41));
+
+ ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable));
+}
+
+TEST_F(HighlightingInformations, LambdaArgumentUsage)
+{
+ const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41));
+
+ ASSERT_THAT(infos[3], HasType(HighlightingType::LocalVariable));
+}
+
+TEST_F(HighlightingInformations, LambdaFieldUsage)
+{
+ const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41));
+
+ ASSERT_THAT(infos[5], HasType(HighlightingType::Field));
+}
+
Data *HighlightingInformations::d;
void HighlightingInformations::SetUpTestCase()