diff options
author | Marc Mutz <[email protected]> | 2022-03-14 15:03:49 +0100 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2022-03-15 11:36:09 +0100 |
commit | 0aaada0ddc586d20a494880322f89d50c9d572c3 (patch) | |
tree | 8a933199c3ec42f456e9601abc421531136c9c37 | |
parent | 0d064328b2500928287dff502328a29d84444baa (diff) |
QString::asprintf: check that passing field widths as arguments works
Pick-to: 6.3 6.2 5.15
Change-Id: Ifb36179b9c26ce15378f10c2947c8cb1e38e10d4
Reviewed-by: Edward Welbourne <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
-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 52c0e071998..1aa60ec1ef8 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", |