From 52744f505381c2840efbe1dc4858d422d32d9f32 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 3 Feb 2012 15:43:28 +1000 Subject: Improve float selftest Correct a bug in the test and use unique names for data rows. The bug was that the test assumed that QCOMPARE for float values 100001 and 100002 would fail, but it actually succeeds. QCOMPARE for floats uses qFuzzyCompare(), which succeeds if the numbers differ by no more than 1/100,000th of the smaller value. Thus QCOMPARE(100001, 100002) passes, while QCOMPARE(99998, 99999) fails. Change-Id: Ia35d3126c2e3ebe91d64daa309048514a365d9fb Reviewed-by: Rohan McGovern --- tests/auto/testlib/selftests/expected_float.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests/auto/testlib/selftests/expected_float.txt') 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 ********* -- cgit v1.2.3