From 9a9a1a2a2e0c8bcbbaa178be3d67add3876df9b7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 25 Jun 2020 12:37:10 +0200 Subject: Port QString to qsizetype MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id9477ccfabadd578546bb265a9483f128efb6736 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira --- tests/auto/corelib/text/qstring/tst_qstring.cpp | 42 +++++++++++----------- .../corelib/text/qstringref/tst_qstringref.cpp | 22 ++++++------ .../auto/gui/text/qtextcursor/tst_qtextcursor.cpp | 24 ++++++------- 3 files changed, 44 insertions(+), 44 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 850def64ab..e1857e31ee 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -333,7 +333,7 @@ class tst_QString : public QObject template void insert_impl() const { do_apply1(MemFun(&QString::insert)); } template - void insert_impl() const { insert_impl(); } + void insert_impl() const { insert_impl(); } void insert_data(bool emptyIsNoop = false); class TransientDefaultLocale @@ -397,7 +397,7 @@ private slots: void prepend_qstringview_data() { prepend_data(true); } void prepend_qlatin1string() { prepend_impl(); } void prepend_qlatin1string_data() { prepend_data(true); } - void prepend_qcharstar_int() { prepend_impl, QString &(QString::*)(const QChar *, int)>(); } + void prepend_qcharstar_int() { prepend_impl, QString &(QString::*)(const QChar *, qsizetype)>(); } void prepend_qcharstar_int_data() { prepend_data(true); } void prepend_qchar() { prepend_impl, QString &(QString::*)(QChar)>(); } void prepend_qchar_data() { prepend_data(true); } @@ -416,7 +416,7 @@ private slots: void append_qstringview_data() { append_data(true); } void append_qlatin1string() { append_impl(); } void append_qlatin1string_data() { append_data(); } - void append_qcharstar_int() { append_impl, QString&(QString::*)(const QChar *, int)>(); } + void append_qcharstar_int() { append_impl, QString&(QString::*)(const QChar *, qsizetype)>(); } void append_qcharstar_int_data() { append_data(true); } void append_qchar() { append_impl(); } void append_qchar_data() { append_data(true); } @@ -453,19 +453,19 @@ private slots: void insert_qstring() { insert_impl(); } void insert_qstring_data() { insert_data(true); } - void insert_qstringview() { insert_impl(); } + void insert_qstringview() { insert_impl(); } void insert_qstringview_data() { insert_data(true); } - void insert_qlatin1string() { insert_impl(); } + void insert_qlatin1string() { insert_impl(); } void insert_qlatin1string_data() { insert_data(true); } - void insert_qcharstar_int() { insert_impl, QString &(QString::*)(int, const QChar*, int) >(); } + void insert_qcharstar_int() { insert_impl, QString &(QString::*)(qsizetype, const QChar*, qsizetype) >(); } void insert_qcharstar_int_data() { insert_data(true); } - void insert_qchar() { insert_impl, QString &(QString::*)(int, QChar)>(); } + void insert_qchar() { insert_impl, QString &(QString::*)(qsizetype, QChar)>(); } void insert_qchar_data() { insert_data(true); } void insert_qbytearray() { insert_impl(); } void insert_qbytearray_data() { insert_data(true); } - void insert_char() { insert_impl, QString &(QString::*)(int, QChar)>(); } + void insert_char() { insert_impl, QString &(QString::*)(qsizetype, QChar)>(); } void insert_char_data() { insert_data(true); } - void insert_charstar() { insert_impl(); } + void insert_charstar() { insert_impl(); } void insert_charstar_data() { insert_data(true); } void insert_special_cases(); @@ -1213,7 +1213,7 @@ void tst_QString::chop_data() QTest::newRow("data0") << original << 1 << QString("abc"); QTest::newRow("data1") << original << 0 << original; QTest::newRow("data2") << original << -1 << original; - QTest::newRow("data3") << original << original.size() << QString(); + QTest::newRow("data3") << original << int(original.size()) << QString(); QTest::newRow("data4") << original << 1000 << QString(); } @@ -1581,27 +1581,27 @@ void tst_QString::lastIndexOf_data() QString a = "ABCDEFGHIEfGEFG"; - QTest::newRow("-1") << a << "G" << a.size() - 1 << 14 << true; + QTest::newRow("-1") << a << "G" << int(a.size()) - 1 << 14 << true; QTest::newRow("1") << a << "G" << - 1 << 14 << true; QTest::newRow("2") << a << "G" << -3 << 11 << true; QTest::newRow("3") << a << "G" << -5 << 6 << true; QTest::newRow("4") << a << "G" << 14 << 14 << true; QTest::newRow("5") << a << "G" << 13 << 11 << true; - QTest::newRow("6") << a << "B" << a.size() - 1 << 1 << true; + QTest::newRow("6") << a << "B" << int(a.size()) - 1 << 1 << true; QTest::newRow("7") << a << "B" << - 1 << 1 << true; QTest::newRow("8") << a << "B" << 1 << 1 << true; QTest::newRow("9") << a << "B" << 0 << -1 << true; - QTest::newRow("10") << a << "G" << -1 << a.size()-1 << true; - QTest::newRow("11") << a << "G" << a.size()-1 << a.size()-1 << true; - QTest::newRow("12") << a << "G" << a.size() << -1 << true; + QTest::newRow("10") << a << "G" << -1 << int(a.size())-1 << true; + QTest::newRow("11") << a << "G" << int(a.size())-1 << int(a.size())-1 << true; + QTest::newRow("12") << a << "G" << int(a.size()) << -1 << true; QTest::newRow("13") << a << "A" << 0 << 0 << true; - QTest::newRow("14") << a << "A" << -1*a.size() << 0 << true; + QTest::newRow("14") << a << "A" << -1*int(a.size()) << 0 << true; QTest::newRow("15") << a << "efg" << 0 << -1 << false; - QTest::newRow("16") << a << "efg" << a.size() << -1 << false; - QTest::newRow("17") << a << "efg" << -1 * a.size() << -1 << false; - QTest::newRow("19") << a << "efg" << a.size() - 1 << 12 << false; + QTest::newRow("16") << a << "efg" << int(a.size()) << -1 << false; + QTest::newRow("17") << a << "efg" << -1 * int(a.size()) << -1 << false; + QTest::newRow("19") << a << "efg" << int(a.size()) - 1 << 12 << false; QTest::newRow("20") << a << "efg" << 12 << 12 << false; QTest::newRow("21") << a << "efg" << -12 << -1 << false; QTest::newRow("22") << a << "efg" << 11 << 9 << false; @@ -1610,8 +1610,8 @@ void tst_QString::lastIndexOf_data() QTest::newRow("25") << "asd" << "asdf" << -1 << -1 << false; QTest::newRow("26") << "" << QString() << -1 << -1 << false; - QTest::newRow("27") << a << "" << a.size() << a.size() << false; - QTest::newRow("28") << a << "" << a.size() + 10 << -1 << false; + QTest::newRow("27") << a << "" << int(a.size()) << int(a.size()) << false; + QTest::newRow("28") << a << "" << int(a.size()) + 10 << -1 << false; } void tst_QString::lastIndexOf() diff --git a/tests/auto/corelib/text/qstringref/tst_qstringref.cpp b/tests/auto/corelib/text/qstringref/tst_qstringref.cpp index f6a2326af1..021e7f2967 100644 --- a/tests/auto/corelib/text/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/text/qstringref/tst_qstringref.cpp @@ -483,27 +483,27 @@ void tst_QStringRef::lastIndexOf_data() QString a = "ABCDEFGHIEfGEFG"; - QTest::newRow("-1") << a << "G" << a.size() - 1 << 14 << true; + QTest::newRow("-1") << a << "G" << int(a.size()) - 1 << 14 << true; QTest::newRow("1") << a << "G" << - 1 << 14 << true; QTest::newRow("2") << a << "G" << -3 << 11 << true; QTest::newRow("3") << a << "G" << -5 << 6 << true; QTest::newRow("4") << a << "G" << 14 << 14 << true; QTest::newRow("5") << a << "G" << 13 << 11 << true; - QTest::newRow("6") << a << "B" << a.size() - 1 << 1 << true; + QTest::newRow("6") << a << "B" << int(a.size()) - 1 << 1 << true; QTest::newRow("7") << a << "B" << - 1 << 1 << true; QTest::newRow("8") << a << "B" << 1 << 1 << true; QTest::newRow("9") << a << "B" << 0 << -1 << true; - QTest::newRow("10") << a << "G" << -1 << a.size()-1 << true; - QTest::newRow("11") << a << "G" << a.size()-1 << a.size()-1 << true; - QTest::newRow("12") << a << "G" << a.size() << -1 << true; + QTest::newRow("10") << a << "G" << -1 << int(a.size())-1 << true; + QTest::newRow("11") << a << "G" << int(a.size())-1 << int(a.size())-1 << true; + QTest::newRow("12") << a << "G" << int(a.size()) << -1 << true; QTest::newRow("13") << a << "A" << 0 << 0 << true; - QTest::newRow("14") << a << "A" << -1*a.size() << 0 << true; + QTest::newRow("14") << a << "A" << -1*int(a.size()) << 0 << true; QTest::newRow("15") << a << "efg" << 0 << -1 << false; - QTest::newRow("16") << a << "efg" << a.size() << -1 << false; - QTest::newRow("17") << a << "efg" << -1 * a.size() << -1 << false; - QTest::newRow("19") << a << "efg" << a.size() - 1 << 12 << false; + QTest::newRow("16") << a << "efg" << int(a.size()) << -1 << false; + QTest::newRow("17") << a << "efg" << -1 * int(a.size()) << -1 << false; + QTest::newRow("19") << a << "efg" << int(a.size()) - 1 << 12 << false; QTest::newRow("20") << a << "efg" << 12 << 12 << false; QTest::newRow("21") << a << "efg" << -12 << -1 << false; QTest::newRow("22") << a << "efg" << 11 << 9 << false; @@ -512,8 +512,8 @@ void tst_QStringRef::lastIndexOf_data() QTest::newRow("25") << "asd" << "asdf" << -1 << -1 << false; QTest::newRow("26") << "" << QString() << -1 << -1 << false; - QTest::newRow("27") << a << "" << a.size() << a.size() << false; - QTest::newRow("28") << a << "" << a.size() + 10 << -1 << false; + QTest::newRow("27") << a << "" << int(a.size()) << int(a.size()) << false; + QTest::newRow("28") << a << "" << int(a.size()) + 10 << -1 << false; } void tst_QStringRef::lastIndexOf() diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp index 3da32a2842..4defd0da27 100644 --- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp @@ -1557,26 +1557,26 @@ void tst_QTextCursor::update_data() QTest::newRow("removeInsideSelection") << text << /*position*/ 0 - << /*anchor*/ text.length() + << /*anchor*/ int(text.length()) // delete 'big' << 6 << 6 + charsToDelete << QString() // don't insert anything, just remove << /*expectedPosition*/ 0 - << /*expectedAnchor*/ text.length() - charsToDelete + << /*expectedAnchor*/ int(text.length() - charsToDelete) ; text = "Hello big world"; charsToDelete = 3; QTest::newRow("removeInsideSelectionWithSwappedAnchorAndPosition") << text - << /*position*/ text.length() + << /*position*/ int(text.length()) << /*anchor*/ 0 // delete 'big' << 6 << 6 + charsToDelete << QString() // don't insert anything, just remove - << /*expectedPosition*/ text.length() - charsToDelete + << /*expectedPosition*/ int(text.length() - charsToDelete) << /*expectedAnchor*/ 0 ; @@ -1587,13 +1587,13 @@ void tst_QTextCursor::update_data() QTest::newRow("replaceInsideSelection") << text << /*position*/ 0 - << /*anchor*/ text.length() + << /*anchor*/ int(text.length()) // delete 'big' ... << 6 << 6 + charsToDelete << textToInsert // ... and replace 'big' with 'small' << /*expectedPosition*/ 0 - << /*expectedAnchor*/ text.length() - charsToDelete + textToInsert.length() + << /*expectedAnchor*/ int(text.length() - charsToDelete + textToInsert.length()) ; text = "Hello big world"; @@ -1601,13 +1601,13 @@ void tst_QTextCursor::update_data() textToInsert = "small"; QTest::newRow("replaceInsideSelectionWithSwappedAnchorAndPosition") << text - << /*position*/ text.length() + << /*position*/ int(text.length()) << /*anchor*/ 0 // delete 'big' ... << 6 << 6 + charsToDelete << textToInsert // ... and replace 'big' with 'small' - << /*expectedPosition*/ text.length() - charsToDelete + textToInsert.length() + << /*expectedPosition*/ int(text.length() - charsToDelete + textToInsert.length()) << /*expectedAnchor*/ 0 ; @@ -1616,14 +1616,14 @@ void tst_QTextCursor::update_data() charsToDelete = 3; QTest::newRow("removeBeforeSelection") << text - << /*position*/ text.length() - 5 - << /*anchor*/ text.length() + << /*position*/ int(text.length() - 5) + << /*anchor*/ int(text.length()) // delete 'big' << 6 << 6 + charsToDelete << QString() // don't insert anything, just remove - << /*expectedPosition*/ text.length() - 5 - charsToDelete - << /*expectedAnchor*/ text.length() - charsToDelete + << /*expectedPosition*/ int(text.length() - 5 - charsToDelete) + << /*expectedAnchor*/ int(text.length() - charsToDelete) ; text = "Hello big world"; -- cgit v1.2.3