diff options
Diffstat (limited to 'tests/auto/testlib/selftests/float')
-rw-r--r-- | tests/auto/testlib/selftests/float/.prev_CMakeLists.txt | 18 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/float/CMakeLists.txt | 20 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/float/float.pro | 10 | ||||
-rw-r--r-- | tests/auto/testlib/selftests/float/tst_float.cpp | 41 |
4 files changed, 17 insertions, 72 deletions
diff --git a/tests/auto/testlib/selftests/float/.prev_CMakeLists.txt b/tests/auto/testlib/selftests/float/.prev_CMakeLists.txt deleted file mode 100644 index 8b47df4c03..0000000000 --- a/tests/auto/testlib/selftests/float/.prev_CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Generated from float.pro. - -##################################################################### -## float Binary: -##################################################################### - -qt_add_executable(float - SOURCES - ../../../../shared/emulationdetector.h - tst_float.cpp - INCLUDE_DIRECTORIES - ../../../../shared - PUBLIC_LIBRARIES - Qt::Test -) - -## Scopes: -##################################################################### diff --git a/tests/auto/testlib/selftests/float/CMakeLists.txt b/tests/auto/testlib/selftests/float/CMakeLists.txt index 2eb3264acd..448c3e962e 100644 --- a/tests/auto/testlib/selftests/float/CMakeLists.txt +++ b/tests/auto/testlib/selftests/float/CMakeLists.txt @@ -1,24 +1,22 @@ -# Generated from float.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## float Binary: ##################################################################### -qt_add_executable(float - NO_INSTALL # special case - OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case +qt_internal_add_executable(float + NO_INSTALL + EXCEPTIONS + OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} SOURCES - ../../../../shared/emulationdetector.h tst_float.cpp - INCLUDE_DIRECTORIES - ../../../../shared - PUBLIC_LIBRARIES + LIBRARIES Qt::Test + Qt::TestPrivate ) ## Scopes: ##################################################################### -# special case begin -qt_apply_testlib_coverage_options(float) -# special case end +qt_internal_apply_testlib_coverage_options(float) diff --git a/tests/auto/testlib/selftests/float/float.pro b/tests/auto/testlib/selftests/float/float.pro deleted file mode 100644 index 8f169921c3..0000000000 --- a/tests/auto/testlib/selftests/float/float.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT = core testlib -mac:CONFIG -= app_bundle -CONFIG -= debug_and_release_target - -INCLUDEPATH += ../../../../shared/ -HEADERS = ../../../../shared/emulationdetector.h -SOURCES += tst_float.cpp -TARGET = float - -include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/float/tst_float.cpp b/tests/auto/testlib/selftests/float/tst_float.cpp index 823495f863..9af14f1e89 100644 --- a/tests/auto/testlib/selftests/float/tst_float.cpp +++ b/tests/auto/testlib/selftests/float/tst_float.cpp @@ -1,37 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/QCoreApplication> #include <QtCore/qfloat16.h> -#include <QtTest/QtTest> +#include <QTest> #include <QDebug> -#include "emulationdetector.h" +#include <QtTest/private/qemulationdetector_p.h> // Test proper handling of floating-point types class tst_float: public QObject @@ -182,20 +157,20 @@ void tst_float::float16Comparisons_data() const QTest::addColumn<qfloat16>("operandLeft"); QTest::addColumn<qfloat16>("operandRight"); const qfloat16 zero(0), one(1); - const qfloat16 tiny(EmulationDetector::isRunningArmOnX86() ? 0.00099f : 0.001f); + const qfloat16 tiny(9.756e-03f); QTest::newRow("should FAIL 1") << one << qfloat16(3); QTest::newRow("should PASS 1") << zero << zero; - QTest::newRow("should FAIL 2") << qfloat16(1e-3f) << qfloat16(3e-3f); // QCOMPARE for uses qFuzzyCompare(), which ignores differences of one part // in 102.5 and considers any two qFuzzyIsNull() values, i.e. values smaller - // than 1e-3, equal + // than 1/102.5, equal + QTest::newRow("should FAIL 2") << qfloat16(.01f) << qfloat16(.03f); QTest::newRow("should PASS 2") << qfloat16(1001) << qfloat16(1002); QTest::newRow("should FAIL 3") << qfloat16(98) << qfloat16(99); QTest::newRow("should PASS 3") << tiny << -tiny; // ... which gets a bit unreliable near to the type's bounds - QTest::newRow("should FAIL 4") << qfloat16(1.01e-3f) << qfloat16(0.99e-3f); + QTest::newRow("should FAIL 4") << qfloat16(10e-3f) << qfloat16(9.7e-3f); QTest::newRow("should PASS 4") << qfloat16(6e4) + qfloat16(700) << qfloat16(6e4) + qfloat16(1200); QTest::newRow("should FAIL 5") << qfloat16(6e4) - qfloat16(600) << qfloat16(6e4) - qfloat16(1200); |