MCPcopy Create free account
hub / github.com/KDE/kdevelop / testProblemSerialization

Method testProblemSerialization

kdevplatform/language/duchain/tests/test_duchain.cpp:791–866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789}
790
791void TestDUChain::testProblemSerialization()
792{
793 DUChain::self()->disablePersistentStorage(false);
794
795 auto parent = ProblemPointer{new Problem};
796 parent->setDescription(QStringLiteral("parent"));
797
798 auto child = ProblemPointer{new Problem};
799 child->setDescription(QStringLiteral("child"));
800 parent->addDiagnostic(child);
801
802 const IndexedString url("/my/test/file");
803
804 TopDUContextPointer smartTop;
805
806 { // serialize
807 DUChainWriteLocker lock;
808 auto file = new ParsingEnvironmentFile(url);
809 auto top = new TopDUContext(url, {}, file);
810
811 top->addProblem(parent);
812 QCOMPARE(top->problems().size(), 1);
813 auto p = top->problems().at(0);
814 QCOMPARE(p->description(), QStringLiteral("parent"));
815 QCOMPARE(p->diagnostics().size(), 1);
816 auto c = p->diagnostics().first();
817 QCOMPARE(c->description(), QStringLiteral("child"));
818
819 DUChain::self()->addDocumentChain(top);
820 QVERIFY(DUChain::self()->chainForDocument(url));
821 smartTop = top;
822 }
823
824 DUChain::self()->storeToDisk();
825
826 ProblemPointer parent_deserialized;
827 IProblem::Ptr child_deserialized;
828
829 { // deserialize
830 DUChainWriteLocker lock;
831 QVERIFY(!smartTop);
832 auto top = DUChain::self()->chainForDocument(url);
833 QVERIFY(top);
834 smartTop = top;
835 QCOMPARE(top->problems().size(), 1);
836 parent_deserialized = top->problems().at(0);
837 QCOMPARE(parent_deserialized->diagnostics().size(), 1);
838 child_deserialized = parent_deserialized->diagnostics().first();
839
840 QCOMPARE(parent_deserialized->description(), QStringLiteral("parent"));
841 QCOMPARE(child_deserialized->description(), QStringLiteral("child"));
842
843 top->clearProblems();
844 QVERIFY(top->problems().isEmpty());
845
846 QCOMPARE(parent_deserialized->description(), QStringLiteral("parent"));
847 QCOMPARE(child_deserialized->description(), QStringLiteral("child"));
848

Callers

nothing calls this directly

Calls 15

addDocumentChainMethod · 0.80
chainForDocumentMethod · 0.80
storeToDiskMethod · 0.80
removeDocumentChainMethod · 0.80
setDescriptionMethod · 0.45
addDiagnosticMethod · 0.45
addProblemMethod · 0.45
sizeMethod · 0.45
problemsMethod · 0.45
atMethod · 0.45
descriptionMethod · 0.45

Tested by

no test coverage detected