From ffba28d26ab6aaf9a953f42d5fa15c55a85c75a7 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gorszkowski Date: Sat, 12 Jan 2013 22:05:41 +0100 Subject: 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 --- src/plugins/cpptools/cppcompletion_test.cpp | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/plugins/cpptools/cppcompletion_test.cpp') 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\n" + "struct Template\n" + "{\n" + " int templateT_i;\n" + "};\n" + "\n" + "template<>\n" + "struct Template\n" + "{\n" + " int templateChar_i;\n" + "};\n" + "\n" + "Template 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); -- cgit v1.2.1