summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qloggingcategory
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qloggingcategory')
-rw-r--r--tests/auto/corelib/io/qloggingcategory/CMakeLists.txt14
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp27
2 files changed, 31 insertions, 10 deletions
diff --git a/tests/auto/corelib/io/qloggingcategory/CMakeLists.txt b/tests/auto/corelib/io/qloggingcategory/CMakeLists.txt
index 13ee586696..0e9fc98fae 100644
--- a/tests/auto/corelib/io/qloggingcategory/CMakeLists.txt
+++ b/tests/auto/corelib/io/qloggingcategory/CMakeLists.txt
@@ -1,15 +1,19 @@
-# Generated from qloggingcategory.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qloggingcategory Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qloggingcategory LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qloggingcategory
SOURCES
tst_qloggingcategory.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
)
-
-#### Keys ignored in scope 1:.:.:qloggingcategory.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index a0a9bb940e..476ca275a4 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QMutexLocker>
@@ -78,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;
@@ -153,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];
}
@@ -181,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();
@@ -903,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!");
@@ -916,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)