summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPrzemyslaw Gorszkowski <pgorszkowski@gmail.com>2012-12-29 07:40:20 +0100
committerhjk <qthjk@ovi.com>2012-12-29 13:10:33 +0100
commitd08af15002f9bda035b8258fc0f69597df6b2f86 (patch)
tree6feb758177aadae13bf36b1dc30cf3691a194afd /src
parent45cd2d1e8fac9f88ba0bb597e7de52d580ed29f3 (diff)
downloadqt-creator-d08af15002f9bda035b8258fc0f69597df6b2f86.tar.gz
C++: unit test for code completion
Added unit test for code completion when pointer's type is a typedef Change-Id: I408be8d9364a4b48824238dcc44175167ae653f4 Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp28
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index 3d2abd7095..d90d73d3ac 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -533,6 +533,34 @@ void CppToolsPlugin::test_completion_template_7()
QVERIFY(completions.contains(QLatin1String("i")));
}
+void CppToolsPlugin::test_completion_type_of_pointer_is_typedef()
+{
+ TestData data;
+ data.srcText = "\n"
+ "typedef struct Foo\n"
+ "{\n"
+ " int foo;\n"
+ "} Foo;\n"
+ "Foo *bar;\n"
+ "@\n"
+ ;
+
+ setup(&data);
+
+ Utils::ChangeSet change;
+ QString txt = QLatin1String("bar->");
+ 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("Foo")));
+ QVERIFY(completions.contains(QLatin1String("foo")));
+}
+
void CppToolsPlugin::test_completion()
{
QFETCH(QByteArray, code);
diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h
index e6ad68cfb1..29dd1c8781 100644
--- a/src/plugins/cpptools/cpptoolsplugin.h
+++ b/src/plugins/cpptools/cpptoolsplugin.h
@@ -100,6 +100,7 @@ private slots:
void test_completion_template_5();
void test_completion_template_6();
void test_completion_template_7();
+ void test_completion_type_of_pointer_is_typedef();
void test_completion_template_as_base();
void test_completion_template_as_base_data();
void test_completion_use_global_identifier_as_base_class();