Fix QCOMPARE with enum classes.

As these are strongly typed, they won't implicitly convert to int, so make sure
to cast explicitly.

(cherry picked from commit 9626baaea9, auto test
is not included)
Task-number: QTBUG-49597
Change-Id: I29c4331a9b0c61f2e60c2bcab5a99f65daa7060f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Robin Burchell 2015-11-24 21:00:38 +01:00 committed by Olivier Goffart (Woboq GmbH)
parent adc4894fca
commit 4a4b17805c

View File

@ -238,7 +238,7 @@ namespace QTest
inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, char*>::Type toString(T e)
{
QMetaEnum me = QMetaEnum::fromType<T>();
return qstrdup(me.key(e));
return qstrdup(me.key(int(e))); // int cast is necessary to support enum classes
}
template <typename T> // Fallback