| 44 | } |
| 45 | |
| 46 | bool CTestSuite::findCaseDeclarations(const QVector<Declaration*> &classDeclarations) |
| 47 | { |
| 48 | for (Declaration* decl : classDeclarations) { |
| 49 | qCDebug(CMAKE_TESTING) << "Found declaration" << decl->toString() |
| 50 | << decl->identifier().identifier().byteArray(); |
| 51 | |
| 52 | const auto* const function = dynamic_cast<ClassFunctionDeclaration*>(decl); |
| 53 | if (!function || !(function->accessPolicy() == Declaration::Private && function->isSlot())) { |
| 54 | continue; |
| 55 | } |
| 56 | QString name = function->qualifiedIdentifier().last().toString(); |
| 57 | qCDebug(CMAKE_TESTING) << "Found private slot in test" << name; |
| 58 | |
| 59 | if (name.endsWith(QLatin1String("_data"))) { |
| 60 | continue; |
| 61 | } |
| 62 | |
| 63 | const auto functionType = function->type<FunctionType>(); |
| 64 | if (!functionType || functionType->indexedArgumentsSize() > 0) { |
| 65 | // function declarations with arguments are not valid test functions |
| 66 | continue; |
| 67 | } |
| 68 | qCDebug(CMAKE_TESTING) << "Found test case function declaration" << function->identifier().toString(); |
| 69 | |
| 70 | if (name != QLatin1String("initTestCase") && name != QLatin1String("cleanupTestCase") && |
| 71 | name != QLatin1String("init") && name != QLatin1String("cleanup")) |
| 72 | { |
| 73 | m_cases << name; |
| 74 | } else { |
| 75 | continue; |
| 76 | } |
| 77 | |
| 78 | const auto* def = FunctionDefinition::definition(decl); |
| 79 | m_declarations[name] = def ? IndexedDeclaration(def) : IndexedDeclaration(function); |
| 80 | } |
| 81 | return !m_declarations.isEmpty(); |
| 82 | } |
| 83 | |
| 84 | void CTestSuite::loadDeclarations(const IndexedString& document, const KDevelop::ReferencedTopDUContext& ref) |
| 85 | { |
nothing calls this directly
no test coverage detected