summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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/itemmodels/qitemmodel/tst_qitemmodel.cpp4
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp6
6 files changed, 173 insertions, 11 deletions
diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
index 9bd87e3f21..d2902f4944 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()
@@ -305,5 +307,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..bf2943a63c
--- /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);
+
+ qssize_t 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/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
index 8ebb860edd..3d9446965e 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
@@ -533,9 +533,6 @@ void tst_QItemModel::data()
// A valid index should have a valid qvariant data
QVERIFY(currentModel->index(0,0).isValid());
- // shouldn't be able to set data on an invalid index
- QCOMPARE(currentModel->setData(QModelIndex(), "foo", Qt::DisplayRole), false);
-
// General Purpose roles
QVariant variant = currentModel->data(currentModel->index(0,0), Qt::ToolTipRole);
if (variant.isValid()) {
@@ -605,7 +602,6 @@ void tst_QItemModel::setData()
QVERIFY(currentModel);
QSignalSpy spy(currentModel, &QAbstractItemModel::dataChanged);
QVERIFY(spy.isValid());
- QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false);
QCOMPARE(spy.count(), 0);
QFETCH(bool, isEmpty);
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
index adc8c59bf7..9a54c0a70d 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
@@ -112,12 +112,6 @@ void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data()
QStringList res3;
QTest::newRow( "data3" ) << strings3 << 0 << 5 << aboutto3 << res3;
- /* Not sure if this is a valid test */
- QStringList strings4; strings4 << "One" << "Two" << "Three" << "Four" << "Five";
- QStringList aboutto4; aboutto4 << "Five" << "";
- QStringList res4; res4 << "One" << "Two" << "Three" << "Four";
- QTest::newRow( "data4" ) << strings4 << 4 << 2 << aboutto4 << res4;
-
/*
* Keep this, template to add more data
QStringList strings2; strings2 << "One" << "Two" << "Three" << "Four" << "Five";