diff options
author | Marco Bubke <marco.bubke@qt.io> | 2016-08-04 19:55:54 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2016-08-08 13:50:25 +0000 |
commit | 98a167c0d51fb2f4f79f3203050ca8087abf955a (patch) | |
tree | ba3bc3989e1792ceeb076cf5568fd1a379b43925 /tests | |
parent | fe3a7d6479884089bcb7d47823d086e0e74c1c30 (diff) | |
download | qt-creator-98a167c0d51fb2f4f79f3203050ca8087abf955a.tar.gz |
Clang: Fix template renaming
Change-Id: I8040fe8dfc99d66e242ce2ff8589aa914838bfc9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unittest/data/renamevariable.cpp | 16 | ||||
-rw-r--r-- | tests/unit/unittest/symbolfindertest.cpp | 57 |
2 files changed, 70 insertions, 3 deletions
diff --git a/tests/unit/unittest/data/renamevariable.cpp b/tests/unit/unittest/data/renamevariable.cpp index 0738d32dc1..638fddf56c 100644 --- a/tests/unit/unittest/data/renamevariable.cpp +++ b/tests/unit/unittest/data/renamevariable.cpp @@ -2,3 +2,19 @@ int variable; int x = variable + 3; +template <typename TemplateName> +class TemplateKlasse { +public: + TemplateName value; +}; + +void function() +{ + TemplateKlasse<int> instance; + + instance.value += 5; + + auto l = [x=instance] { + int k = x.value + 3; + }; +} diff --git a/tests/unit/unittest/symbolfindertest.cpp b/tests/unit/unittest/symbolfindertest.cpp index 75f1cf803b..9d8ac2ed94 100644 --- a/tests/unit/unittest/symbolfindertest.cpp +++ b/tests/unit/unittest/symbolfindertest.cpp @@ -94,17 +94,29 @@ TEST(SymbolFinder, FindNameInUnsavedFile) TEST(SymbolFinder, FindUsrs) { SymbolFinder finder(1, 5); - finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "int variable;", {"cc", "renamevariable.cpp"}); + finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "int variable;", {"cc", "renamevariable.cpp", "-std=c++14"}); finder.findSymbol(); ASSERT_THAT(finder.unifiedSymbolResolutions().front(), StrEq("c:@variable")); } -TEST(SymbolFinder, SourceLocations) +TEST(SymbolFinder, VariableDeclarationSourceLocations) { SymbolFinder finder(1, 5); - finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp"}); + finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"}); + + finder.findSymbol(); + + ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), + AllOf(Contains(IsSourceLocation(1, 5)), + Contains(IsSourceLocation(3, 9)))); +} + +TEST(SymbolFinder, VariableUsageSourceLocations) +{ + SymbolFinder finder(3, 9); + finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"}); finder.findSymbol(); @@ -113,6 +125,45 @@ TEST(SymbolFinder, SourceLocations) Contains(IsSourceLocation(3, 9)))); } +TEST(SymbolFinder, TemplateMemberVariableDeclarationSourceLocations) +{ + SymbolFinder finder(8, 18); + finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"}); + + finder.findSymbol(); + + ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), + AllOf(Contains(IsSourceLocation(8, 18)), + Contains(IsSourceLocation(15, 14)), + Contains(IsSourceLocation(18, 19)))); +} + +TEST(SymbolFinder, TemplateMemberVariableUsageSourceLocations) +{ + SymbolFinder finder(15, 14); + finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"}); + + finder.findSymbol(); + + ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), + AllOf(Contains(IsSourceLocation(8, 18)), + Contains(IsSourceLocation(15, 14)), + Contains(IsSourceLocation(18, 19)))); +} + +TEST(SymbolFinder, TemplateMemberVariableUsageInLambdaSourceLocations) +{ + SymbolFinder finder(18, 19); + finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"}); + + finder.findSymbol(); + + ASSERT_THAT(finder.sourceLocations().sourceLocationContainers(), + AllOf(Contains(IsSourceLocation(8, 18)), + Contains(IsSourceLocation(15, 14)), + Contains(IsSourceLocation(18, 19)))); +} + TEST(SymbolFinder, CursorOverMacroDefintionSymbolName) { SymbolFinder finder(1, 9); |