forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -100,6 +100,7 @@ private slots:
|
||||
void test_completion_template_6();
|
||||
void test_completion_template_7();
|
||||
void test_completion_type_of_pointer_is_typedef();
|
||||
void test_completion_instantiate_full_specialization();
|
||||
void test_completion_template_as_base();
|
||||
void test_completion_template_as_base_data();
|
||||
void test_completion_use_global_identifier_as_base_class();
|
||||
|
||||
Reference in New Issue
Block a user