summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppcompletion_test.cpp
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 /src/plugins/cpptools/cppcompletion_test.cpp
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>
Diffstat (limited to 'src/plugins/cpptools/cppcompletion_test.cpp')
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp96
1 files changed, 96 insertions, 0 deletions
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()