summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppcompletion_test.cpp
diff options
context:
space:
mode:
authorPrzemyslaw Gorszkowski <pgorszkowski@gmail.com>2013-01-12 22:05:41 +0100
committerPrzemyslaw Gorszkowski <pgorszkowski@gmail.com>2013-01-30 18:49:25 +0100
commitffba28d26ab6aaf9a953f42d5fa15c55a85c75a7 (patch)
tree010c0eb03d5caf768b3206ee7b69fe68b93a333c /src/plugins/cpptools/cppcompletion_test.cpp
parent0135609973b8c8f9b380aefb618659f698c5c2c5 (diff)
downloadqt-creator-ffba28d26ab6aaf9a953f42d5fa15c55a85c75a7.tar.gz
C++: Fix code compl. for instantiation of template specialization
It works for full specialization. Instantiate of the partial specialization has to be implemented(finding appropriate partial specialization-on going) Added unit test. Change-Id: I8ef5ea963e7c665e0d67d390b3a833486773dab0 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppcompletion_test.cpp')
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index 80471cd8df..63325d521f 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -564,6 +564,42 @@ void CppToolsPlugin::test_completion_type_of_pointer_is_typedef()
QVERIFY(completions.contains(QLatin1String("foo")));
}
+void CppToolsPlugin::test_completion_instantiate_full_specialization()
+{
+ TestData data;
+ data.srcText = "\n"
+ "template<typename T>\n"
+ "struct Template\n"
+ "{\n"
+ " int templateT_i;\n"
+ "};\n"
+ "\n"
+ "template<>\n"
+ "struct Template<char>\n"
+ "{\n"
+ " int templateChar_i;\n"
+ "};\n"
+ "\n"
+ "Template<char> templateChar;\n"
+ "@\n"
+ ;
+
+ setup(&data);
+
+ Utils::ChangeSet change;
+ QString txt = QLatin1String("templateChar.");
+ change.insert(data.pos, txt);
+ QTextCursor cursor(data.doc);
+ change.apply(&cursor);
+ data.pos += txt.length();
+
+ QStringList completions = getCompletions(data);
+
+ QCOMPARE(completions.size(), 2);
+ QVERIFY(completions.contains(QLatin1String("Template")));
+ QVERIFY(completions.contains(QLatin1String("templateChar_i")));
+}
+
void CppToolsPlugin::test_completion()
{
QFETCH(QByteArray, code);