From 37f617c405ae4f26cbb6bb4f08d61d6ccc111a98 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 9 Nov 2018 14:05:35 +0100 Subject: Add qfloat16 support to QCOMPARE Change-Id: Ide06f215a888328308a06e7e48edd666f790a5f0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- .../auto/testlib/selftests/expected_float.lightxml | 27 ++++++++ tests/auto/testlib/selftests/expected_float.tap | 78 ++++++++++++++++------ .../auto/testlib/selftests/expected_float.teamcity | 13 ++++ tests/auto/testlib/selftests/expected_float.txt | 16 ++++- tests/auto/testlib/selftests/expected_float.xml | 27 ++++++++ .../auto/testlib/selftests/expected_float.xunitxml | 13 +++- tests/auto/testlib/selftests/float/tst_float.cpp | 39 +++++++++++ 7 files changed, 191 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/auto/testlib/selftests/expected_float.lightxml b/tests/auto/testlib/selftests/expected_float.lightxml index 0dbc5dd8c8..37ccbfc2c5 100644 --- a/tests/auto/testlib/selftests/expected_float.lightxml +++ b/tests/auto/testlib/selftests/expected_float.lightxml @@ -34,6 +34,33 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_float.tap b/tests/auto/testlib/selftests/expected_float.tap index fae2dc9796..158eff1470 100644 --- a/tests/auto/testlib/selftests/expected_float.tap +++ b/tests/auto/testlib/selftests/expected_float.tap @@ -10,9 +10,9 @@ not ok 3 - floatComparisons(should FAIL 1) found: 1 (operandLeft) expected: 3 (operandRight) 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 - line: 48 + line: 51 ... not ok 4 - floatComparisons(should FAIL 2) --- @@ -22,9 +22,9 @@ not ok 4 - floatComparisons(should FAIL 2) found: 1e-07 (operandLeft) expected: 3e-07 (operandRight) 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 - line: 48 + line: 51 ... not ok 5 - floatComparisons(should FAIL 3) --- @@ -34,12 +34,50 @@ not ok 5 - floatComparisons(should FAIL 3) found: 99998 (operandLeft) expected: 99999 (operandRight) 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 - line: 48 + line: 51 ... 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 message: Compared floats are not the same (fuzzy compare) @@ -47,11 +85,11 @@ not ok 7 - compareFloatTests(1e0) found: 1 (t1) expected: 3 (t3) 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 - line: 96 + line: 135 ... -not ok 8 - compareFloatTests(1e-7) +not ok 13 - compareFloatTests(1e-7) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -59,11 +97,11 @@ not ok 8 - compareFloatTests(1e-7) found: 1e-07 (t1) expected: 3e-07 (t3) 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 - line: 96 + line: 135 ... -not ok 9 - compareFloatTests(1e+7) +not ok 14 - compareFloatTests(1e+7) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -71,12 +109,12 @@ not ok 9 - compareFloatTests(1e+7) found: 1e+07 (t1) expected: 3e+07 (t3) 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 - line: 96 + line: 135 ... -ok 10 - cleanupTestCase() -1..10 -# tests 10 -# pass 4 -# fail 6 +ok 15 - cleanupTestCase() +1..15 +# tests 15 +# pass 6 +# fail 9 diff --git a/tests/auto/testlib/selftests/expected_float.teamcity b/tests/auto/testlib/selftests/expected_float.teamcity index d5b81593d8..140dc7edf9 100644 --- a/tests/auto/testlib/selftests/expected_float.teamcity +++ b/tests/auto/testlib/selftests/expected_float.teamcity @@ -14,6 +14,19 @@ ##teamcity[testFinished name='floatComparisons(should FAIL 3)' flowId='tst_float'] ##teamcity[testStarted 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[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'] diff --git a/tests/auto/testlib/selftests/expected_float.txt b/tests/auto/testlib/selftests/expected_float.txt index 8abea6a67e..4e3554758d 100644 --- a/tests/auto/testlib/selftests/expected_float.txt +++ b/tests/auto/testlib/selftests/expected_float.txt @@ -15,6 +15,20 @@ FAIL! : tst_float::floatComparisons(should FAIL 3) Compared floats are not the Expected (operandRight): 99999 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] 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) Actual (t1): 1 Expected (t3): 3 @@ -28,5 +42,5 @@ FAIL! : tst_float::compareFloatTests(1e+7) Compared floats are not the same (fu Expected (t3): 3e+07 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] 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 ********* diff --git a/tests/auto/testlib/selftests/expected_float.xml b/tests/auto/testlib/selftests/expected_float.xml index 096e1a5b54..1f17d48d1b 100644 --- a/tests/auto/testlib/selftests/expected_float.xml +++ b/tests/auto/testlib/selftests/expected_float.xml @@ -36,6 +36,33 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_float.xunitxml b/tests/auto/testlib/selftests/expected_float.xunitxml index 5de14e8d9b..87f11ccba5 100644 --- a/tests/auto/testlib/selftests/expected_float.xunitxml +++ b/tests/auto/testlib/selftests/expected_float.xunitxml @@ -1,5 +1,5 @@ - + @@ -17,6 +17,17 @@ Actual (operandLeft) : 99998 Expected (operandRight): 99999" result="fail"/> + + + + + ("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 { QFETCH(float, t1); -- cgit v1.2.3