QTestLib: Show the values of unregistered enums
... on a failed QCOMPARE. Change-Id: I653894927e49fad92c21409d03ed70880ca510f6 Reviewed-by: Jason McDonald <macadder1@gmail.com>
This commit is contained in:
parent
29b2387587
commit
b88f692d7d
@ -246,8 +246,14 @@ namespace QTest
|
||||
return qstrdup(me.valueToKey(int(e))); // int cast is necessary to support enum classes
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline typename std::enable_if<!QtPrivate::IsQEnumHelper<T>::Value && std::is_enum_v<T>, char*>::type toString(const T &e)
|
||||
{
|
||||
return qstrdup(QByteArray::number(static_cast<std::underlying_type_t<T>>(e)).constData());
|
||||
}
|
||||
|
||||
template <typename T> // Fallback
|
||||
inline typename std::enable_if<!QtPrivate::IsQEnumHelper<T>::Value, char*>::type toString(const T &)
|
||||
inline typename std::enable_if<!QtPrivate::IsQEnumHelper<T>::Value && !std::is_enum_v<T>, char*>::type toString(const T &)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -7,7 +7,9 @@
|
||||
</properties>
|
||||
<testcase name="initTestCase" result="pass" time="@TEST_DURATION@"/>
|
||||
<testcase name="compare_unregistered_enums" result="fail" time="@TEST_DURATION@">
|
||||
<failure result="fail" message="Compared values are not the same"/>
|
||||
<failure result="fail" message="Compared values are not the same
|
||||
Actual (MyUnregisteredEnumValue1): 0
|
||||
Expected (MyUnregisteredEnumValue2): 1"/>
|
||||
</testcase>
|
||||
<testcase name="compare_registered_enums" result="fail" time="@TEST_DURATION@">
|
||||
<failure result="fail" message="Compared values are not the same
|
||||
|
@ -9,7 +9,9 @@
|
||||
</TestFunction>
|
||||
<TestFunction name="compare_unregistered_enums">
|
||||
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
|
||||
<Description><![CDATA[Compared values are not the same]]></Description>
|
||||
<Description><![CDATA[Compared values are not the same
|
||||
Actual (MyUnregisteredEnumValue1): 0
|
||||
Expected (MyUnregisteredEnumValue2): 1]]></Description>
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
|
@ -3,7 +3,12 @@ TAP version 13
|
||||
ok 1 - initTestCase()
|
||||
not ok 2 - compare_unregistered_enums()
|
||||
---
|
||||
# Compared values are not the same
|
||||
type: QCOMPARE
|
||||
message: Compared values are not the same
|
||||
wanted: 1 (MyUnregisteredEnumValue2)
|
||||
found: 0 (MyUnregisteredEnumValue1)
|
||||
expected: 1 (MyUnregisteredEnumValue2)
|
||||
actual: 0 (MyUnregisteredEnumValue1)
|
||||
at: tst_Cmptest::compare_unregistered_enums() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:0)
|
||||
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
|
||||
line: 0
|
||||
|
@ -2,7 +2,7 @@
|
||||
##teamcity[testStarted name='initTestCase()' flowId='tst_Cmptest']
|
||||
##teamcity[testFinished name='initTestCase()' flowId='tst_Cmptest']
|
||||
##teamcity[testStarted name='compare_unregistered_enums()' flowId='tst_Cmptest']
|
||||
##teamcity[testFailed name='compare_unregistered_enums()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared values are not the same' flowId='tst_Cmptest']
|
||||
##teamcity[testFailed name='compare_unregistered_enums()' message='Failure! |[Loc: _FILE_(_LINE_)|]' details='Compared values are not the same|n Actual (MyUnregisteredEnumValue1): 0|n Expected (MyUnregisteredEnumValue2): 1' flowId='tst_Cmptest']
|
||||
##teamcity[testFinished name='compare_unregistered_enums()' flowId='tst_Cmptest']
|
||||
##teamcity[testStarted name='compare_registered_enums()' flowId='tst_Cmptest']
|
||||
##teamcity[testFailed name='compare_registered_enums()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (Qt::Monday): Monday|n Expected (Qt::Sunday): Sunday' flowId='tst_Cmptest']
|
||||
|
@ -2,6 +2,8 @@
|
||||
Config: Using QtTest library
|
||||
PASS : tst_Cmptest::initTestCase()
|
||||
FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same
|
||||
Actual (MyUnregisteredEnumValue1): 0
|
||||
Expected (MyUnregisteredEnumValue2): 1
|
||||
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
|
||||
FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same
|
||||
Actual (Qt::Monday): Monday
|
||||
|
@ -11,7 +11,9 @@
|
||||
</TestFunction>
|
||||
<TestFunction name="compare_unregistered_enums">
|
||||
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
|
||||
<Description><![CDATA[Compared values are not the same]]></Description>
|
||||
<Description><![CDATA[Compared values are not the same
|
||||
Actual (MyUnregisteredEnumValue1): 0
|
||||
Expected (MyUnregisteredEnumValue2): 1]]></Description>
|
||||
</Incident>
|
||||
<Duration msecs="0"/>
|
||||
</TestFunction>
|
||||
|
Loading…
Reference in New Issue
Block a user