Add qfloat16 support to QCOMPARE
Change-Id: Ide06f215a888328308a06e7e48edd666f790a5f0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
1135cf3df4
commit
37f617c405
@ -52,6 +52,7 @@
|
|||||||
#include <QtCore/qfileinfo.h>
|
#include <QtCore/qfileinfo.h>
|
||||||
#include <QtCore/qdir.h>
|
#include <QtCore/qdir.h>
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
|
#include <QtCore/qfloat16.h>
|
||||||
#include <QtCore/qlibraryinfo.h>
|
#include <QtCore/qlibraryinfo.h>
|
||||||
#include <QtCore/private/qtools_p.h>
|
#include <QtCore/private/qtools_p.h>
|
||||||
#include <QtCore/qdiriterator.h>
|
#include <QtCore/qdiriterator.h>
|
||||||
@ -2483,6 +2484,16 @@ bool QTest::compare_helper(bool success, const char *failureMsg,
|
|||||||
return QTestResult::compare(success, failureMsg, val1, val2, actual, expected, file, line);
|
return QTestResult::compare(success, failureMsg, val1, val2, actual, expected, file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! \fn bool QTest::qCompare(const qfloat16 &t1, const qfloat16 &t2, const char *actual, const char *expected, const char *file, int line)
|
||||||
|
\internal
|
||||||
|
*/
|
||||||
|
bool QTest::qCompare(qfloat16 const &t1, qfloat16 const &t2, const char *actual, const char *expected,
|
||||||
|
const char *file, int line)
|
||||||
|
{
|
||||||
|
return compare_helper(qFuzzyCompare(t1, t2), "Compared qfloat16s are not the same (fuzzy compare)",
|
||||||
|
toString(t1), toString(t2), actual, expected, file, line);
|
||||||
|
}
|
||||||
|
|
||||||
/*! \fn bool QTest::qCompare(const float &t1, const float &t2, const char *actual, const char *expected, const char *file, int line)
|
/*! \fn bool QTest::qCompare(const float &t1, const float &t2, const char *actual, const char *expected, const char *file, int line)
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
@ -2547,6 +2558,13 @@ TO_STRING_IMPL(unsigned char, %hhu)
|
|||||||
TO_STRING_IMPL(float, %g)
|
TO_STRING_IMPL(float, %g)
|
||||||
TO_STRING_IMPL(double, %lg)
|
TO_STRING_IMPL(double, %lg)
|
||||||
|
|
||||||
|
template <> Q_TESTLIB_EXPORT char *QTest::toString<qfloat16>(const qfloat16 &t)
|
||||||
|
{
|
||||||
|
char *msg = new char[16];
|
||||||
|
qsnprintf(msg, 16, "%.3g", static_cast<float>(t));
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
template <> Q_TESTLIB_EXPORT char *QTest::toString<char>(const char &t)
|
template <> Q_TESTLIB_EXPORT char *QTest::toString<char>(const char &t)
|
||||||
{
|
{
|
||||||
unsigned char c = static_cast<unsigned char>(t);
|
unsigned char c = static_cast<unsigned char>(t);
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class qfloat16;
|
||||||
class QRegularExpression;
|
class QRegularExpression;
|
||||||
|
|
||||||
#define QVERIFY(statement) \
|
#define QVERIFY(statement) \
|
||||||
@ -361,6 +362,9 @@ namespace QTest
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Q_TESTLIB_EXPORT bool qCompare(qfloat16 const &t1, qfloat16 const &t2,
|
||||||
|
const char *actual, const char *expected, const char *file, int line);
|
||||||
|
|
||||||
Q_TESTLIB_EXPORT bool qCompare(float const &t1, float const &t2,
|
Q_TESTLIB_EXPORT bool qCompare(float const &t1, float const &t2,
|
||||||
const char *actual, const char *expected, const char *file, int line);
|
const char *actual, const char *expected, const char *file, int line);
|
||||||
|
|
||||||
@ -405,6 +409,7 @@ namespace QTest
|
|||||||
|
|
||||||
QTEST_COMPARE_DECL(float)
|
QTEST_COMPARE_DECL(float)
|
||||||
QTEST_COMPARE_DECL(double)
|
QTEST_COMPARE_DECL(double)
|
||||||
|
QTEST_COMPARE_DECL(qfloat16)
|
||||||
QTEST_COMPARE_DECL(char)
|
QTEST_COMPARE_DECL(char)
|
||||||
QTEST_COMPARE_DECL(signed char)
|
QTEST_COMPARE_DECL(signed char)
|
||||||
QTEST_COMPARE_DECL(unsigned char)
|
QTEST_COMPARE_DECL(unsigned char)
|
||||||
|
@ -34,6 +34,33 @@
|
|||||||
</Incident>
|
</Incident>
|
||||||
<Duration msecs="0"/>
|
<Duration msecs="0"/>
|
||||||
</TestFunction>
|
</TestFunction>
|
||||||
|
<TestFunction name="float16Comparisons">
|
||||||
|
<Incident type="pass" file="" line="0">
|
||||||
|
<DataTag><![CDATA[should SUCCEED 1]]></DataTag>
|
||||||
|
</Incident>
|
||||||
|
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
||||||
|
<DataTag><![CDATA[should FAIL 1]]></DataTag>
|
||||||
|
<Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 1
|
||||||
|
Expected (operandRight): 3]]></Description>
|
||||||
|
</Incident>
|
||||||
|
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
||||||
|
<DataTag><![CDATA[should FAIL 2]]></DataTag>
|
||||||
|
<Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 0.0001
|
||||||
|
Expected (operandRight): 0.0003]]></Description>
|
||||||
|
</Incident>
|
||||||
|
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
||||||
|
<DataTag><![CDATA[should FAIL 3]]></DataTag>
|
||||||
|
<Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 98
|
||||||
|
Expected (operandRight): 99]]></Description>
|
||||||
|
</Incident>
|
||||||
|
<Incident type="pass" file="" line="0">
|
||||||
|
<DataTag><![CDATA[should SUCCEED 2]]></DataTag>
|
||||||
|
</Incident>
|
||||||
|
<Duration msecs="0"/>
|
||||||
|
</TestFunction>
|
||||||
<TestFunction name="compareFloatTests">
|
<TestFunction name="compareFloatTests">
|
||||||
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
||||||
<DataTag><![CDATA[1e0]]></DataTag>
|
<DataTag><![CDATA[1e0]]></DataTag>
|
||||||
|
@ -10,9 +10,9 @@ not ok 3 - floatComparisons(should FAIL 1)
|
|||||||
found: 1 (operandLeft)
|
found: 1 (operandLeft)
|
||||||
expected: 3 (operandRight)
|
expected: 3 (operandRight)
|
||||||
actual: 1 (operandLeft)
|
actual: 1 (operandLeft)
|
||||||
at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:48)
|
at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:51)
|
||||||
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
line: 48
|
line: 51
|
||||||
...
|
...
|
||||||
not ok 4 - floatComparisons(should FAIL 2)
|
not ok 4 - floatComparisons(should FAIL 2)
|
||||||
---
|
---
|
||||||
@ -22,9 +22,9 @@ not ok 4 - floatComparisons(should FAIL 2)
|
|||||||
found: 1e-07 (operandLeft)
|
found: 1e-07 (operandLeft)
|
||||||
expected: 3e-07 (operandRight)
|
expected: 3e-07 (operandRight)
|
||||||
actual: 1e-07 (operandLeft)
|
actual: 1e-07 (operandLeft)
|
||||||
at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:48)
|
at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:51)
|
||||||
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
line: 48
|
line: 51
|
||||||
...
|
...
|
||||||
not ok 5 - floatComparisons(should FAIL 3)
|
not ok 5 - floatComparisons(should FAIL 3)
|
||||||
---
|
---
|
||||||
@ -34,12 +34,50 @@ not ok 5 - floatComparisons(should FAIL 3)
|
|||||||
found: 99998 (operandLeft)
|
found: 99998 (operandLeft)
|
||||||
expected: 99999 (operandRight)
|
expected: 99999 (operandRight)
|
||||||
actual: 99998 (operandLeft)
|
actual: 99998 (operandLeft)
|
||||||
at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:48)
|
at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:51)
|
||||||
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
line: 48
|
line: 51
|
||||||
...
|
...
|
||||||
ok 6 - floatComparisons(should SUCCEED 2)
|
ok 6 - floatComparisons(should SUCCEED 2)
|
||||||
not ok 7 - compareFloatTests(1e0)
|
ok 7 - float16Comparisons(should SUCCEED 1)
|
||||||
|
not ok 8 - float16Comparisons(should FAIL 1)
|
||||||
|
---
|
||||||
|
type: QCOMPARE
|
||||||
|
message: Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
wanted: 3 (operandRight)
|
||||||
|
found: 1 (operandLeft)
|
||||||
|
expected: 3 (operandRight)
|
||||||
|
actual: 1 (operandLeft)
|
||||||
|
at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:90)
|
||||||
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
|
line: 90
|
||||||
|
...
|
||||||
|
not ok 9 - float16Comparisons(should FAIL 2)
|
||||||
|
---
|
||||||
|
type: QCOMPARE
|
||||||
|
message: Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
wanted: 0.0003 (operandRight)
|
||||||
|
found: 0.0001 (operandLeft)
|
||||||
|
expected: 0.0003 (operandRight)
|
||||||
|
actual: 0.0001 (operandLeft)
|
||||||
|
at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:90)
|
||||||
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
|
line: 90
|
||||||
|
...
|
||||||
|
not ok 10 - float16Comparisons(should FAIL 3)
|
||||||
|
---
|
||||||
|
type: QCOMPARE
|
||||||
|
message: Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
wanted: 99 (operandRight)
|
||||||
|
found: 98 (operandLeft)
|
||||||
|
expected: 99 (operandRight)
|
||||||
|
actual: 98 (operandLeft)
|
||||||
|
at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:90)
|
||||||
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
|
line: 90
|
||||||
|
...
|
||||||
|
ok 11 - float16Comparisons(should SUCCEED 2)
|
||||||
|
not ok 12 - compareFloatTests(1e0)
|
||||||
---
|
---
|
||||||
type: QCOMPARE
|
type: QCOMPARE
|
||||||
message: Compared floats are not the same (fuzzy compare)
|
message: Compared floats are not the same (fuzzy compare)
|
||||||
@ -47,11 +85,11 @@ not ok 7 - compareFloatTests(1e0)
|
|||||||
found: 1 (t1)
|
found: 1 (t1)
|
||||||
expected: 3 (t3)
|
expected: 3 (t3)
|
||||||
actual: 1 (t1)
|
actual: 1 (t1)
|
||||||
at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:96)
|
at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:135)
|
||||||
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
line: 96
|
line: 135
|
||||||
...
|
...
|
||||||
not ok 8 - compareFloatTests(1e-7)
|
not ok 13 - compareFloatTests(1e-7)
|
||||||
---
|
---
|
||||||
type: QCOMPARE
|
type: QCOMPARE
|
||||||
message: Compared floats are not the same (fuzzy compare)
|
message: Compared floats are not the same (fuzzy compare)
|
||||||
@ -59,11 +97,11 @@ not ok 8 - compareFloatTests(1e-7)
|
|||||||
found: 1e-07 (t1)
|
found: 1e-07 (t1)
|
||||||
expected: 3e-07 (t3)
|
expected: 3e-07 (t3)
|
||||||
actual: 1e-07 (t1)
|
actual: 1e-07 (t1)
|
||||||
at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:96)
|
at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:135)
|
||||||
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
line: 96
|
line: 135
|
||||||
...
|
...
|
||||||
not ok 9 - compareFloatTests(1e+7)
|
not ok 14 - compareFloatTests(1e+7)
|
||||||
---
|
---
|
||||||
type: QCOMPARE
|
type: QCOMPARE
|
||||||
message: Compared floats are not the same (fuzzy compare)
|
message: Compared floats are not the same (fuzzy compare)
|
||||||
@ -71,12 +109,12 @@ not ok 9 - compareFloatTests(1e+7)
|
|||||||
found: 1e+07 (t1)
|
found: 1e+07 (t1)
|
||||||
expected: 3e+07 (t3)
|
expected: 3e+07 (t3)
|
||||||
actual: 1e+07 (t1)
|
actual: 1e+07 (t1)
|
||||||
at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:96)
|
at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:135)
|
||||||
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp
|
||||||
line: 96
|
line: 135
|
||||||
...
|
...
|
||||||
ok 10 - cleanupTestCase()
|
ok 15 - cleanupTestCase()
|
||||||
1..10
|
1..15
|
||||||
# tests 10
|
# tests 15
|
||||||
# pass 4
|
# pass 6
|
||||||
# fail 6
|
# fail 9
|
||||||
|
@ -14,6 +14,19 @@
|
|||||||
##teamcity[testFinished name='floatComparisons(should FAIL 3)' flowId='tst_float']
|
##teamcity[testFinished name='floatComparisons(should FAIL 3)' flowId='tst_float']
|
||||||
##teamcity[testStarted name='floatComparisons(should SUCCEED 2)' flowId='tst_float']
|
##teamcity[testStarted name='floatComparisons(should SUCCEED 2)' flowId='tst_float']
|
||||||
##teamcity[testFinished name='floatComparisons(should SUCCEED 2)' flowId='tst_float']
|
##teamcity[testFinished name='floatComparisons(should SUCCEED 2)' flowId='tst_float']
|
||||||
|
##teamcity[testStarted name='float16Comparisons(should SUCCEED 1)' flowId='tst_float']
|
||||||
|
##teamcity[testFinished name='float16Comparisons(should SUCCEED 1)' flowId='tst_float']
|
||||||
|
##teamcity[testStarted name='float16Comparisons(should FAIL 1)' flowId='tst_float']
|
||||||
|
##teamcity[testFailed name='float16Comparisons(should FAIL 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): 3' flowId='tst_float']
|
||||||
|
##teamcity[testFinished name='float16Comparisons(should FAIL 1)' flowId='tst_float']
|
||||||
|
##teamcity[testStarted name='float16Comparisons(should FAIL 2)' flowId='tst_float']
|
||||||
|
##teamcity[testFailed name='float16Comparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0.0001|n Expected (operandRight): 0.0003' flowId='tst_float']
|
||||||
|
##teamcity[testFinished name='float16Comparisons(should FAIL 2)' flowId='tst_float']
|
||||||
|
##teamcity[testStarted name='float16Comparisons(should FAIL 3)' flowId='tst_float']
|
||||||
|
##teamcity[testFailed name='float16Comparisons(should FAIL 3)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 98|n Expected (operandRight): 99' flowId='tst_float']
|
||||||
|
##teamcity[testFinished name='float16Comparisons(should FAIL 3)' flowId='tst_float']
|
||||||
|
##teamcity[testStarted name='float16Comparisons(should SUCCEED 2)' flowId='tst_float']
|
||||||
|
##teamcity[testFinished name='float16Comparisons(should SUCCEED 2)' flowId='tst_float']
|
||||||
##teamcity[testStarted name='compareFloatTests(1e0)' flowId='tst_float']
|
##teamcity[testStarted name='compareFloatTests(1e0)' flowId='tst_float']
|
||||||
##teamcity[testFailed name='compareFloatTests(1e0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1|n Expected (t3): 3' flowId='tst_float']
|
##teamcity[testFailed name='compareFloatTests(1e0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1|n Expected (t3): 3' flowId='tst_float']
|
||||||
##teamcity[testFinished name='compareFloatTests(1e0)' flowId='tst_float']
|
##teamcity[testFinished name='compareFloatTests(1e0)' flowId='tst_float']
|
||||||
|
@ -15,6 +15,20 @@ FAIL! : tst_float::floatComparisons(should FAIL 3) Compared floats are not the
|
|||||||
Expected (operandRight): 99999
|
Expected (operandRight): 99999
|
||||||
Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)]
|
Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)]
|
||||||
PASS : tst_float::floatComparisons(should SUCCEED 2)
|
PASS : tst_float::floatComparisons(should SUCCEED 2)
|
||||||
|
PASS : tst_float::float16Comparisons(should SUCCEED 1)
|
||||||
|
FAIL! : tst_float::float16Comparisons(should FAIL 1) Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 1
|
||||||
|
Expected (operandRight): 3
|
||||||
|
Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)]
|
||||||
|
FAIL! : tst_float::float16Comparisons(should FAIL 2) Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 0.0001
|
||||||
|
Expected (operandRight): 0.0003
|
||||||
|
Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)]
|
||||||
|
FAIL! : tst_float::float16Comparisons(should FAIL 3) Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 98
|
||||||
|
Expected (operandRight): 99
|
||||||
|
Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)]
|
||||||
|
PASS : tst_float::float16Comparisons(should SUCCEED 2)
|
||||||
FAIL! : tst_float::compareFloatTests(1e0) Compared floats are not the same (fuzzy compare)
|
FAIL! : tst_float::compareFloatTests(1e0) Compared floats are not the same (fuzzy compare)
|
||||||
Actual (t1): 1
|
Actual (t1): 1
|
||||||
Expected (t3): 3
|
Expected (t3): 3
|
||||||
@ -28,5 +42,5 @@ FAIL! : tst_float::compareFloatTests(1e+7) Compared floats are not the same (fu
|
|||||||
Expected (t3): 3e+07
|
Expected (t3): 3e+07
|
||||||
Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)]
|
Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)]
|
||||||
PASS : tst_float::cleanupTestCase()
|
PASS : tst_float::cleanupTestCase()
|
||||||
Totals: 4 passed, 6 failed, 0 skipped, 0 blacklisted, 0ms
|
Totals: 6 passed, 9 failed, 0 skipped, 0 blacklisted, 0ms
|
||||||
********* Finished testing of tst_float *********
|
********* Finished testing of tst_float *********
|
||||||
|
@ -36,6 +36,33 @@
|
|||||||
</Incident>
|
</Incident>
|
||||||
<Duration msecs="0"/>
|
<Duration msecs="0"/>
|
||||||
</TestFunction>
|
</TestFunction>
|
||||||
|
<TestFunction name="float16Comparisons">
|
||||||
|
<Incident type="pass" file="" line="0">
|
||||||
|
<DataTag><![CDATA[should SUCCEED 1]]></DataTag>
|
||||||
|
</Incident>
|
||||||
|
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
||||||
|
<DataTag><![CDATA[should FAIL 1]]></DataTag>
|
||||||
|
<Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 1
|
||||||
|
Expected (operandRight): 3]]></Description>
|
||||||
|
</Incident>
|
||||||
|
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
||||||
|
<DataTag><![CDATA[should FAIL 2]]></DataTag>
|
||||||
|
<Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 0.0001
|
||||||
|
Expected (operandRight): 0.0003]]></Description>
|
||||||
|
</Incident>
|
||||||
|
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
||||||
|
<DataTag><![CDATA[should FAIL 3]]></DataTag>
|
||||||
|
<Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 98
|
||||||
|
Expected (operandRight): 99]]></Description>
|
||||||
|
</Incident>
|
||||||
|
<Incident type="pass" file="" line="0">
|
||||||
|
<DataTag><![CDATA[should SUCCEED 2]]></DataTag>
|
||||||
|
</Incident>
|
||||||
|
<Duration msecs="0"/>
|
||||||
|
</TestFunction>
|
||||||
<TestFunction name="compareFloatTests">
|
<TestFunction name="compareFloatTests">
|
||||||
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0">
|
||||||
<DataTag><![CDATA[1e0]]></DataTag>
|
<DataTag><![CDATA[1e0]]></DataTag>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<testsuite errors="0" failures="6" tests="4" name="tst_float">
|
<testsuite errors="0" failures="9" tests="5" name="tst_float">
|
||||||
<properties>
|
<properties>
|
||||||
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
|
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
|
||||||
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
|
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
|
||||||
@ -17,6 +17,17 @@
|
|||||||
Actual (operandLeft) : 99998
|
Actual (operandLeft) : 99998
|
||||||
Expected (operandRight): 99999" result="fail"/>
|
Expected (operandRight): 99999" result="fail"/>
|
||||||
</testcase>
|
</testcase>
|
||||||
|
<testcase result="fail" name="float16Comparisons">
|
||||||
|
<failure tag="should FAIL 1" message="Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 1
|
||||||
|
Expected (operandRight): 3" result="fail"/>
|
||||||
|
<failure tag="should FAIL 2" message="Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 0.0001
|
||||||
|
Expected (operandRight): 0.0003" result="fail"/>
|
||||||
|
<failure tag="should FAIL 3" message="Compared qfloat16s are not the same (fuzzy compare)
|
||||||
|
Actual (operandLeft) : 98
|
||||||
|
Expected (operandRight): 99" result="fail"/>
|
||||||
|
</testcase>
|
||||||
<testcase result="fail" name="compareFloatTests">
|
<testcase result="fail" name="compareFloatTests">
|
||||||
<failure tag="1e0" message="Compared floats are not the same (fuzzy compare)
|
<failure tag="1e0" message="Compared floats are not the same (fuzzy compare)
|
||||||
Actual (t1): 1
|
Actual (t1): 1
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtCore/qfloat16.h>
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -36,6 +37,8 @@ class tst_float: public QObject
|
|||||||
private slots:
|
private slots:
|
||||||
void floatComparisons() const;
|
void floatComparisons() const;
|
||||||
void floatComparisons_data() const;
|
void floatComparisons_data() const;
|
||||||
|
void float16Comparisons() const;
|
||||||
|
void float16Comparisons_data() const;
|
||||||
void compareFloatTests() const;
|
void compareFloatTests() const;
|
||||||
void compareFloatTests_data() const;
|
void compareFloatTests_data() const;
|
||||||
};
|
};
|
||||||
@ -79,6 +82,42 @@ void tst_float::floatComparisons_data() const
|
|||||||
<< float(100002);
|
<< float(100002);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_float::float16Comparisons() const
|
||||||
|
{
|
||||||
|
QFETCH(qfloat16, operandLeft);
|
||||||
|
QFETCH(qfloat16, operandRight);
|
||||||
|
|
||||||
|
QCOMPARE(operandLeft, operandRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_float::float16Comparisons_data() const
|
||||||
|
{
|
||||||
|
QTest::addColumn<qfloat16>("operandLeft");
|
||||||
|
QTest::addColumn<qfloat16>("operandRight");
|
||||||
|
|
||||||
|
QTest::newRow("should SUCCEED 1")
|
||||||
|
<< qfloat16(0)
|
||||||
|
<< qfloat16(0);
|
||||||
|
|
||||||
|
QTest::newRow("should FAIL 1")
|
||||||
|
<< qfloat16(1.000)
|
||||||
|
<< qfloat16(3.000);
|
||||||
|
|
||||||
|
QTest::newRow("should FAIL 2")
|
||||||
|
<< qfloat16(1.000e-4f)
|
||||||
|
<< qfloat16(3.000e-4f);
|
||||||
|
|
||||||
|
// QCOMPARE for qfloat16s uses qFuzzyCompare()
|
||||||
|
|
||||||
|
QTest::newRow("should FAIL 3")
|
||||||
|
<< qfloat16(98)
|
||||||
|
<< qfloat16(99);
|
||||||
|
|
||||||
|
QTest::newRow("should SUCCEED 2")
|
||||||
|
<< qfloat16(1001)
|
||||||
|
<< qfloat16(1002);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_float::compareFloatTests() const
|
void tst_float::compareFloatTests() const
|
||||||
{
|
{
|
||||||
QFETCH(float, t1);
|
QFETCH(float, t1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user