summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-03-14 15:03:49 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-15 10:36:19 +0000
commit579193b2f0e6f569bef9311703113d738ae96736 (patch)
tree3b5fee180effbb08d123307ee779512239121aed
parentee02640f03bc07cd2e864e14e3ca33b6ab05d64f (diff)
QString::asprintf: check that passing field widths as arguments works
Change-Id: Ifb36179b9c26ce15378f10c2947c8cb1e38e10d4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 0aaada0ddc586d20a494880322f89d50c9d572c3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index da57694532..f17d174d63 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -1438,6 +1438,9 @@ void tst_QString::asprintfS()
QCOMPARE(QString::asprintf("%-10.10s", "Hello" ), QLatin1String("Hello "));
QCOMPARE(QString::asprintf("%-10.3s", "Hello" ), QLatin1String("Hel "));
QCOMPARE(QString::asprintf("%-5.5s", "Hello" ), QLatin1String("Hello"));
+ QCOMPARE(QString::asprintf("%*s", 4, "Hello"), QLatin1String("Hello"));
+ QCOMPARE(QString::asprintf("%*s", 10, "Hello"), QLatin1String(" Hello"));
+ QCOMPARE(QString::asprintf("%-*s", 10, "Hello"), QLatin1String("Hello "));
// Check utf8 conversion for %s
QCOMPARE(QString::asprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305"));
@@ -1457,6 +1460,9 @@ void tst_QString::asprintfS()
QCOMPARE(QString::asprintf("%-10.10ls", qUtf16Printable("Hello")), QLatin1String("Hello "));
QCOMPARE(QString::asprintf("%-10.3ls", qUtf16Printable("Hello")), QLatin1String("Hel "));
QCOMPARE(QString::asprintf("%-5.5ls", qUtf16Printable("Hello")), QLatin1String("Hello"));
+ QCOMPARE(QString::asprintf("%*ls", 4, qUtf16Printable("Hello")), QLatin1String("Hello"));
+ QCOMPARE(QString::asprintf("%*ls", 10, qUtf16Printable("Hello")), QLatin1String(" Hello"));
+ QCOMPARE(QString::asprintf("%-*ls", 10, qUtf16Printable("Hello")), QLatin1String("Hello "));
// Check utf16 is preserved for %ls
QCOMPARE(QString::asprintf("%ls",