Confirm QLatin1StringView can be constructed over arrays of unknown bounds

It can (unlike the other views).

Pick-to: 6.8 6.5 5.15
Task-number: QTBUG-112746
Change-Id: Id976429611c53f1c707de1d989c454507b8f4773
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 01f0305dc6f751d3eb4d1681a2f8f9f3165b547c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-12-09 11:01:39 +01:00 committed by Qt Cherry-pick Bot
parent f329dd4e16
commit 0c054f6844

View File

@ -14,11 +14,24 @@ Q_DECLARE_TYPEINFO(QLatin1StringViewContainer, Q_RELOCATABLE_TYPE);
QT_END_NAMESPACE QT_END_NAMESPACE
Q_DECLARE_METATYPE(QLatin1StringViewContainer) Q_DECLARE_METATYPE(QLatin1StringViewContainer)
// QTBUG-112746
namespace {
extern const char string_array[];
static void from_array_of_unknown_size()
{
auto sv = QLatin1StringView{string_array};
QCOMPARE(sv.size(), 3);
}
const char string_array[] = "abc\0def";
} // unnamed namespace
class tst_QLatin1StringView : public QObject class tst_QLatin1StringView : public QObject
{ {
Q_OBJECT Q_OBJECT
private Q_SLOTS: private Q_SLOTS:
void fromArraysOfUnknownSize() { from_array_of_unknown_size(); }
void constExpr(); void constExpr();
void construction(); void construction();
void userDefinedLiterals(); void userDefinedLiterals();