summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/global')
-rw-r--r--tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp38
-rw-r--r--tests/auto/corelib/global/qglobal/qglobal.c117
-rw-r--r--tests/auto/corelib/global/qglobal/qglobal.pro2
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp17
-rw-r--r--tests/auto/corelib/global/qlogging/qlogging.pro6
-rw-r--r--tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp5
6 files changed, 177 insertions, 8 deletions
diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
index 6b98e3a823..241dccb90e 100644
--- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
+++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
@@ -46,6 +46,8 @@ private slots:
void promotionTests();
void arithOps_data();
void arithOps();
+ void floatToFloat16();
+ void floatFromFloat16();
};
void tst_qfloat16::fuzzyCompare_data()
@@ -307,5 +309,41 @@ void tst_qfloat16::arithOps()
QVERIFY(qFuzzyCompare(r4,1.f/val2));
}
+void tst_qfloat16::floatToFloat16()
+{
+ float in[63];
+ qfloat16 out[63];
+ qfloat16 expected[63];
+
+ for (int i = 0; i < 63; ++i)
+ in[i] = i * (1/13.f);
+
+ for (int i = 0; i < 63; ++i)
+ expected[i] = qfloat16(in[i]);
+
+ qFloatToFloat16(out, in, 63);
+
+ for (int i = 0; i < 63; ++i)
+ QVERIFY(qFuzzyCompare(out[i], expected[i]));
+}
+
+void tst_qfloat16::floatFromFloat16()
+{
+ qfloat16 in[35];
+ float out[35];
+ float expected[35];
+
+ for (int i = 0; i < 35; ++i)
+ in[i] = qfloat16(i * (17.f / 3));
+
+ for (int i = 0; i < 35; ++i)
+ expected[i] = float(in[i]);
+
+ qFloatFromFloat16(out, in, 35);
+
+ for (int i = 0; i < 35; ++i)
+ QCOMPARE(out[i], expected[i]);
+}
+
QTEST_APPLESS_MAIN(tst_qfloat16)
#include "tst_qfloat16.moc"
diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c
new file mode 100644
index 0000000000..af42efa7f6
--- /dev/null
+++ b/tests/auto/corelib/global/qglobal/qglobal.c
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Intel Corporation.
+** 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$
+**
+****************************************************************************/
+
+#include <QtCore/qglobal.h>
+
+#if QT_HAS_INCLUDE(<stdbool.h>) || __STDC_VERSION__ >= 199901L
+# include <stdbool.h>
+#else
+# undef true
+# define true 1
+# undef false
+# define false 0
+#endif
+
+#ifdef Q_COMPILER_THREAD_LOCAL
+# include <threads.h>
+#endif
+
+/*
+ * Certain features of qglobal.h must work in C mode too. We test that
+ * everything works.
+ */
+
+/* Types and Q_UNUSED */
+void tst_GlobalTypes()
+{
+ qint8 s8;
+ qint16 s16;
+ qint32 s32;
+ qint64 s64;
+ qlonglong sll;
+ Q_UNUSED(s8); Q_UNUSED(s16); Q_UNUSED(s32); Q_UNUSED(s64); Q_UNUSED(sll);
+
+ quint8 u8;
+ quint16 u16;
+ quint32 u32;
+ quint64 u64;
+ qulonglong ull;
+ Q_UNUSED(u8); Q_UNUSED(u16); Q_UNUSED(u32); Q_UNUSED(u64); Q_UNUSED(ull);
+
+ uchar uc;
+ ushort us;
+ uint ui;
+ ulong ul;
+ Q_UNUSED(uc); Q_UNUSED(us); Q_UNUSED(ui); Q_UNUSED(ul);
+
+ qreal qr;
+ Q_UNUSED(qr);
+
+ qsizetype qs;
+ qptrdiff qp;
+ qintptr qip;
+ quintptr qup;
+ Q_UNUSED(qs); Q_UNUSED(qp); Q_UNUSED(qip); Q_UNUSED(qup);
+}
+
+/* Qt version */
+int tst_QtVersion()
+{
+ return QT_VERSION;
+}
+
+const char *tst_qVersion() Q_DECL_NOTHROW
+{
+#if !defined(QT_NAMESPACE)
+ return qVersion();
+#else
+ return NULL;
+#endif
+}
+
+/* Static assertion */
+Q_STATIC_ASSERT(true);
+Q_STATIC_ASSERT(1);
+Q_STATIC_ASSERT_X(true, "Message");
+Q_STATIC_ASSERT_X(1, "Message");
+
+Q_STATIC_ASSERT(!false);
+Q_STATIC_ASSERT(!0);
+
+Q_STATIC_ASSERT(!!true);
+Q_STATIC_ASSERT(!!1);
+
+#ifdef Q_COMPILER_THREAD_LOCAL
+static thread_local int gt_var;
+void thread_local_test()
+{
+ thread_local int t_var;
+ t_var = gt_var;
+}
+#endif
+
diff --git a/tests/auto/corelib/global/qglobal/qglobal.pro b/tests/auto/corelib/global/qglobal/qglobal.pro
index b8ed7761f5..a40cb9a288 100644
--- a/tests/auto/corelib/global/qglobal/qglobal.pro
+++ b/tests/auto/corelib/global/qglobal/qglobal.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
TARGET = tst_qglobal
QT = core testlib
-SOURCES = tst_qglobal.cpp
+SOURCES = tst_qglobal.cpp qglobal.c
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 083526fdc4..78b954f373 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -39,6 +39,7 @@ class tst_QGlobal: public QObject
Q_OBJECT
private slots:
+ void cMode();
void qIsNull();
void for_each();
void qassert();
@@ -56,6 +57,22 @@ private slots:
void testqOverload();
};
+extern "C" { // functions in qglobal.c
+void tst_GlobalTypes();
+int tst_QtVersion();
+const char *tst_qVersion();
+}
+
+void tst_QGlobal::cMode()
+{
+ tst_GlobalTypes();
+ QCOMPARE(tst_QtVersion(), QT_VERSION);
+
+#ifndef QT_NAMESPACE
+ QCOMPARE(tst_qVersion(), qVersion());
+#endif
+}
+
void tst_QGlobal::qIsNull()
{
double d = 0.0;
diff --git a/tests/auto/corelib/global/qlogging/qlogging.pro b/tests/auto/corelib/global/qlogging/qlogging.pro
index f1ca6570a0..bbe75297d5 100644
--- a/tests/auto/corelib/global/qlogging/qlogging.pro
+++ b/tests/auto/corelib/global/qlogging/qlogging.pro
@@ -1,6 +1,8 @@
TEMPLATE = subdirs
-CONFIG += ordered
-!winrt: SUBDIRS += app
+!winrt {
+ test.depends = app
+ SUBDIRS += app
+}
SUBDIRS += test
diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
index 220ec9a2f8..7a6842d144 100644
--- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
+++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
@@ -840,10 +840,6 @@ void tst_QRandomGenerator::stdUniformIntDistribution()
void tst_QRandomGenerator::stdGenerateCanonical()
{
-#if defined(Q_CC_MSVC) && Q_CC_MSVC < 1900
- // see https://connect.microsoft.com/VisualStudio/feedback/details/811611
- QSKIP("MSVC 2013's std::generate_canonical is broken");
-#else
QFETCH(uint, control);
RandomGenerator rng(control);
@@ -858,7 +854,6 @@ void tst_QRandomGenerator::stdGenerateCanonical()
for (int i = 0; i < 4; ++i)
QVERIFY_3TIMES(std::generate_canonical<qreal COMMA 32>(rng) !=
std::generate_canonical<qreal COMMA 32>(rng));
-#endif
}
void tst_QRandomGenerator::stdUniformRealDistribution_data()