summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-09-29 16:46:29 +0200
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2016-10-05 20:31:23 +0000
commit1b567854e4787ac591f8039c88e8cd8a44edaef7 (patch)
tree9c21312c4bf9fb2df7faefc88d1c3e94d253ab0e
parent89842b97d74d1824240d3cc35950c92aa011a8ac (diff)
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 <thiago.macieira@intel.com>
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h25
1 files changed, 13 insertions, 12 deletions
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 <qmetatype.h>
+#include <float.h>
#define FOR_EACH_PRIMITIVE_METATYPE(F) \
QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F) \
@@ -97,16 +98,16 @@ template<> struct TestValueFactory<QMetaType::QString> {
static QString *create() { return new QString(QString::fromLatin1("QString")); }
};
template<> struct TestValueFactory<QMetaType::Int> {
- static int *create() { return new int(0x12345678); }
+ static int *create() { return new int(INT_MIN); }
};
template<> struct TestValueFactory<QMetaType::UInt> {
- static uint *create() { return new uint(0x12345678); }
+ static uint *create() { return new uint(UINT_MAX); }
};
template<> struct TestValueFactory<QMetaType::Bool> {
static bool *create() { return new bool(true); }
};
template<> struct TestValueFactory<QMetaType::Double> {
- static double *create() { return new double(3.14); }
+ static double *create() { return new double(DBL_MIN); }
};
template<> struct TestValueFactory<QMetaType::QByteArray> {
static QByteArray *create() { return new QByteArray(QByteArray("QByteArray")); }
@@ -127,28 +128,28 @@ template<> struct TestValueFactory<QMetaType::QChar> {
static QChar *create() { return new QChar(QChar('q')); }
};
template<> struct TestValueFactory<QMetaType::Long> {
- static long *create() { return new long(0x12345678); }
+ static long *create() { return new long(LONG_MIN); }
};
template<> struct TestValueFactory<QMetaType::Short> {
- static short *create() { return new short(0x1234); }
+ static short *create() { return new short(SHRT_MIN); }
};
template<> struct TestValueFactory<QMetaType::Char> {
static char *create() { return new char('c'); }
};
template<> struct TestValueFactory<QMetaType::ULong> {
- static ulong *create() { return new ulong(0x12345678); }
+ static ulong *create() { return new ulong(ULONG_MAX); }
};
template<> struct TestValueFactory<QMetaType::UShort> {
- static ushort *create() { return new ushort(0x1234); }
+ static ushort *create() { return new ushort(USHRT_MAX); }
};
template<> struct TestValueFactory<QMetaType::SChar> {
- static signed char *create() { return new signed char(-12); }
+ static signed char *create() { return new signed char(CHAR_MIN); }
};
template<> struct TestValueFactory<QMetaType::UChar> {
- static uchar *create() { return new uchar('u'); }
+ static uchar *create() { return new uchar(UCHAR_MAX); }
};
template<> struct TestValueFactory<QMetaType::Float> {
- static float *create() { return new float(3.14f); }
+ static float *create() { return new float(FLT_MIN); }
};
template<> struct TestValueFactory<QMetaType::QObjectStar> {
static QObject * *create() { return new QObject *(0); }
@@ -157,10 +158,10 @@ template<> struct TestValueFactory<QMetaType::VoidStar> {
static void * *create() { return new void *(0); }
};
template<> struct TestValueFactory<QMetaType::LongLong> {
- static qlonglong *create() { return new qlonglong(0x12345678); }
+ static qlonglong *create() { return new qlonglong(LLONG_MIN); }
};
template<> struct TestValueFactory<QMetaType::ULongLong> {
- static qulonglong *create() { return new qulonglong(0x12345678); }
+ static qulonglong *create() { return new qulonglong(ULLONG_MAX); }
};
template<> struct TestValueFactory<QMetaType::QStringList> {
static QStringList *create() { return new QStringList(QStringList() << "Q" << "t"); }