summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp81
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.h2
2 files changed, 83 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index 4df7400978..9eb28dca97 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -152,6 +152,87 @@ void CppToolsPlugin::test_completion_forward_declarations_present()
QCOMPARE(completions, expected);
}
+void CppToolsPlugin::test_completion_inside_parentheses_c_style_conversion()
+{
+ TestData data;
+ data.srcText = "\n"
+ "class Base\n"
+ "{\n"
+ " int i_base;\n"
+ "};\n"
+ "\n"
+ "class Derived : public Base\n"
+ "{\n"
+ " int i_derived;\n"
+ "};\n"
+ "\n"
+ "void fun()\n"
+ "{\n"
+ " Base *b = new Derived;\n"
+ " if (1)\n"
+ " @\n"
+ "}\n"
+ ;
+
+ setup(&data);
+
+ Utils::ChangeSet change;
+ QString txt = QLatin1String("((Derived *)b)->");
+ change.insert(data.pos, txt);
+ QTextCursor cursor(data.doc);
+ change.apply(&cursor);
+ data.pos += txt.length();
+
+ QStringList completions = getCompletions(data);
+
+ QCOMPARE(completions.size(), 4);
+ QVERIFY(completions.contains(QLatin1String("Derived")));
+ QVERIFY(completions.contains(QLatin1String("Base")));
+ QVERIFY(completions.contains(QLatin1String("i_derived")));
+ QVERIFY(completions.contains(QLatin1String("i_base")));
+
+}
+
+void CppToolsPlugin::test_completion_inside_parentheses_cast_operator_conversion()
+{
+ TestData data;
+ data.srcText = "\n"
+ "class Base\n"
+ "{\n"
+ " int i_base;\n"
+ "};\n"
+ "\n"
+ "class Derived : public Base\n"
+ "{\n"
+ " int i_derived;\n"
+ "};\n"
+ "\n"
+ "void fun()\n"
+ "{\n"
+ " Base *b = new Derived;\n"
+ " if (1)\n"
+ " @\n"
+ "}\n"
+ ;
+
+ setup(&data);
+
+ Utils::ChangeSet change;
+ QString txt = QLatin1String("(static_cast<Derived *>(b))->");
+ change.insert(data.pos, txt);
+ QTextCursor cursor(data.doc);
+ change.apply(&cursor);
+ data.pos += txt.length();
+
+ QStringList completions = getCompletions(data);
+
+ QCOMPARE(completions.size(), 4);
+ QVERIFY(completions.contains(QLatin1String("Derived")));
+ QVERIFY(completions.contains(QLatin1String("Base")));
+ QVERIFY(completions.contains(QLatin1String("i_derived")));
+ QVERIFY(completions.contains(QLatin1String("i_base")));
+}
+
void CppToolsPlugin::test_completion_basic_1()
{
TestData data;
diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h
index c338a24dfe..b56ee4aa0d 100644
--- a/src/plugins/cpptools/cpptoolsplugin.h
+++ b/src/plugins/cpptools/cpptoolsplugin.h
@@ -90,6 +90,8 @@ private slots:
void test_codegen_definition_middle_member();
void test_completion_forward_declarations_present();
+ void test_completion_inside_parentheses_c_style_conversion();
+ void test_completion_inside_parentheses_cast_operator_conversion();
void test_completion_basic_1();
void test_completion_template_1();
void test_completion_template_2();