From 7bf4f81de81b6e800509867d5acad545c566dbac Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 17 Sep 2019 19:53:55 +0200 Subject: Add qfloat16::copySign() since we can't overload std::copysign() Change-Id: Idfaf841b3eb3538f076ae4f0de2d7d029e1588fe Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib/global') diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index 94f0afa5ed..a661b0388e 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -430,6 +430,13 @@ void tst_qfloat16::finite() QVERIFY(!qIsInf(value)); QVERIFY(!qIsNaN(value)); QCOMPARE(qFpClassify(value), mode); + + // *NOT* using QCOMPARE() on finite qfloat16 values, since that uses fuzzy + // comparison, and we need exact here. + const qfloat16 zero(0), plus(+1), minus(-1); + const qfloat16 magnitude = (value < zero) ? -value : value; + QVERIFY(value.copySign(plus) == magnitude); + QVERIFY(value.copySign(minus) == -magnitude); } void tst_qfloat16::properties() @@ -534,7 +541,9 @@ void tst_qfloat16::limits() // See also: qNaN() and infinity() QVERIFY(Bounds::denorm_min() / rose == zero); if (overOptimized) QEXPECT_FAIL("", "Over-optimized on ARM", Continue); - QVERIFY(-Bounds::denorm_min() / rose == -zero); + const qfloat16 under = (-Bounds::denorm_min()) / rose; + QVERIFY(under == -zero); + QCOMPARE(qfloat16(1).copySign(under), qfloat16(-1)); } QTEST_APPLESS_MAIN(tst_qfloat16) -- cgit v1.2.3 From af2daafde72db02454d24b7d691aa6861525ab99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 18 Nov 2019 17:01:26 +0100 Subject: Deprecate constructing QFlags from a pointer This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qflags/tst_qflags.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/corelib/global') diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 1568855032..be75f5b3cc 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -49,7 +49,7 @@ void tst_QFlags::testFlag() const QVERIFY(btn.testFlag(Qt::LeftButton)); QVERIFY(!btn.testFlag(Qt::MidButton)); - btn = 0; + btn = { }; QVERIFY(!btn.testFlag(Qt::LeftButton)); } -- cgit v1.2.3 From c3bd5ffdc8a3b459f18ba6e35fca93e29f3b0ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 8 Dec 2019 23:47:10 +0100 Subject: Don't wrap feature detection macros with QT_HAS_FOO() variants Using wrappers for these macros is problematic when for example passing the -frewrite-includes flag to preprocess sources before shipping off to distcc or Icecream. It will also start producing warnings when compilers implement http://eel.is/c++draft/cpp.cond#7.sentence-2. See for example https://reviews.llvm.org/D49091 Both https://clang.llvm.org/docs/LanguageExtensions.html and the SD-6 document at https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations recommend defining '__has_foo(x) 0' as a fallback for compilers without the macros, so that's what we go for. Change-Id: I0298cd3b4a6ff6618821e34642a5ddd6728be767 Reviewed-by: Alex Richardson Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qglobal/qglobal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/corelib/global') diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c index c7124454d0..7a2266ae94 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.c +++ b/tests/auto/corelib/global/qglobal/qglobal.c @@ -28,7 +28,7 @@ #include -#if QT_HAS_INCLUDE() || __STDC_VERSION__ >= 199901L +#if __has_include() || __STDC_VERSION__ >= 199901L # include #else # undef true -- cgit v1.2.3 From 70d484b5df6211546e17f336782f83a3f856965d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 8 Jan 2020 17:05:15 +0100 Subject: Fix encoding expected by tst_qmessagehandler::qMessagePattern() The actual logging code, qt_message_print(), uses toLocal8Bit(), so testing by comaring with toUtf8() isn't robust. Change-Id: I7d6614e4af8c679674dbbf4ff47a88b2b75fc2dc Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/auto/corelib/global') diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 17d0f86728..3af637d13a 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2014 Olivier Goffart ** Contact: https://www.qt.io/licensing/ ** @@ -767,18 +767,18 @@ void tst_qmessagehandler::qMessagePattern_data() QTest::qWait(10000); QTest::newRow("time") << "/%{time yyyy - MM - d}/%{message}" << true << (QList() - << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + "/qDebug")); + << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toLocal8Bit() + "/qDebug")); QTest::newRow("time-time") << "/%{time yyyy - MM - d}/%{time dd-MM-yy}/%{message}" << true << (QList() - << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() - + '/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toLocal8Bit() + + '/' + QDateTime::currentDateTime().toString("dd-MM-yy").toLocal8Bit() + "/qDebug")); QTest::newRow("skipped-time-shown-time") << "/%{if-warning}%{time yyyy - MM - d}%{endif}%{if-debug}%{time dd-MM-yy}%{endif}/%{message}" << true << (QList() - << ('/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + "/qDebug")); + << ('/' + QDateTime::currentDateTime().toString("dd-MM-yy").toLocal8Bit() + "/qDebug")); // %{time} should have a padding of 6 so if it takes less than 10 seconds to show // the first message, there should be 5 spaces -- cgit v1.2.3