C++: Add tests

...for two regressions that were introduced by

    commit e0594fc9b9
    C++: Fix expensive lookup for boost

Change-Id: I1fa01e626da480ca53e04b4709fec458378e7aef
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Nikolai Kosjar
2015-08-31 10:29:41 +02:00
parent f4a9eaf3a9
commit 42d8672626
3 changed files with 207 additions and 0 deletions

View File

@@ -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()