From 57d36d3f0cbbf641bb67f7f183edcb52aa15180d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 20 Jan 2014 22:15:09 -0800 Subject: Fix mix of new[] / malloc in QTest::toHexRepresentation toHexRepresentation is used in QTest::toString(), whose results are deallocated with free(). So we shouldn't allocate with new[]. Change-Id: I3e9d35b3f28a1b9bfe740a13b5daa414b67853c6 Reviewed-by: Olivier Goffart Reviewed-by: Robin Burchell --- src/testlib/qtestcase.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index e170d2a044..2c8b7b20b7 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1893,7 +1893,7 @@ char *toHexRepresentation(const char *ba, int length) if (length > maxLen) { const int size = len * 3 + 4; - result = new char[size]; + result = static_cast(malloc(size)); char *const forElipsis = result + size - 5; forElipsis[0] = ' '; @@ -1901,10 +1901,9 @@ char *toHexRepresentation(const char *ba, int length) forElipsis[2] = '.'; forElipsis[3] = '.'; result[size - 1] = '\0'; - } - else { + } else { const int size = len * 3; - result = new char[size]; + result = static_cast(malloc(size)); result[size - 1] = '\0'; } -- cgit v1.2.3 From 2d8028d696a86102a7753f9d59fb41f4170181a8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jan 2014 20:37:16 -0800 Subject: Fix the alignment for non-ASCII strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d040681b6f3d03b349e9b9487fe89a611d03ee3c added support for aligning the test results for easier side-by-side comparison of the actual and expected values. However, it didn't take into account multibyte strings. That is, we would see: FAIL! tst_testcase::testcase: Compared values are not the same Actual (QString("é")): F0O Expected (expected) : FOO We use mbstowcs (multibyte string to wide char string) that calculates the length in wide chars of the output string. That's roughly equivalent to QString::fromLocal8Bit(string).toUcs4().size(). Change-Id: Ic2649951c50e05143da32a7fbef00a01e385c542 Reviewed-by: Jason McDonald --- src/testlib/qtestresult.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp index d94b2bf85c..a9abca0ef8 100644 --- a/src/testlib/qtestresult.cpp +++ b/src/testlib/qtestresult.cpp @@ -46,8 +46,10 @@ #include #include +#include #include #include +#include QT_BEGIN_NAMESPACE @@ -268,8 +270,8 @@ bool QTestResult::compare(bool success, const char *failureMsg, if (success && QTest::expectFailMode) { qsnprintf(msg, 1024, "QCOMPARE(%s, %s) returned TRUE unexpectedly.", actual, expected); } else if (val1 || val2) { - size_t len1 = strlen(actual); - size_t len2 = strlen(expected); + size_t len1 = mbstowcs(NULL, actual, 0); + size_t len2 = mbstowcs(NULL, expected, 0); qsnprintf(msg, 1024, "%s\n Actual (%s)%*s %s\n Expected (%s)%*s %s", failureMsg, actual, qMax(len1, len2) - len1 + 1, ":", val1 ? val1 : "", -- cgit v1.2.3 From 4fab72a5eb19d34eb9b96a192fd901ddf7db2c92 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 12 Dec 2013 10:22:34 +0100 Subject: Doc: corrected broken links Links fixed: Extra Filters Basic Tools blockingfortuneclient Thread Support Drag and drop examples qBinaryFind qmake common project types imagegestures Task-number: QTBUG-34749 Change-Id: Ib93dda00716dc596db327fee5b97e110a9f27fa7 Reviewed-by: Martin Smith --- src/testlib/doc/qttestlib.qdocconf | 2 +- src/testlib/doc/src/qttestlib-manual.qdoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf index 250d237f12..92e5c97aab 100644 --- a/src/testlib/doc/qttestlib.qdocconf +++ b/src/testlib/doc/qttestlib.qdocconf @@ -27,7 +27,7 @@ qhp.QtTestLib.subprojects.classes.sortPages = true tagfile = ../../../doc/qttestlib/qttestlib.tags -depends += qtcore qtdoc qtwidgets qtgui qtquick +depends += qtcore qtdoc qtwidgets qtgui qmake qtquick headerdirs += .. diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index 613d2c220c..bdd9769175 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -120,7 +120,7 @@ \snippet code/doc_src_qtestlib.pro 2 - See \l{qmake Common Projects#building-a-testcase}{the qmake manual} for + See the \l{Building a Testcase}{qmake manual} for more information about \c{make check}. If you are using other build tools, make sure that you add the location -- cgit v1.2.3 From 89bb20b937495fa63741241c8ea9780492fb6e45 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 23 Jan 2014 04:06:10 +0100 Subject: Revert "Fix mix of new[] / malloc in QTest::toHexRepresentation" This reverts commit e8f73d656cf13d440a3a83980e05c6b117489e40. The original was correct: qtestcase.cpp:282 and 283 use delete[]. Change-Id: I668e17f500edcf9f1406553a160f6f5518dee148 Reviewed-by: Olivier Goffart --- src/testlib/qtestcase.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 2c8b7b20b7..e170d2a044 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1893,7 +1893,7 @@ char *toHexRepresentation(const char *ba, int length) if (length > maxLen) { const int size = len * 3 + 4; - result = static_cast(malloc(size)); + result = new char[size]; char *const forElipsis = result + size - 5; forElipsis[0] = ' '; @@ -1901,9 +1901,10 @@ char *toHexRepresentation(const char *ba, int length) forElipsis[2] = '.'; forElipsis[3] = '.'; result[size - 1] = '\0'; - } else { + } + else { const int size = len * 3; - result = static_cast(malloc(size)); + result = new char[size]; result[size - 1] = '\0'; } -- cgit v1.2.3 From 0b26ad05bbadeef493317c994cc7ccb53b0a612c Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 23 Jan 2014 16:10:26 +0100 Subject: Doc: corrected link/example errors Update pro files after move gestures folder Update snippet statements Corrected path in imagegestures.pro Task-number: QTBUG-34749 Change-Id: Icc19908914e36507e412ab63bf0cc2809aa48e17 Reviewed-by: Jerome Pasion --- src/testlib/doc/src/qttest-index.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/testlib') diff --git a/src/testlib/doc/src/qttest-index.qdoc b/src/testlib/doc/src/qttest-index.qdoc index 4cf0726429..8dc51f8696 100644 --- a/src/testlib/doc/src/qttest-index.qdoc +++ b/src/testlib/doc/src/qttest-index.qdoc @@ -56,7 +56,7 @@ \list \li \l{Qt Test C++ Classes}{C++ Classes} - \li \l{Qt Quick Test}{QML Types} + \li \l{Qt Quick Test QML Types}{QML Types} \endlist */ -- cgit v1.2.3