summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/testlib/tostring/tst_tostring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/testlib/tostring/tst_tostring.cpp')
-rw-r--r--tests/benchmarks/testlib/tostring/tst_tostring.cpp86
1 files changed, 58 insertions, 28 deletions
diff --git a/tests/benchmarks/testlib/tostring/tst_tostring.cpp b/tests/benchmarks/testlib/tostring/tst_tostring.cpp
index 03455748f4..e00b12ef53 100644
--- a/tests/benchmarks/testlib/tostring/tst_tostring.cpp
+++ b/tests/benchmarks/testlib/tostring/tst_tostring.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtCore/qmath.h> // pi, e
@@ -50,6 +25,36 @@ private slots:
void quint64Tst() { numeric<quint64>(); }
void qint64Tst_data() { numeric_data<qint64>(); }
void qint64Tst() { numeric<qint64>(); }
+
+private:
+ template <typename T> void compare();
+ template <typename T> void compare_eq();
+
+private slots:
+ void floatCompare_data() { numeric_data<float>(); }
+ void floatCompare() { compare<float>(); }
+ void floatCompareEq_data() { numeric_data<float>(); }
+ void floatCompareEq() { compare_eq<float>(); }
+ void doubleCompare_data() { numeric_data<double>(); }
+ void doubleCompare() { compare<double>(); }
+ void doubleCompareEq_data() { numeric_data<double>(); }
+ void doubleCompareEq() { compare_eq<double>(); }
+ void intCompare_data() { numeric_data<int>(); }
+ void intCompare() { compare<int>(); }
+ void intCompareEq_data() { numeric_data<int>(); }
+ void intCompareEq() { compare_eq<int>(); }
+ void unsignedCompare_data() { numeric_data<unsigned>(); }
+ void unsignedCompare() { compare<unsigned>(); }
+ void unsignedCompareEq_data() { numeric_data<unsigned>(); }
+ void unsignedCompareEq() { compare_eq<unsigned>(); }
+ void quint64Compare_data() { numeric_data<quint64>(); }
+ void quint64Compare() { compare<quint64>(); }
+ void quint64CompareEq_data() { numeric_data<quint64>(); }
+ void quint64CompareEq() { compare_eq<quint64>(); }
+ void qint64Compare_data() { numeric_data<qint64>(); }
+ void qint64Compare() { compare<qint64>(); }
+ void qint64CompareEq_data() { numeric_data<qint64>(); }
+ void qint64CompareEq() { compare_eq<qint64>(); }
};
template <typename T>
@@ -95,10 +100,35 @@ void tst_toString::numeric()
QFETCH(T, datum);
QBENCHMARK {
- auto tst = QTest::toString<T>(datum);
+ auto tst = QTest::toString(datum);
delete [] tst;
}
}
+template <typename T>
+void tst_toString::compare()
+{
+ QFETCH(T, datum);
+
+ QBENCHMARK {
+ QCOMPARE(datum, datum);
+ }
+}
+
+template <typename T>
+void tst_toString::compare_eq()
+{
+ QFETCH(T, datum);
+
+ if constexpr (std::numeric_limits<T>::has_quiet_NaN) {
+ if (qIsNaN(datum))
+ QSKIP("Unlike QCOMPARE, QCOMPARE_EQ doesn't handle NaN specially");
+ }
+
+ QBENCHMARK {
+ QCOMPARE_EQ(datum, datum);
+ }
+}
+
QTEST_MAIN(tst_toString)
#include "tst_tostring.moc"