summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-08-03 19:23:28 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-08-06 14:21:46 +0000
commit5ff71637968c70f138d8ea6cc24e61c1608f2187 (patch)
tree4b4f605969497961e70ad311b2ebed3d0b4060e3 /tests/auto/corelib/io
parent5b62970b9441717670a1756b858c500004dfdfe0 (diff)
qputenv: port to QByteArrayView
The vast majority of in-tree users pass simple and short C string literals as the value. By porting to QByteArrayView, we document that we'll accept non-NUL-terminated data, and do the NUL-termination internally, using SSO'ed std::string, saving memory allocations in the common case of short strings. I didn't bother to check which direction std::string takes for nullptrs these days (there was a change accepted in that area for C++20 or 23), so play it safe and protect against them. Follow-up to Task-number: QTBUG-105302 Change-Id: I2369acc62f1d5cbc26135396cfe0602d8c75300c Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp2
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp8
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index a0a9bb940e..3ba6de20a9 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -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();
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 2c0500eec9..b2bb14180e 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -64,10 +64,10 @@ private:
qputenv("XDG_DATA_DIRS", QFile::encodeName(m_globalAppDir));
}
void setDefaultLocations() {
- qputenv("XDG_CONFIG_HOME", QByteArray());
- qputenv("XDG_CONFIG_DIRS", QByteArray());
- qputenv("XDG_DATA_HOME", QByteArray());
- qputenv("XDG_DATA_DIRS", QByteArray());
+ qputenv("XDG_CONFIG_HOME", nullptr);
+ qputenv("XDG_CONFIG_DIRS", nullptr);
+ qputenv("XDG_DATA_HOME", nullptr);
+ qputenv("XDG_DATA_DIRS", nullptr);
}
#endif