Commit fb396ffb authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

CppTools: Cover all permutations for each enum testcase

* named enum, access by value names
* named enum, access by enum name (C++11)
* anonymous enum

+ Add some failing tests

Task-number: QTCREATORBUG-13757
Change-Id: I7b0a859805a5979c3c886a6dbec703639fb374be
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 738572a4
......@@ -310,10 +310,43 @@ void CppToolsPlugin::test_completion()
actualCompletions.sort();
expectedCompletions.sort();
QEXPECT_FAIL("enum_in_function_in_struct_in_function", "doesn't work", Abort);
QEXPECT_FAIL("enum_in_function_in_struct_in_function", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_function_in_struct_in_function_cxx11", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_function_in_struct_in_function_anon", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_inside_member_function", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_inside_member_function_cxx11", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_inside_member_function_anon", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_class_accessed_in_member_func_cxx11", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_class_accessed_in_member_func_inline_cxx11", "QTCREATORBUG-13757", Abort);
QCOMPARE(actualCompletions, expectedCompletions);
}
static void enumTestCase(const QByteArray &tag, const QByteArray &source,
const QByteArray &prefix = QByteArray())
{
QByteArray fullSource = source;
fullSource.replace('$', "enum E { val1, val2, val3 };");
QTest::newRow(tag) << fullSource << (prefix + "val")
<< (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
QTest::newRow(tag + "_cxx11") << fullSource << (prefix + "E::")
<< (QStringList()
<< QLatin1String("E")
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
fullSource.replace("enum E ", "enum ");
QTest::newRow(tag + "_anon") << fullSource << (prefix + "val")
<< (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
}
void CppToolsPlugin::test_completion_data()
{
QTest::addColumn<QByteArray>("code");
......@@ -1762,103 +1795,94 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("staticFun2")
<< QLatin1String("m2"));
QTest::newRow("enum_inside_block_inside_function_cxx11_QTCREATORBUG5456") << _(
enumTestCase(
"enum_inside_block_inside_function",
"void foo()\n"
"{\n"
" {\n"
" $\n"
" @\n"
" }\n"
"}\n"
);
enumTestCase(
"enum_inside_function",
"void foo()\n"
"{\n"
" {\n"
" enum E { e1, e2, e3 };\n"
" @\n"
" }\n"
"}\n"
) << _("E::") << (QStringList()
<< QLatin1String("E")
<< QLatin1String("e1")
<< QLatin1String("e2")
<< QLatin1String("e3"));
QTest::newRow("enum_inside_function") << _(
"void foo()\n"
"{\n"
" enum E { val1, val2, val3 };\n"
" $\n"
" @\n"
"}\n"
) << _("val") << (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
);
QTest::newRow("anon_enum_inside_function") << _(
"void foo()\n"
"{\n"
" enum { val1, val2, val3 };\n"
" @\n"
"}\n"
) << _("val") << (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
QTest::newRow("enum_in_function_in_struct_in_function") << _(
enumTestCase(
"enum_in_function_in_struct_in_function",
"void foo()\n"
"{\n"
" struct S {\n"
" void fun()\n"
" {\n"
" enum E { val1, val2, val3 };\n"
" $\n"
" @\n"
" }\n"
" };\n"
"}\n"
) << _("val") << (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
);
QTest::newRow("enum_inside_function_cxx11_QTCREATORBUG5456") << _(
"void foo()\n"
enumTestCase(
"enum_inside_class",
"struct Foo\n"
"{\n"
" enum E { e1, e2, e3 };\n"
" $\n"
" @\n"
"}\n"
) << _("E::") << (QStringList()
<< QLatin1String("E")
<< QLatin1String("e1")
<< QLatin1String("e2")
<< QLatin1String("e3"));
"};\n",
"Foo::"
);
QTest::newRow("enum_inside_class") << _(
"struct Foo\n"
enumTestCase(
"enum_inside_namespace",
"namespace Ns\n"
"{\n"
" enum E { val1, val2, val3 };\n"
" $\n"
" @\n"
"};\n"
) << _("Foo::v") << (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
"}\n",
"Ns::"
);
QTest::newRow("enum_inside_class_cxx11") << _(
"struct Foo\n"
enumTestCase(
"enum_inside_member_function",
"class Foo { void func(); };\n"
"void Foo::func()\n"
"{\n"
" enum E { val1, val2, val3 };\n"
" $\n"
" @\n"
"}\n"
);
enumTestCase(
"enum_in_class_accessed_in_member_func_inline",
"class Foo\n"
"{\n"
" $\n"
" void func()\n"
" {\n"
" @\n"
" }\n"
"};\n"
) << _("Foo::E::") << (QStringList()
<< QLatin1String("E")
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
);
QTest::newRow("anon_enum_inside_class") << _(
"struct Foo\n"
enumTestCase(
"enum_in_class_accessed_in_member_func",
"class Foo\n"
"{\n"
" enum { val1, val2, val3 };\n"
" @\n"
" $\n"
" void func();\n"
"};\n"
) << _("Foo::v") << (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
"void Foo::func()\n"
"{\n"
" @\n"
"}\n"
);
QTest::newRow("nested_anonymous_with___attribute__") << _(
"struct Enclosing\n"
......@@ -1874,40 +1898,6 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("Enclosing")
<< QLatin1String("i"));
QTest::newRow("enum_inside_namespace") << _(
"namespace Ns\n"
"{\n"
" enum E { val1, val2, val3 };\n"
" @\n"
"}\n"
) << _("Ns::v") << (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
QTest::newRow("enum_inside_namespace_cxx11") << _(
"namespace Ns\n"
"{\n"
" enum E { val1, val2, val3 };\n"
" @\n"
"}\n"
) << _("Ns::E::") << (QStringList()
<< QLatin1String("E")
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
QTest::newRow("anon_enum_inside_namespace") << _(
"namespace Ns\n"
"{\n"
" enum { val1, val2, val3 };\n"
" @\n"
"}\n"
) << _("Ns::v") << (QStringList()
<< QLatin1String("val1")
<< QLatin1String("val2")
<< QLatin1String("val3"));
QTest::newRow("lambdaCalls_1") << _(
"struct S { int bar; };\n"
"void foo()\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment