diff options
Diffstat (limited to 'tests/auto/xml/dom/qdom/tst_qdom.cpp')
-rw-r--r-- | tests/auto/xml/dom/qdom/tst_qdom.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index 4cf48a9f4b..b73dbc49e2 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QBuffer> @@ -15,6 +15,7 @@ #include <QtXml> #include <QVariant> #include <cmath> +#include <QtXml/private/qdom_p.h> QT_FORWARD_DECLARE_CLASS(QDomDocument) QT_FORWARD_DECLARE_CLASS(QDomNode) @@ -106,6 +107,7 @@ private slots: void DTDInternalSubset_data() const; void QTBUG49113_dontCrashWithNegativeIndex() const; void standalone(); + void splitTextLeakMemory() const; void cleanupTestCase() const; @@ -2315,5 +2317,19 @@ void tst_QDom::DTDInternalSubset_data() const << internalSubset0; } +void tst_QDom::splitTextLeakMemory() const +{ + QDomDocument doc; + QDomElement top = doc.createElement("top"); + QDomText text = doc.createTextNode("abcdefgh"); + top.appendChild(text); + QDomText end = text.splitText(2); + QCOMPARE(text.data(), "ab"_L1); + QCOMPARE(end.data(), "cdefgh"_L1); + // only the parent node and the document have a reference on the nodes + QCOMPARE(text.impl->ref.loadRelaxed(), 2); + QCOMPARE(end.impl->ref.loadRelaxed(), 2); +} + QTEST_MAIN(tst_QDom) #include "tst_qdom.moc" |