forked from qt-creator/qt-creator
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:
@@ -369,6 +369,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
|||||||
|
|
||||||
QEXPECT_FAIL("globalVarFromEnum", "Contributor works on a fix.", Abort);
|
QEXPECT_FAIL("globalVarFromEnum", "Contributor works on a fix.", Abort);
|
||||||
QEXPECT_FAIL("matchFunctionSignature_Follow_5", "foo(int) resolved as CallAST", 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->currentLine(), expectedLine);
|
||||||
QCOMPARE(currentTextEditor->currentColumn() - 1, expectedColumn);
|
QCOMPARE(currentTextEditor->currentColumn() - 1, expectedColumn);
|
||||||
|
|
||||||
@@ -972,6 +973,20 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
|
|||||||
"template<class $T>\n"
|
"template<class $T>\n"
|
||||||
"using Foo = Bar<@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()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor()
|
||||||
|
@@ -3253,6 +3253,102 @@ void CppToolsPlugin::test_completion_data()
|
|||||||
) << _("o.member.") << (QStringList()
|
) << _("o.member.") << (QStringList()
|
||||||
<< QLatin1String("Data")
|
<< QLatin1String("Data")
|
||||||
<< QLatin1String("x"));
|
<< 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()
|
void CppToolsPlugin::test_completion_member_access_operator()
|
||||||
|
@@ -1212,6 +1212,8 @@ void tst_CheckSymbols::findField()
|
|||||||
source[position] = ' ';
|
source[position] = ' ';
|
||||||
BaseTestCase tc(source);
|
BaseTestCase tc(source);
|
||||||
Use use = tc.findUse(line, column);
|
Use use = tc.findUse(line, column);
|
||||||
|
|
||||||
|
QEXPECT_FAIL("std vector", "Regression since e0594fc9b906a32f5c8ac70265490cf86044676f", Abort);
|
||||||
QVERIFY(use.isValid());
|
QVERIFY(use.isValid());
|
||||||
QVERIFY(use.kind == Highlighting::FieldUse);
|
QVERIFY(use.kind == Highlighting::FieldUse);
|
||||||
}
|
}
|
||||||
@@ -1399,6 +1401,100 @@ void tst_CheckSymbols::findField_data()
|
|||||||
" p->@bar;\n"
|
" p->@bar;\n"
|
||||||
"}\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)
|
QTEST_APPLESS_MAIN(tst_CheckSymbols)
|
||||||
|
Reference in New Issue
Block a user