diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2016-01-09 20:57:11 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2016-03-01 13:20:49 +0000 |
commit | d9a57623afb7331e9c8ec064b3f047eb32b73b94 (patch) | |
tree | ab65cf95e12ab47f8601fb2eef82635438711a26 /tests/unit | |
parent | c2dfd0f53bbe3b93ac898f0b0ae34e419426351e (diff) | |
download | qt-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.cpp | 21 |
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() |