diff options
-rw-r--r-- | tests/auto/testlib/selftests/expected_float.txt | 16 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/float/tst_float.cpp | 17 |
2 files changed, 23 insertions, 10 deletions
diff --git a/tests/auto/testlib/selftests/expected_float.txt b/tests/auto/testlib/selftests/expected_float.txt index acd0aaa54a..81e4d7b067 100644 --- a/tests/auto/testlib/selftests/expected_float.txt +++ b/tests/auto/testlib/selftests/expected_float.txt @@ -1,26 +1,30 @@ ********* Start testing of tst_float ********* Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ PASS : tst_float::initTestCase() -FAIL! : tst_float::floatComparisons(should FAIL) Compared floats are not the same (fuzzy compare) +FAIL! : tst_float::floatComparisons(should FAIL 1) Compared floats are not the same (fuzzy compare) Actual (operandLeft): 1 Expected (operandRight): 3 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(61)] -FAIL! : tst_float::floatComparisons(should FAIL) Compared floats are not the same (fuzzy compare) +FAIL! : tst_float::floatComparisons(should FAIL 2) Compared floats are not the same (fuzzy compare) Actual (operandLeft): 1e-07 Expected (operandRight): 3e-07 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(61)] +FAIL! : tst_float::floatComparisons(should FAIL 3) Compared floats are not the same (fuzzy compare) + Actual (operandLeft): 99998 + Expected (operandRight): 99999 + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(61)] FAIL! : tst_float::compareFloatTests(1e0) Compared floats are not the same (fuzzy compare) Actual (t1): 1 Expected (t3): 3 - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(100)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(104)] FAIL! : tst_float::compareFloatTests(1e-7) Compared floats are not the same (fuzzy compare) Actual (t1): 1e-07 Expected (t3): 3e-07 - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(100)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(104)] FAIL! : tst_float::compareFloatTests(1e+7) Compared floats are not the same (fuzzy compare) Actual (t1): 1e+07 Expected (t3): 3e+07 - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(100)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(104)] PASS : tst_float::cleanupTestCase() -Totals: 2 passed, 5 failed, 0 skipped +Totals: 2 passed, 6 failed, 0 skipped ********* Finished testing of tst_float ********* diff --git a/tests/auto/testlib/selftests/float/tst_float.cpp b/tests/auto/testlib/selftests/float/tst_float.cpp index 9b7865ed25..fb10521604 100644 --- a/tests/auto/testlib/selftests/float/tst_float.cpp +++ b/tests/auto/testlib/selftests/float/tst_float.cpp @@ -66,19 +66,28 @@ void tst_float::floatComparisons_data() const QTest::addColumn<float>("operandLeft"); QTest::addColumn<float>("operandRight"); - QTest::newRow("should SUCCEED") + QTest::newRow("should SUCCEED 1") << float(0) << float(0); - QTest::newRow("should FAIL") + QTest::newRow("should FAIL 1") << float(1.00000) << float(3.00000); - QTest::newRow("should FAIL") + QTest::newRow("should FAIL 2") << float(1.00000e-7f) << float(3.00000e-7f); - QTest::newRow("should FAIL") + // QCOMPARE for floats uses qFuzzyCompare(), which succeeds if the numbers + // differ by no more than 1/100,000th of the smaller value. Thus + // QCOMPARE(99998, 99999) should fail, while QCOMPARE(100001, 100002) + // should pass. + + QTest::newRow("should FAIL 3") + << float(99998) + << float(99999); + + QTest::newRow("should SUCCEED 2") << float(100001) << float(100002); } |