move static assertions into tests
This commit is contained in:
parent
d228bcaca2
commit
294b795005
|
@ -63,7 +63,6 @@ OBJECTS_DIR = obj
|
||||||
RCC_DIR = rcc
|
RCC_DIR = rcc
|
||||||
|
|
||||||
QSK_CONFIG += QskDll
|
QSK_CONFIG += QskDll
|
||||||
QSK_CONFIG += QskRequireConstexprLiterals
|
|
||||||
|
|
||||||
linux {
|
linux {
|
||||||
|
|
||||||
|
|
|
@ -12,31 +12,6 @@ QSK_QT_PRIVATE_BEGIN
|
||||||
#include <private/qdrawhelper_p.h>
|
#include <private/qdrawhelper_p.h>
|
||||||
QSK_QT_PRIVATE_END
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
#ifdef QSK_REQUIRE_CONSTEXPR_LITERALS
|
|
||||||
namespace QskRgb::literals::integral
|
|
||||||
{
|
|
||||||
// RGBA hex string to QRgb with defaulted alpha = 0xFF
|
|
||||||
static_assert( "#123456"_rgba == 0xFF123456, "invalid or not constexpr" );
|
|
||||||
static_assert( "#123456"_argb == 0xFF123456, "invalid or not constexpr" );
|
|
||||||
|
|
||||||
// ARGB hex string to QRgb with defaulted alpha = 0xFF
|
|
||||||
static_assert( "#AA112233"_argb == 0xAA112233, "invalid or not constexpr" );
|
|
||||||
static_assert( "#112233AA"_rgba == 0xAA112233, "invalid or not constexpr" );
|
|
||||||
|
|
||||||
// RGBA hex literal to QRgb with defaulted alpha = 0xFF
|
|
||||||
static_assert( 0x112233_rgba == 0xFF112233, "invalid or not constexpr" );
|
|
||||||
static_assert( 0xaabbcc_rgba == 0xFFAABBCC, "invalid or not constexpr" );
|
|
||||||
static_assert( 0xAABBCC_rgba == 0xFFAABBCC, "invalid or not constexpr" );
|
|
||||||
static_assert( 0x112233aa_rgba == 0xaa112233, "invalid or not constexpr" );
|
|
||||||
|
|
||||||
// ARGB hex literal to QRgb with defaulted alpha = 0xFF
|
|
||||||
static_assert( 0x112233_argb == 0xFF112233, "invalid or not constexpr" );
|
|
||||||
static_assert( 0xaabbcc_argb == 0xFFAABBCC, "invalid or not constexpr" );
|
|
||||||
static_assert( 0xAABBCC_argb == 0xFFAABBCC, "invalid or not constexpr" );
|
|
||||||
static_assert( 0x112233aa_argb == 0x112233aa, "invalid or not constexpr" );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
inline int value( int from, int to, qreal ratio )
|
inline int value( int from, int to, qreal ratio )
|
||||||
|
|
|
@ -8,7 +8,6 @@ greaterThan( QT_MAJOR_VERSION, 5 ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
contains(QSK_CONFIG, QskDll): DEFINES += QSK_MAKEDLL
|
contains(QSK_CONFIG, QskDll): DEFINES += QSK_MAKEDLL
|
||||||
contains(QSK_CONFIG, QskRequireConstexprLiterals): DEFINES += QSK_REQUIRE_CONSTEXPR_LITERALS
|
|
||||||
|
|
||||||
QSK_SUBDIRS = common graphic nodes controls layouts dialogs inputpanel
|
QSK_SUBDIRS = common graphic nodes controls layouts dialogs inputpanel
|
||||||
INCLUDEPATH *= $${QSK_SUBDIRS}
|
INCLUDEPATH *= $${QSK_SUBDIRS}
|
||||||
|
|
|
@ -2,6 +2,32 @@
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
|
||||||
|
#define QSK_REQUIRE_CONSTEXPR_LITERALS
|
||||||
|
#ifdef QSK_REQUIRE_CONSTEXPR_LITERALS
|
||||||
|
namespace QskRgb::literals::integral
|
||||||
|
{
|
||||||
|
// RGBA hex string to QRgb with defaulted alpha = 0xFF
|
||||||
|
static_assert( "#123456"_rgba == 0xFF123456, "invalid or not constexpr" );
|
||||||
|
static_assert( "#123456"_argb == 0xFF123456, "invalid or not constexpr" );
|
||||||
|
|
||||||
|
// ARGB hex string to QRgb with defaulted alpha = 0xFF
|
||||||
|
static_assert( "#AA112233"_argb == 0xAA112233, "invalid or not constexpr" );
|
||||||
|
static_assert( "#112233AA"_rgba == 0xAA112233, "invalid or not constexpr" );
|
||||||
|
|
||||||
|
// RGBA hex literal to QRgb with defaulted alpha = 0xFF
|
||||||
|
static_assert( 0x112233_rgba == 0xFF112233, "invalid or not constexpr" );
|
||||||
|
static_assert( 0xaabbcc_rgba == 0xFFAABBCC, "invalid or not constexpr" );
|
||||||
|
static_assert( 0xAABBCC_rgba == 0xFFAABBCC, "invalid or not constexpr" );
|
||||||
|
static_assert( 0x112233aa_rgba == 0xaa112233, "invalid or not constexpr" );
|
||||||
|
|
||||||
|
// ARGB hex literal to QRgb with defaulted alpha = 0xFF
|
||||||
|
static_assert( 0x112233_argb == 0xFF112233, "invalid or not constexpr" );
|
||||||
|
static_assert( 0xaabbcc_argb == 0xFFAABBCC, "invalid or not constexpr" );
|
||||||
|
static_assert( 0xAABBCC_argb == 0xFFAABBCC, "invalid or not constexpr" );
|
||||||
|
static_assert( 0x112233aa_argb == 0x112233aa, "invalid or not constexpr" );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void QskRgbLiterals::parsing_data()
|
void QskRgbLiterals::parsing_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn< QString >( "text" );
|
QTest::addColumn< QString >( "text" );
|
||||||
|
|
Loading…
Reference in New Issue