tst_qsettings: reliably remove the empty.ini file

... using QScopeGuard.

Change-Id: I3693ca5e5ef32aa7ccabaa7e05a94bee69e0910b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2021-06-10 22:51:59 +02:00
parent 44fa80cbd4
commit 16f695f8a8

View File

@ -2177,6 +2177,8 @@ void tst_QSettings::testEmptyData()
vList2 << emptyString << nullString; vList2 << emptyString << nullString;
vList3 << QString("foo"); vList3 << QString("foo");
const auto rm = QScopeGuard([=] { QFile::remove(filename); });
{ {
QSettings settings(filename, QSettings::IniFormat); QSettings settings(filename, QSettings::IniFormat);
settings.setValue("nullString", nullString); settings.setValue("nullString", nullString);
@ -2230,7 +2232,6 @@ void tst_QSettings::testEmptyData()
QCOMPARE(settings.value("vList3").toList(), vList3); QCOMPARE(settings.value("vList3").toList(), vList3);
QCOMPARE(settings.status(), QSettings::NoError); QCOMPARE(settings.status(), QSettings::NoError);
} }
QFile::remove(filename);
} }
void tst_QSettings::testEmptyKey() void tst_QSettings::testEmptyKey()