| 2439 | } |
| 2440 | |
| 2441 | void TestDUChain::testSameFunctionDefinition() |
| 2442 | { |
| 2443 | QString source(QStringLiteral(R"( |
| 2444 | #include <stdio.h> |
| 2445 | #include <stdlib.h> |
| 2446 | |
| 2447 | void configure() |
| 2448 | { |
| 2449 | printf("do stuff\n"); |
| 2450 | } |
| 2451 | )")); |
| 2452 | |
| 2453 | QTemporaryDir dir; |
| 2454 | auto project = new TestProject(Path(dir.path()), this); |
| 2455 | m_projectController->addProject(project); |
| 2456 | |
| 2457 | TestFile file1(source, QStringLiteral("c"), project); |
| 2458 | TestFile file2(source, QStringLiteral("c"), project); |
| 2459 | TestFile file3(source, QStringLiteral("c"), project); |
| 2460 | |
| 2461 | file1.parse(TopDUContext::AllDeclarationsContextsAndUses); |
| 2462 | file2.parse(TopDUContext::AllDeclarationsContextsAndUses); |
| 2463 | file3.parse(TopDUContext::AllDeclarationsContextsAndUses); |
| 2464 | |
| 2465 | QVERIFY(file1.waitForParsed(1000)); |
| 2466 | QVERIFY(file2.waitForParsed(1000)); |
| 2467 | QVERIFY(file3.waitForParsed(1000)); |
| 2468 | |
| 2469 | auto checkFunctionDefinition = [] (TestFile & file) { |
| 2470 | DUChainReadLocker lock; |
| 2471 | QCOMPARE(file.topContext()->localDeclarations().count(), 1); |
| 2472 | auto configureFunc = file.topContext()->localDeclarations().first(); |
| 2473 | QCOMPARE(FunctionDefinition::definition(configureFunc), configureFunc); |
| 2474 | }; |
| 2475 | |
| 2476 | checkFunctionDefinition(file1); |
| 2477 | checkFunctionDefinition(file2); |
| 2478 | checkFunctionDefinition(file3); |
| 2479 | |
| 2480 | m_projectController->closeAllProjects(); |
| 2481 | } |
| 2482 | |
| 2483 | void TestDUChain::testSizeAlignOf() |
| 2484 | { |
nothing calls this directly
no test coverage detected