From fd714ec5aa3418b55c7c8bf7d77cbdb2a6798135 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 3 May 2011 15:47:55 +1000 Subject: Remove Q_ASSERT from QTextOdfWriter autotest If the tag can't be found in the data, return an empty string rather than asserting, so that the test fails gracefully. Change-Id: I536f08c9c3e942817680849d96d035999d4994db Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern (cherry picked from commit a88dd1c5f62b5ded8ea0d76d185127ef28549c72) --- tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp') diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp index 997cd683c5..ffce9a21eb 100644 --- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp @@ -114,11 +114,14 @@ QString tst_QTextOdfWriter::getContentFromXml() xmlWriter->writeEndDocument(); buffer->close(); QString stringContent = QString::fromUtf8(buffer->data()); + QString ret; int index = stringContent.indexOf("', index); - stringContent = stringContent.mid(index+1, stringContent.length() - index - 10); - return stringContent; + if (index > 0) { + index = stringContent.indexOf('>', index); + if (index > 0) + ret = stringContent.mid(index+1, stringContent.length() - index - 10); + } + return ret; } void tst_QTextOdfWriter::testWriteParagraph_data() -- cgit v1.2.3