summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-08-31 10:29:41 +0200
committerNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-08-31 09:26:00 +0000
commit42d8672626e7bbb292c1457bedab2e48324aedb7 (patch)
treeb4206f546e8c27289edf7ce6c7731227ff7af252
parentf4a9eaf3a97e2a2f1dbdbfbf1b50a6ab21c7393e (diff)
downloadqt-creator-42d8672626e7bbb292c1457bedab2e48324aedb7.tar.gz
C++: Add tests
...for two regressions that were introduced by commit e0594fc9b906a32f5c8ac70265490cf86044676f C++: Fix expensive lookup for boost Change-Id: I1fa01e626da480ca53e04b4709fec458378e7aef Reviewed-by: Orgad Shaneh <orgads@gmail.com>
-rw-r--r--src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp15
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp96
-rw-r--r--tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp96
3 files changed, 207 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
index d0c22f402c..6f98752d46 100644
--- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
+++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
@@ -369,6 +369,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
QEXPECT_FAIL("globalVarFromEnum", "Contributor works on a fix.", Abort);
QEXPECT_FAIL("matchFunctionSignature_Follow_5", "foo(int) resolved as CallAST", Abort);
+ QEXPECT_FAIL("qualifiedNames", "Regression since e0594fc9b906a32f5c8ac70265490cf86044676f", Abort);
QCOMPARE(currentTextEditor->currentLine(), expectedLine);
QCOMPARE(currentTextEditor->currentColumn() - 1, expectedColumn);
@@ -972,6 +973,20 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
"template<class $T>\n"
"using Foo = Bar<@T>;\n"
);
+
+ QTest::newRow("qualifiedNames") << _(
+ "struct C\n"
+ "{\n"
+ " struct Nested { int $member; };\n"
+ " void f();\n"
+ "};\n"
+ "\n"
+ "void C::f()\n"
+ "{\n"
+ " C::Nested object;\n"
+ " object.@member;\n"
+ "}\n"
+ );
}
void CppEditorPlugin::test_FollowSymbolUnderCursor()
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index 4a5763cc10..15a1a43de9 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -3253,6 +3253,102 @@ void CppToolsPlugin::test_completion_data()
) << _("o.member.") << (QStringList()
<< QLatin1String("Data")
<< QLatin1String("x"));
+
+ QTest::newRow("std vector") << _(
+ "namespace std\n"
+ "{\n"
+ "template<typename _Tp>\n"
+ "struct allocator\n"
+ "{\n"
+ " typedef _Tp value_type;\n"
+ "\n"
+ " template<typename _Tp1>\n"
+ " struct rebind\n"
+ " { typedef allocator<_Tp1> other; };\n"
+ "};\n"
+ "\n"
+ "template<typename _Alloc, typename _Tp>\n"
+ "struct __alloctr_rebind\n"
+ "{\n"
+ " typedef typename _Alloc::template rebind<_Tp>::other __type;\n"
+ "};\n"
+ "\n"
+ "template<typename _Alloc>\n"
+ "struct allocator_traits\n"
+ "{\n"
+ " typedef typename _Alloc::value_type value_type;\n"
+ "\n"
+ " template<typename _Tp>\n"
+ " using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;\n"
+ "};\n"
+ "\n"
+ "template<typename _Iterator>\n"
+ "struct iterator_traits { };\n"
+ "\n"
+ "template<typename _Tp>\n"
+ "struct iterator_traits<_Tp*>\n"
+ "{\n"
+ " typedef _Tp* pointer;\n"
+ "};\n"
+ "} // namespace std\n"
+ "\n"
+ "namespace __gnu_cxx\n"
+ "{\n"
+ "template<typename _Alloc>\n"
+ "struct __alloc_traits\n"
+ "{\n"
+ " typedef _Alloc allocator_type;\n"
+ " typedef std::allocator_traits<_Alloc> _Base_type;\n"
+ " typedef typename _Alloc::value_type value_type;\n"
+ "\n"
+ " static value_type *_S_pointer_helper(...);\n"
+ " typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer;\n"
+ " typedef __pointer pointer;\n"
+ "\n"
+ " template<typename _Tp>\n"
+ " struct rebind\n"
+ " { typedef typename _Base_type::template rebind_alloc<_Tp> other; };\n"
+ "};\n"
+ "\n"
+ "template<typename _Iterator, typename _Container>\n"
+ "struct __normal_iterator\n"
+ "{\n"
+ " typedef std::iterator_traits<_Iterator> __traits_type;\n"
+ " typedef typename __traits_type::pointer pointer;\n"
+ "\n"
+ " pointer p;\n"
+ "};\n"
+ "} // namespace __gnu_cxx\n"
+ "\n"
+ "namespace std {\n"
+ "template<typename _Tp, typename _Alloc>\n"
+ "struct _Vector_Base\n"
+ "{\n"
+ " typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template\n"
+ " rebind<_Tp>::other _Tp_alloc_type;\n"
+ " typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer\n"
+ " pointer;\n"
+ "};\n"
+ "\n"
+ "template<typename _Tp, typename _Alloc = std::allocator<_Tp> >\n"
+ "struct vector : protected _Vector_Base<_Tp, _Alloc>\n"
+ "{\n"
+ " typedef _Vector_Base<_Tp, _Alloc> _Base;\n"
+ " typedef typename _Base::pointer pointer;\n"
+ " typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;\n"
+ "};\n"
+ "} // namespace std\n"
+ "\n"
+ "struct Foo { int bar; };\n"
+ "\n"
+ "void func()\n"
+ "{\n"
+ " std::vector<Foo>::iterator it;\n"
+ " @;\n"
+ "}\n"
+ ) << _("it.p->") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
}
void CppToolsPlugin::test_completion_member_access_operator()
diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
index 53d1266832..b343b99357 100644
--- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
+++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
@@ -1212,6 +1212,8 @@ void tst_CheckSymbols::findField()
source[position] = ' ';
BaseTestCase tc(source);
Use use = tc.findUse(line, column);
+
+ QEXPECT_FAIL("std vector", "Regression since e0594fc9b906a32f5c8ac70265490cf86044676f", Abort);
QVERIFY(use.isValid());
QVERIFY(use.kind == Highlighting::FieldUse);
}
@@ -1399,6 +1401,100 @@ void tst_CheckSymbols::findField_data()
" p->@bar;\n"
"}\n"
);
+
+ QTest::newRow("std vector") << _(
+ "namespace std\n"
+ "{\n"
+ "template<typename _Tp>\n"
+ "struct allocator\n"
+ "{\n"
+ " typedef _Tp value_type;\n"
+ "\n"
+ " template<typename _Tp1>\n"
+ " struct rebind\n"
+ " { typedef allocator<_Tp1> other; };\n"
+ "};\n"
+ "\n"
+ "template<typename _Alloc, typename _Tp>\n"
+ "struct __alloctr_rebind\n"
+ "{\n"
+ " typedef typename _Alloc::template rebind<_Tp>::other __type;\n"
+ "};\n"
+ "\n"
+ "template<typename _Alloc>\n"
+ "struct allocator_traits\n"
+ "{\n"
+ " typedef typename _Alloc::value_type value_type;\n"
+ "\n"
+ " template<typename _Tp>\n"
+ " using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;\n"
+ "};\n"
+ "\n"
+ "template<typename _Iterator>\n"
+ "struct iterator_traits { };\n"
+ "\n"
+ "template<typename _Tp>\n"
+ "struct iterator_traits<_Tp*>\n"
+ "{\n"
+ " typedef _Tp* pointer;\n"
+ "};\n"
+ "} // namespace std\n"
+ "\n"
+ "namespace __gnu_cxx\n"
+ "{\n"
+ "template<typename _Alloc>\n"
+ "struct __alloc_traits\n"
+ "{\n"
+ " typedef _Alloc allocator_type;\n"
+ " typedef std::allocator_traits<_Alloc> _Base_type;\n"
+ " typedef typename _Alloc::value_type value_type;\n"
+ "\n"
+ " static value_type *_S_pointer_helper(...);\n"
+ " typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer;\n"
+ " typedef __pointer pointer;\n"
+ "\n"
+ " template<typename _Tp>\n"
+ " struct rebind\n"
+ " { typedef typename _Base_type::template rebind_alloc<_Tp> other; };\n"
+ "};\n"
+ "\n"
+ "template<typename _Iterator, typename _Container>\n"
+ "struct __normal_iterator\n"
+ "{\n"
+ " typedef std::iterator_traits<_Iterator> __traits_type;\n"
+ " typedef typename __traits_type::pointer pointer;\n"
+ "\n"
+ " pointer p;\n"
+ "};\n"
+ "} // namespace __gnu_cxx\n"
+ "\n"
+ "namespace std {\n"
+ "template<typename _Tp, typename _Alloc>\n"
+ "struct _Vector_Base\n"
+ "{\n"
+ " typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template\n"
+ " rebind<_Tp>::other _Tp_alloc_type;\n"
+ " typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer\n"
+ " pointer;\n"
+ "};\n"
+ "\n"
+ "template<typename _Tp, typename _Alloc = std::allocator<_Tp> >\n"
+ "struct vector : protected _Vector_Base<_Tp, _Alloc>\n"
+ "{\n"
+ " typedef _Vector_Base<_Tp, _Alloc> _Base;\n"
+ " typedef typename _Base::pointer pointer;\n"
+ " typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;\n"
+ "};\n"
+ "} // namespace std\n"
+ "\n"
+ "struct Foo { int bar; };\n"
+ "\n"
+ "void func()\n"
+ "{\n"
+ " std::vector<Foo>::iterator it;\n"
+ " it.p->@bar;\n"
+ "}\n"
+ );
}
QTEST_APPLESS_MAIN(tst_CheckSymbols)