diff options
-rw-r--r-- | src/testlib/qtestcase.h | 8 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/expected_cmptest.junitxml | 4 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/expected_cmptest.lightxml | 4 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/expected_cmptest.tap | 7 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/expected_cmptest.teamcity | 2 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/expected_cmptest.txt | 2 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/expected_cmptest.xml | 4 |
7 files changed, 25 insertions, 6 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index d7c9d43581..ced876fcd9 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -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; } diff --git a/tests/auto/testlib/selftests/expected_cmptest.junitxml b/tests/auto/testlib/selftests/expected_cmptest.junitxml index 667cfaad44..b5d2721b7a 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.junitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.junitxml @@ -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 diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index ee2ca716a3..f87a3b3d9a 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -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> diff --git a/tests/auto/testlib/selftests/expected_cmptest.tap b/tests/auto/testlib/selftests/expected_cmptest.tap index 52911f227c..b2856bc50c 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.tap +++ b/tests/auto/testlib/selftests/expected_cmptest.tap @@ -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 diff --git a/tests/auto/testlib/selftests/expected_cmptest.teamcity b/tests/auto/testlib/selftests/expected_cmptest.teamcity index e971f2fd4b..59817b2006 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.teamcity +++ b/tests/auto/testlib/selftests/expected_cmptest.teamcity @@ -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'] diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index 527ec991bb..525094d813 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -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 diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index c89f177a13..678a751669 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -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> |