diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-03-14 15:03:49 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-16 19:12:56 +0000 |
commit | ba395fcd94201a6804e56986e56d4433eeeaa871 (patch) | |
tree | 06d94672f2201b4710b17b295a7e0d7ee179edda /tests/auto/corelib/text | |
parent | e00397efe39fcb86bca6b6e86034889bef7ba309 (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>
Diffstat (limited to 'tests/auto/corelib/text')
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 6 |
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 696b8159ac..878988d425 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -1301,6 +1301,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")); @@ -1320,6 +1323,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", |