Commit 149242ee authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

CppEditor: Make doxygen tests data-driven

Change-Id: I7b859a7304cb2a6e19eabf114345b31fe11d98b1
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 7a3ff861
......@@ -51,6 +51,9 @@ using namespace CPlusPlus;
using namespace CppEditor::Internal;
namespace {
typedef QByteArray _;
/**
* Encapsulates the whole process of setting up an editor,
* pressing ENTER and checking the result.
......@@ -140,205 +143,149 @@ void TestCase::run(const QByteArray &expected, int undoCount)
}
} // anonymous namespace
void CppEditorPlugin::test_doxygen_comments_qt_style()
void CppEditorPlugin::test_doxygen_comments_data()
{
const QByteArray given =
QTest::addColumn<QByteArray>("given");
QTest::addColumn<QByteArray>("expected");
QTest::newRow("qt_style") << _(
"bool preventFolding;\n"
"/*!|\n"
"int a;\n"
;
const QByteArray expected =
) << _(
"bool preventFolding;\n"
"/*!\n"
" * \\brief a\n"
" */\n"
"int a;\n"
;
TestCase data(given);
data.run(expected);
}
);
void CppEditorPlugin::test_doxygen_comments_qt_style_continuation()
{
const QByteArray given =
QTest::newRow("qt_style_continuation") << _(
"bool preventFolding;\n"
"/*!\n"
" * \\brief a|\n"
" */\n"
"int a;\n"
;
const QByteArray expected =
) << _(
"bool preventFolding;\n"
"/*!\n"
" * \\brief a\n"
" *\n"
" */\n"
"int a;\n"
;
TestCase data(given);
data.run(expected);
}
);
void CppEditorPlugin::test_doxygen_comments_java_style()
{
const QByteArray given =
QTest::newRow("java_style") << _(
"bool preventFolding;\n"
"/**|\n"
"int a;\n"
;
const QByteArray expected =
) << _(
"bool preventFolding;\n"
"/**\n"
" * @brief a\n"
" */\n"
"int a;\n"
;
TestCase data(given);
data.run(expected);
}
);
void CppEditorPlugin::test_doxygen_comments_java_style_continuation()
{
const QByteArray given =
QTest::newRow("java_style_continuation") << _(
"bool preventFolding;\n"
"/**\n"
" * @brief a|\n"
" */\n"
"int a;\n"
;
const QByteArray expected =
) << _(
"bool preventFolding;\n"
"/**\n"
" * @brief a\n"
" *\n"
" */\n"
"int a;\n"
;
TestCase data(given);
data.run(expected);
}
);
void CppEditorPlugin::test_doxygen_comments_cpp_styleA()
{
const QByteArray given =
QTest::newRow("cpp_styleA") << _(
"bool preventFolding;\n"
"///|\n"
"int a;\n"
;
const QByteArray expected =
) << _(
"bool preventFolding;\n"
"///\n"
"/// \\brief a\n"
"///\n"
"int a;\n"
;
TestCase data(given);
data.run(expected);
}
);
void CppEditorPlugin::test_doxygen_comments_cpp_styleB()
{
const QByteArray given =
QTest::newRow("cpp_styleB") << _(
"bool preventFolding;\n"
"//!|\n"
"int a;\n"
;
const QByteArray expected =
) << _(
"bool preventFolding;\n"
"//!\n"
"//! \\brief a\n"
"//!\n"
"int a;\n"
;
TestCase data(given);
data.run(expected);
}
);
void CppEditorPlugin::test_doxygen_comments_cpp_styleA_continuation()
{
const QByteArray given =
QTest::newRow("cpp_styleA_continuation") << _(
"bool preventFolding;\n"
"///\n"
"/// \\brief a|\n"
"///\n"
"int a;\n"
;
const QByteArray expected =
) << _(
"bool preventFolding;\n"
"///\n"
"/// \\brief a\n"
"///\n"
"///\n"
"int a;\n"
;
TestCase data(given);
data.run(expected);
}
);
/// test cpp style doxygen comment when inside a indented scope
void CppEditorPlugin::test_doxygen_comments_cpp_styleA_indented()
{
const QByteArray given =
/// test cpp style doxygen comment when inside a indented scope
QTest::newRow("cpp_styleA_indented") << _(
" bool preventFolding;\n"
" ///|\n"
" int a;\n"
;
const QByteArray expected =
) << _(
" bool preventFolding;\n"
" ///\n"
" /// \\brief a\n"
" ///\n"
" int a;\n"
;
TestCase data(given);
data.run(expected);
}
);
/// test cpp style doxygen comment continuation when inside a indented scope
void CppEditorPlugin::test_doxygen_comments_cpp_styleA_indented_continuation()
{
const QByteArray given =
/// test cpp style doxygen comment continuation when inside a indented scope
QTest::newRow("cpp_styleA_indented_continuation") << _(
" bool preventFolding;\n"
" ///\n"
" /// \\brief a|\n"
" ///\n"
" int a;\n"
;
const QByteArray expected =
) << _(
" bool preventFolding;\n"
" ///\n"
" /// \\brief a\n"
" ///\n"
" ///\n"
" int a;\n"
;
);
TestCase data(given);
data.run(expected);
}
void CppEditorPlugin::test_doxygen_comments_cpp_styleA_corner_case()
{
const QByteArray given =
QTest::newRow("cpp_styleA_corner_case") << _(
"bool preventFolding;\n"
"///\n"
"void d(); ///|\n"
;
const QByteArray expected =
) << _(
"bool preventFolding;\n"
"///\n"
"void d(); ///\n"
"\n"
;
);
}
void CppEditorPlugin::test_doxygen_comments()
{
QFETCH(QByteArray, given);
QFETCH(QByteArray, expected);
TestCase data(given);
data.run(expected);
}
......@@ -117,16 +117,8 @@ private slots:
void test_FollowSymbolUnderCursor_virtualFunctionCall();
void test_FollowSymbolUnderCursor_virtualFunctionCall_multipleDocuments();
void test_doxygen_comments_qt_style();
void test_doxygen_comments_qt_style_continuation();
void test_doxygen_comments_java_style();
void test_doxygen_comments_java_style_continuation();
void test_doxygen_comments_cpp_styleA();
void test_doxygen_comments_cpp_styleB();
void test_doxygen_comments_cpp_styleA_indented();
void test_doxygen_comments_cpp_styleA_continuation();
void test_doxygen_comments_cpp_styleA_indented_continuation();
void test_doxygen_comments_cpp_styleA_corner_case();
void test_doxygen_comments_data();
void test_doxygen_comments();
void test_quickfix_CompleteSwitchCaseStatement_basic1();
void test_quickfix_CompleteSwitchCaseStatement_basic2();
......
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