Cleanup tst_qdatastream

Make NColorRoles constexpr and use static_assert() to verify that it
has a proper size.

Pick-to: 6.8
Change-Id: I40351e4815e248fe8cc07e906099172d5be531d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f12115e97ca8875a2577eebc67b8c8dc03441996)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ivan Solovev 2025-04-24 17:43:57 +02:00 committed by Qt Cherry-pick Bot
parent 0bd5917b8b
commit b7ad2f3a9f

View File

@ -276,7 +276,7 @@ private:
QString m_previousCurrent;
};
static int NColorRoles[] = {
static constexpr int NColorRoles[] = {
QPalette::NoRole, // No Version
QPalette::NoRole, // Qt_1_0
QPalette::HighlightedText + 1, // Qt_2_0
@ -300,9 +300,11 @@ static int NColorRoles[] = {
QPalette::PlaceholderText + 1, // Qt_6_0
QPalette::Accent + 1, // Qt_6_6
QPalette::Accent + 1, // Qt_6_7
0 // add the correct value for Qt_5_14 here later
};
// +1, because we start from "No Version"
static_assert(std::size(NColorRoles) == QDataStream::Qt_DefaultCompiledVersion + 1);
// Testing get/set functions
void tst_QDataStream::getSetCheck()
{