summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp')
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp60
1 files changed, 27 insertions, 33 deletions
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index e45c13b9b9..476ca275a4 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-#include <QtTest>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
#include <QMutexLocker>
#include <QLoggingCategory>
+#include <QMap>
+#include <QStringList>
Q_LOGGING_CATEGORY(TST_LOG, "tst.log")
Q_LOGGING_CATEGORY(Digia_Oslo_Office_com, "Digia.Oslo.Office.com")
@@ -101,7 +78,7 @@ public:
{
QString ret;
QTextStream out(&ret);
- for (int a = 0; a < _configitemEntryOrder.count(); a++) {
+ for (int a = 0; a < _configitemEntryOrder.size(); a++) {
out << _configitemEntryOrder[a]
<< " = "
<< _values.value(_configitemEntryOrder[a]) << Qt::endl;
@@ -176,7 +153,7 @@ inline QString cleanLogLine(const QString &qstring)
buf.remove("../");
buf.remove("qlog/");
QString ret;
- for (int i = 0; i < buf.length(); i++) {
+ for (int i = 0; i < buf.size(); i++) {
if (buf[i] >= '!' && buf[i] <= 'z')
ret += buf[i];
}
@@ -204,7 +181,7 @@ private slots:
void initTestCase()
{
qputenv("XDG_CONFIG_DIRS", "/does/not/exist");
- qputenv("QT_MESSAGE_PATTERN", QByteArray("%{category}: %{type},%{message}"));
+ qputenv("QT_MESSAGE_PATTERN", "%{category}: %{type},%{message}");
oldMessageHandler = qInstallMessageHandler(myCustomMessageHandler);
// Create configuration
_config = new Configuration();
@@ -926,7 +903,7 @@ private slots:
buf = QStringLiteral("Digia.Berlin.Office.com.debug: Berlin \"from Thread 2\" :false");
compareagainst.append(cleanLogLine(buf));
- for (int i = 0; i < threadtest.count(); i++) {
+ for (int i = 0; i < threadtest.size(); i++) {
if (!compareagainst.contains(cleanLogLine(threadtest[i]))){
fprintf(stdout, "%s\r\n", threadtest[i].toLatin1().constData());
QVERIFY2(false, "Multithread log is not complete!");
@@ -939,6 +916,23 @@ private slots:
delete _config;
qInstallMessageHandler(oldMessageHandler);
}
+
+ void qFatalMacros()
+ {
+ QLoggingCategory customCategory("custom");
+
+ // compile-only test for fatal macros
+ return;
+
+ qFatal("Message");
+ qFatal("Message %d", 42);
+ qFatal(customCategory, "Message %d", 42);
+ qFatal(TST_LOG, "Message %d", 42);
+
+ qFatal() << "Message" << 42;
+ qCFatal(customCategory) << "Message" << 42;
+ qCFatal(TST_LOG) << "Message" << 42;
+ }
};
QTEST_MAIN(tst_QLogging)