From 574e5cf9c510fb28781c8006a1184ca158ee859f Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 12 Jan 2013 10:12:47 +0100 Subject: Add qunsetenv(), next to qputenv() and friends. The existing tst_qgetputenv shows that qputenv with an empty value doesn't lead to the same result on Windows and on Unix, and there was no way to fully delete an env var on Unix (which is needed for some env vars where not-set and empty are different, such as TZ, see `man tzset`). This is also why qglobal has qEnvironmentVariableIsSet() vs qEnvironmentVariableIsEmpty(), on the getter side. Qt4's ifdefs around unsetenv in qapplication_x11.cpp show that this is needed within Qt too (although this particular startup notification code has to be re-imported into Qt5 still). Change-Id: I631c8cddbcf933d4b9008f11aefc59f5a3c7c866 Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp index a4aca82aa9..ef41ef8801 100644 --- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp +++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp @@ -75,6 +75,13 @@ void tst_QGetPutEnv::getSetCheck() QVERIFY(result == "supervalue"); qputenv(varName,QByteArray()); + + // Now test qunsetenv + QVERIFY(qunsetenv(varName)); + QVERIFY(!qEnvironmentVariableIsSet(varName)); + QVERIFY(qEnvironmentVariableIsEmpty(varName)); + result = qgetenv(varName); + QCOMPARE(result, QByteArray()); } QTEST_MAIN(tst_QGetPutEnv) -- cgit v1.2.3