From 1b567854e4787ac591f8039c88e8cd8a44edaef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 29 Sep 2016 16:46:29 +0200 Subject: Use extreme values in QMetaType/QSettings test data By using _MIN for signed values, and _MAX for unsigned values, we may detect conversion issues when serializing QVariants using QSettings. Change-Id: I3ce58ba4b93f791f75c7ae44d1fd5030f07b2f25 Reviewed-by: Thiago Macieira --- .../auto/corelib/kernel/qmetatype/tst_qmetatype.h | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h index a85f575dc4..93ff33bb67 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h @@ -32,6 +32,7 @@ #define TST_QMETATYPE_H #include +#include #define FOR_EACH_PRIMITIVE_METATYPE(F) \ QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F) \ @@ -97,16 +98,16 @@ template<> struct TestValueFactory { static QString *create() { return new QString(QString::fromLatin1("QString")); } }; template<> struct TestValueFactory { - static int *create() { return new int(0x12345678); } + static int *create() { return new int(INT_MIN); } }; template<> struct TestValueFactory { - static uint *create() { return new uint(0x12345678); } + static uint *create() { return new uint(UINT_MAX); } }; template<> struct TestValueFactory { static bool *create() { return new bool(true); } }; template<> struct TestValueFactory { - static double *create() { return new double(3.14); } + static double *create() { return new double(DBL_MIN); } }; template<> struct TestValueFactory { static QByteArray *create() { return new QByteArray(QByteArray("QByteArray")); } @@ -127,28 +128,28 @@ template<> struct TestValueFactory { static QChar *create() { return new QChar(QChar('q')); } }; template<> struct TestValueFactory { - static long *create() { return new long(0x12345678); } + static long *create() { return new long(LONG_MIN); } }; template<> struct TestValueFactory { - static short *create() { return new short(0x1234); } + static short *create() { return new short(SHRT_MIN); } }; template<> struct TestValueFactory { static char *create() { return new char('c'); } }; template<> struct TestValueFactory { - static ulong *create() { return new ulong(0x12345678); } + static ulong *create() { return new ulong(ULONG_MAX); } }; template<> struct TestValueFactory { - static ushort *create() { return new ushort(0x1234); } + static ushort *create() { return new ushort(USHRT_MAX); } }; template<> struct TestValueFactory { - static signed char *create() { return new signed char(-12); } + static signed char *create() { return new signed char(CHAR_MIN); } }; template<> struct TestValueFactory { - static uchar *create() { return new uchar('u'); } + static uchar *create() { return new uchar(UCHAR_MAX); } }; template<> struct TestValueFactory { - static float *create() { return new float(3.14f); } + static float *create() { return new float(FLT_MIN); } }; template<> struct TestValueFactory { static QObject * *create() { return new QObject *(0); } @@ -157,10 +158,10 @@ template<> struct TestValueFactory { static void * *create() { return new void *(0); } }; template<> struct TestValueFactory { - static qlonglong *create() { return new qlonglong(0x12345678); } + static qlonglong *create() { return new qlonglong(LLONG_MIN); } }; template<> struct TestValueFactory { - static qulonglong *create() { return new qulonglong(0x12345678); } + static qulonglong *create() { return new qulonglong(ULLONG_MAX); } }; template<> struct TestValueFactory { static QStringList *create() { return new QStringList(QStringList() << "Q" << "t"); } -- cgit v1.2.3