summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-08-03 12:46:15 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-09 21:27:09 +0200
commitfa08b143f3deb1db11984a88aa34d541c19c9fc5 (patch)
treeabbe3ff4f15f148d97edf6bd13eed79a4294d318 /tests
parent977441f61cc42b7f29e48980577105323fbd3b47 (diff)
QtGlobal: (new) qEnvironmentVariableIs{Set,Empty}()
These functions are a faster version of {,!}qgetenv().is{Null,Empty}(), a common pattern in Qt code. Their main advantage is that they don't need to allocate memory, so they can be used in noexcept functions, or dynamic initialisation of namespace-scope statics, because throwing in these contexts invokes std::terminate(). Change-Id: I651c5bd72f450b5d7df76590f8791572fe992af5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
index e074aeb3e9..d7733bad02 100644
--- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
+++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
@@ -53,12 +53,27 @@ private slots:
void tst_QGetPutEnv::getSetCheck()
{
- const char* varName = "should_not_exist";
+ const char varName[] = "should_not_exist";
+
+ QVERIFY(!qEnvironmentVariableIsSet(varName));
+ QVERIFY(qEnvironmentVariableIsEmpty(varName));
QByteArray result = qgetenv(varName);
QCOMPARE(result, QByteArray());
+
+#ifndef Q_OS_WIN
+ QVERIFY(qputenv(varName, "")); // deletes varName instead of making it empty, on Windows
+
+ QVERIFY(qEnvironmentVariableIsSet(varName));
+ QVERIFY(qEnvironmentVariableIsEmpty(varName));
+#endif
+
QVERIFY(qputenv(varName, QByteArray("supervalue")));
+
+ QVERIFY(qEnvironmentVariableIsSet(varName));
+ QVERIFY(!qEnvironmentVariableIsEmpty(varName));
result = qgetenv(varName);
QVERIFY(result == "supervalue");
+
qputenv(varName,QByteArray());
}