diff --git a/tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp b/tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp index d8706b8a873..8c129a93c71 100644 --- a/tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp +++ b/tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp @@ -410,17 +410,17 @@ private Q_SLOTS: void fromChar16T() const { fromCharacter(u'ä', 1); } void fromUShort() const { fromCharacter(ushort(0xE4), 1); } void fromChar32T() const { - fromCharacter(U'ä', 1); - fromCharacter(U'\x1F0A0', 2); // U+1F0A0: PLAYING CARD BACK + fromCharacter(U'ä', 1, true); + fromCharacter(U'\x1F0A0', 2, true); // U+1F0A0: PLAYING CARD BACK } void fromWCharT() const { ONLY_WIN(fromCharacter(L'ä', 1)); // should work on Unix, too (char32_t does) } void fromQChar() const { fromCharacter(QChar(u'ä'), 1); } - void fromQLatin1Char() const { fromCharacter(QLatin1Char('\xE4'), 1); } + void fromQLatin1Char() const { fromCharacter(QLatin1Char('\xE4'), 1, true); } void fromQCharSpecialCharacter() const { - fromCharacter(QChar::ReplacementCharacter, 1); - fromCharacter(QChar::LastValidCodePoint, 1); + fromCharacter(QChar::ReplacementCharacter, 1, true); + fromCharacter(QChar::LastValidCodePoint, 1, true); } void fromCharacterSpecial() const; @@ -463,7 +463,7 @@ private: template void fromLiteral(const Char *arg) const; template - void fromCharacter(Char arg, qsizetype expectedSize) const; + void fromCharacter(Char arg, qsizetype expectedSize, bool expectConversion = false) const; template void fromRange() const; template @@ -747,8 +747,11 @@ void tst_QAnyStringView::fromLiteral(const Char *arg) const conversion_tests(arg); } +template +const void *as_const_void_star(T *p) { return p; } + template -void tst_QAnyStringView::fromCharacter(Char arg, qsizetype expectedSize) const +void tst_QAnyStringView::fromCharacter(Char arg, qsizetype expectedSize, bool expectConversion) const { // Need to re-create a new QASV(arg) each time, QASV(Char).data() dangles // after the end of the Full Expression: @@ -758,6 +761,11 @@ void tst_QAnyStringView::fromCharacter(Char arg, qsizetype expectedSize) const QCOMPARE(QAnyStringView(arg).size(), expectedSize); + if (expectConversion) + QCOMPARE_NE(QAnyStringView(arg).data(), as_const_void_star(std::addressof(arg))); + else + QCOMPARE_EQ(QAnyStringView(arg).data(), as_const_void_star(std::addressof(arg))); + // QCOMPARE(QAnyStringView(arg), arg); // not all pairs compile, so do it manually: // Check implicit conversion: