AutoTest: Support data-driven test with fixture

Boost has a special macro to indicate a data-driven test
with support for a fixture class. Find and handle these
test cases as well.

Change-Id: I9f3d22b7b2df35edfdf0a017da3005f67ade017f
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-06-03 14:18:48 +02:00
parent c23fe4f403
commit c20824f5ff
2 changed files with 10 additions and 1 deletions

View File

@@ -112,6 +112,9 @@ void BoostCodeParser::handleIdentifier()
handleTestCase(TestCaseType::Fixture);
} else if (identifier == "BOOST_DATA_TEST_CASE") {
handleTestCase(TestCaseType::Data);
} else if (identifier == "BOOST_DATA_TEST_CASE_F") {
m_currentState.setFlag(BoostTestTreeItem::Fixture);
handleTestCase(TestCaseType::Data);
} else if (identifier == "BOOST_TEST_DECORATOR") {
handleDecorator();
}
@@ -195,6 +198,12 @@ void BoostCodeParser::handleTestCase(TestCaseType testCaseType)
}
if (testCaseType == TestCaseType::Parameter)
m_currentState |= BoostTestTreeItem::Parameterized;
} else if (m_currentState.testFlag(BoostTestTreeItem::Fixture)) {
// ignore first parameter (fixture) and first comma
if (!skipCommentsUntil(T_IDENTIFIER))
return;
if (!skipCommentsUntil(T_COMMA))
return;
}
if (!skipCommentsUntil(T_IDENTIFIER))
return;

View File

@@ -40,7 +40,7 @@ namespace BoostTestUtils {
static const QStringList relevant = {
QStringLiteral("BOOST_AUTO_TEST_CASE"), QStringLiteral("BOOST_TEST_CASE"),
QStringLiteral("BOOST_DATA_TEST_CASE"), QStringLiteral("BOOST_FIXTURE_TEST_CASE"),
QStringLiteral("BOOST_PARAM_TEST_CASE")
QStringLiteral("BOOST_PARAM_TEST_CASE"), QStringLiteral("BOOST_DATA_TEST_CASE_F")
};
bool isBoostTestMacro(const QString &macro)