From a6a5d5b618c521f8d44497fe44b74ea677aac4a1 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 13 Mar 2024 14:50:21 +0100 Subject: [PATCH] Test that QBAV(QL1SV) and QBAV(QU8SV) constructors are constexpr Because they always were, but we never tested it. Change-Id: I503c65ed41b90d710c651d879a4477965f2ef0d6 Reviewed-by: Thiago Macieira Reviewed-by: Qt CI Bot --- .../qbytearrayview/tst_qbytearrayview.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp index 1d5a278dbf..894f0430dd 100644 --- a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp +++ b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp @@ -326,6 +326,38 @@ void tst_QByteArrayView::constExpr() const static_assert(sv.size() == 0); static_assert(sv.data() == nullptr); } + { + constexpr QByteArrayView bv(QLatin1StringView("Hello")); + static_assert(bv.size() == 5); + static_assert(!bv.empty()); + static_assert(!bv.isEmpty()); + static_assert(!bv.isNull()); + static_assert(*bv.data() == 'H'); + static_assert(bv[0] == 'H'); + static_assert(bv.at(0) == 'H'); + static_assert(bv.front() == 'H'); + static_assert(bv.first() == 'H'); + static_assert(bv[4] == 'o'); + static_assert(bv.at(4) == 'o'); + static_assert(bv.back() == 'o'); + static_assert(bv.last() == 'o'); + } + { + constexpr QByteArrayView bv(QUtf8StringView("Hello")); + static_assert(bv.size() == 5); + static_assert(!bv.empty()); + static_assert(!bv.isEmpty()); + static_assert(!bv.isNull()); + static_assert(*bv.data() == 'H'); + static_assert(bv[0] == 'H'); + static_assert(bv.at(0) == 'H'); + static_assert(bv.front() == 'H'); + static_assert(bv.first() == 'H'); + static_assert(bv[4] == 'o'); + static_assert(bv.at(4) == 'o'); + static_assert(bv.back() == 'o'); + static_assert(bv.last() == 'o'); + } } void tst_QByteArrayView::basics() const