Fix some clazy warning

wilder
Montel Laurent 8 years ago
parent 61995dafce
commit ee2b394599
  1. 6
      autotests/kconfig_compiler/test1main.cpp
  2. 6
      autotests/kconfig_compiler/test4main.cpp
  3. 2
      autotests/kconfig_compiler/test9main.cpp
  4. 10
      autotests/kconfigguitest.cpp
  5. 12
      autotests/kconfigloadertest.cpp
  6. 16
      autotests/kconfigskeletontest.cpp
  7. 52
      autotests/kconfigtest.cpp
  8. 16
      autotests/kdesktopfiletest.cpp
  9. 12
      autotests/test_kconf_update.cpp
  10. 6
      autotests/test_kconfigutils.cpp

@ -29,9 +29,9 @@ int main(int argc, char **argv)
Q_UNUSED(app);
{
KConfig initialConfig(QLatin1String("examplerc"));
KConfigGroup group = initialConfig.group(QLatin1String("MyOptions"));
group.writeEntry(QLatin1String("MyString"), QStringLiteral("The String"));
KConfig initialConfig(QStringLiteral("examplerc"));
KConfigGroup group = initialConfig.group(QStringLiteral("MyOptions"));
group.writeEntry(QStringLiteral("MyString"), QStringLiteral("The String"));
}
Test1 *t = new Test1(QString(), QString());

@ -29,9 +29,9 @@ int main(int argc, char **argv)
QGuiApplication app(argc, argv);
Q_UNUSED(app);
{
KConfig initialConfig(QLatin1String("test4rc"));
KConfigGroup group = initialConfig.group(QLatin1String("Foo"));
group.writeEntry(QLatin1String("foo bar"), QStringLiteral("Value"));
KConfig initialConfig(QStringLiteral("test4rc"));
KConfigGroup group = initialConfig.group(QStringLiteral("Foo"));
group.writeEntry(QStringLiteral("foo bar"), QStringLiteral("Value"));
}
Test4 *t = Test4::self();
bool ok = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/test4rc");

@ -34,7 +34,7 @@ int main(int argc, char **argv)
// add another path
QStringList newlist;
myPathsList2 << QDir::homePath() + QString::fromLatin1("/.kde");
myPathsList2 << QDir::homePath() + QLatin1String("/.kde");
qWarning() << myPathsList2;
t->setMyPathsList2(myPathsList2);

@ -42,7 +42,7 @@ void KConfigTest::initTestCase()
KConfigSkeleton foo;
Q_UNUSED(foo);
KConfig sc("kconfigtest");
KConfig sc(QStringLiteral("kconfigtest"));
KConfigGroup cg(&sc, "ComplexTypes");
cg.writeEntry("colorEntry1", COLORENTRY1);
@ -52,7 +52,7 @@ void KConfigTest::initTestCase()
cg.writeEntry("fontEntry", FONTENTRY);
QVERIFY(sc.sync());
KConfig sc1("kdebugrc");
KConfig sc1(QStringLiteral("kdebugrc"));
KConfigGroup sg0(&sc1, "0");
sg0.writeEntry("AbortFatal", false);
sg0.writeEntry("WarnOutput", 0);
@ -81,7 +81,7 @@ void KConfigTest::cleanupTestCase()
void KConfigTest::testComplex()
{
KConfig sc2("kconfigtest");
KConfig sc2(QStringLiteral("kconfigtest"));
KConfigGroup sc3(&sc2, "ComplexTypes");
QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(),
@ -99,7 +99,7 @@ void KConfigTest::testComplex()
void KConfigTest::testInvalid()
{
KConfig sc("kconfigtest");
KConfig sc(QStringLiteral("kconfigtest"));
// all of these should print a message to the kdebug.dbg file
KConfigGroup sc3(&sc, "InvalidTypes");
@ -108,7 +108,7 @@ void KConfigTest::testInvalid()
// 1 element list
list << 1;
sc3.writeEntry(QString("badList"), list);
sc3.writeEntry(QStringLiteral("badList"), list);
QVERIFY(sc.sync());
QVERIFY(sc3.readEntry("badList", QColor()) == QColor());

@ -38,7 +38,7 @@ Q_DECLARE_METATYPE(QList<int>)
void ConfigLoaderTest::init()
{
QString fileName = TEST_NAME + QString::fromLatin1(".xml");
QString fileName = TEST_NAME + QLatin1String(".xml");
configFile = new QFile(QFINDTESTDATA(QString::fromLatin1("/") + fileName));
cl = new KConfigLoader(configFile->fileName(), configFile);
}
@ -118,11 +118,11 @@ void ConfigLoaderTest::stringListDefaultValue()
// Create a string list with the expected values.
QStringList expected;
expected.append("One");
expected.append("Two");
expected.append("Three");
expected.append("Four");
expected.append("Five");
expected.append(QStringLiteral("One"));
expected.append(QStringLiteral("Two"));
expected.append(QStringLiteral("Three"));
expected.append(QStringLiteral("Four"));
expected.append(QStringLiteral("Five"));
QVERIFY(typeItem->isEqual(expected));
}

@ -43,14 +43,14 @@ void KConfigSkeletonTest::initTestCase()
void KConfigSkeletonTest::init()
{
QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/kconfigskeletontestrc");
s = new KConfigSkeleton("kconfigskeletontestrc");
s->setCurrentGroup("MyGroup");
itemBool = s->addItemBool("MySetting1", mMyBool, DEFAULT_SETTING1);
s->addItemColor("MySetting2", mMyColor, DEFAULT_SETTING2);
s = new KConfigSkeleton(QStringLiteral("kconfigskeletontestrc"));
s->setCurrentGroup(QStringLiteral("MyGroup"));
itemBool = s->addItemBool(QStringLiteral("MySetting1"), mMyBool, DEFAULT_SETTING1);
s->addItemColor(QStringLiteral("MySetting2"), mMyColor, DEFAULT_SETTING2);
s->setCurrentGroup("MyOtherGroup");
s->addItemFont("MySetting3", mMyFont, DEFAULT_SETTING3);
s->addItemString("MySetting4", mMyString, DEFAULT_SETTING4);
s->setCurrentGroup(QStringLiteral("MyOtherGroup"));
s->addItemFont(QStringLiteral("MySetting3"), mMyFont, DEFAULT_SETTING3);
s->addItemString(QStringLiteral("MySetting4"), mMyString, DEFAULT_SETTING4);
QCOMPARE(mMyBool, DEFAULT_SETTING1);
QCOMPARE(mMyColor, DEFAULT_SETTING2);
@ -88,7 +88,7 @@ void KConfigSkeletonTest::testSimple()
void KConfigSkeletonTest::testRemoveItem()
{
QVERIFY(s->findItem("MySetting1"));
s->removeItem("MySetting1");
s->removeItem(QStringLiteral("MySetting1"));
QVERIFY(!s->findItem("MySetting1"));
}

@ -122,7 +122,7 @@ void KConfigTest::initTestCase()
cg.writeEntry("stringEntry3", STRINGENTRY3);
cg.writeEntry("stringEntry4", STRINGENTRY4);
cg.writeEntry("stringEntry5", STRINGENTRY5);
cg.writeEntry("urlEntry1", QUrl("http://qt-project.org"));
cg.writeEntry("urlEntry1", QUrl(QStringLiteral("http://qt-project.org")));
cg.writeEntry("keywith=equalsign", STRINGENTRY1);
cg.deleteEntry("stringEntry5");
cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry
@ -315,7 +315,7 @@ void KConfigTest::testRevertAllEntries()
void KConfigTest::testSimple()
{
// kdeglobals (which was created in initTestCase) must be found this way:
const QStringList kdeglobals = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QLatin1String("kdeglobals"));
const QStringList kdeglobals = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QStringLiteral("kdeglobals"));
QVERIFY(!kdeglobals.isEmpty());
KConfig sc2(TEST_SUBDIR "kconfigtest");
@ -343,7 +343,7 @@ void KConfigTest::testSimple()
QCOMPARE(sc3.readEntry("bytearrayEntry", QByteArray()), BYTEARRAYENTRY);
QCOMPARE(sc3.readEntry(ESCAPEKEY), QString(ESCAPEENTRY));
QCOMPARE(sc3.readEntry("Test", QString()), QString::fromUtf8(UTF8BITENTRY));
QCOMPARE(sc3.readEntry("emptyEntry"/*, QString("Fietsbel")*/), QString(""));
QCOMPARE(sc3.readEntry("emptyEntry"/*, QString("Fietsbel")*/), QLatin1String(""));
QCOMPARE(sc3.readEntry("emptyEntry", QString("Fietsbel")).isEmpty(), true);
QCOMPARE(sc3.readEntry("stringEntry1"), QString(STRINGENTRY1));
QCOMPARE(sc3.readEntry("stringEntry2"), QString(STRINGENTRY2));
@ -369,8 +369,8 @@ void KConfigTest::testDefaults()
const QString defaultsFile = TEST_SUBDIR "defaulttest.defaults";
KConfig defaults(defaultsFile, KConfig::SimpleConfig);
const QString Default("Default");
const QString NotDefault("Not Default");
const QString Default(QStringLiteral("Default"));
const QString NotDefault(QStringLiteral("Not Default"));
const QString Value1(STRINGENTRY1);
const QString Value2(STRINGENTRY2);
@ -419,14 +419,14 @@ void KConfigTest::testLocale()
KConfigGroup group = config.group("Hello");
group.writeEntry("stringEntry1", Untranslated);
config.setLocale("fr");
config.setLocale(QStringLiteral("fr"));
group.writeEntry("stringEntry1", Translated, KConfig::Localized | KConfig::Persistent);
QVERIFY(config.sync());
QCOMPARE(group.readEntry("stringEntry1", QString()), Translated);
QCOMPARE(group.readEntryUntranslated("stringEntry1"), Untranslated);
config.setLocale("C"); // strings written in the "C" locale are written as nonlocalized
config.setLocale(QStringLiteral("C")); // strings written in the "C" locale are written as nonlocalized
group.writeEntry("stringEntry1", Untranslated, KConfig::Localized | KConfig::Persistent);
QVERIFY(config.sync());
@ -435,7 +435,7 @@ void KConfigTest::testLocale()
void KConfigTest::testEncoding()
{
QString groupstr = QString::fromUtf8("UTF-8:\xc3\xb6l");
QString groupstr = QStringLiteral("UTF-8:\xc3\xb6l");
KConfig c(TEST_SUBDIR "kconfigtestencodings");
KConfigGroup cg(&c, groupstr);
@ -664,7 +664,7 @@ void KConfigTest::testInvalid()
// 1 element list
list << 1;
sc3.writeEntry(QString("badList"), list);
sc3.writeEntry(QStringLiteral("badList"), list);
QVERIFY(sc3.readEntry("badList", QPoint()) == QPoint());
QVERIFY(sc3.readEntry("badList", QRect()) == QRect());
@ -971,7 +971,7 @@ void KConfigTest::testCascadingWithLocale()
QCOMPARE(group.readEntry("FromGlobal"), QString("true"));
QCOMPARE(group.readEntry("FromLocal"), QString("true"));
QCOMPARE(group.readEntry("Name"), QString("Local Testing"));
config.setLocale("fr");
config.setLocale(QStringLiteral("fr"));
QCOMPARE(group.readEntry("FromGlobal"), QString("vrai"));
QCOMPARE(group.readEntry("FromLocal"), QString("vrai"));
QCOMPARE(group.readEntry("Name"), QString("FR"));
@ -1063,12 +1063,12 @@ void KConfigTest::testOptionOrder()
<< "entry2[$i][de_DE]=t2" << endl;
}
KConfig config(TEST_SUBDIR "doubleattrtest", KConfig::SimpleConfig);
config.setLocale("de_DE");
config.setLocale(QStringLiteral("de_DE"));
KConfigGroup cg3 = config.group("group3");
QVERIFY(!cg3.isImmutable());
QCOMPARE(cg3.readEntry("entry2", ""), QString("t2"));
QVERIFY(cg3.isEntryImmutable("entry2"));
config.setLocale("C");
config.setLocale(QStringLiteral("C"));
QCOMPARE(cg3.readEntry("entry2", ""), QString("unlocalized"));
QVERIFY(!cg3.isEntryImmutable("entry2"));
cg3.writeEntry("entry2", "modified");
@ -1117,9 +1117,9 @@ void KConfigTest::testSubGroup()
groupList.sort(); // comes from QSet, so order is undefined
QCOMPARE(groupList, (QStringList() << "SubGroup/3" << "SubGroup1" << "SubGroup2"));
const QStringList expectedSubgroup3Keys = (QStringList() << "sub3string");
const QStringList expectedSubgroup3Keys = (QStringList() << QStringLiteral("sub3string"));
QCOMPARE(subcg3.keyList(), expectedSubgroup3Keys);
const QStringList expectedParentGroupKeys(QStringList() << "parentgrpstring");
const QStringList expectedParentGroupKeys(QStringList() << QStringLiteral("parentgrpstring"));
QCOMPARE(cg.keyList(), expectedParentGroupKeys);
@ -1290,7 +1290,7 @@ void KConfigTest::testConfigCopyTo()
void KConfigTest::testReparent()
{
KConfig cf(TEST_SUBDIR "kconfigtest");
const QString name("Enum Types");
const QString name(QStringLiteral("Enum Types"));
KConfigGroup group = cf.group(name);
const QMap<QString, QString> originalMap = group.entryMap();
KConfigGroup parent = cf.group("Parent Group");
@ -1491,7 +1491,7 @@ void KConfigTest::testLocaleConfig()
// Load the testdata
QVERIFY(QFile::exists(file));
KConfig config(file);
config.setLocale("ca");
config.setLocale(QStringLiteral("ca"));
// This group has only localized values. That is not supported. The values
// should be dropped on loading.
@ -1542,7 +1542,7 @@ void KConfigTest::testDeleteWhenLocalized()
// Load the testdata. We start in locale "ca".
QVERIFY(QFile::exists(file));
KConfig config(file);
config.setLocale("ca");
config.setLocale(QStringLiteral("ca"));
KConfigGroup cg(&config, "Test4711");
// Delete a value. Once with localized, once with Normal
@ -1566,7 +1566,7 @@ void KConfigTest::testDeleteWhenLocalized()
// Now switch the locale to "de" and repeat the checks. Results should be
// the same. But they currently are not. The localized value are
// independent of each other. All values are still there in "de".
config.setLocale("de");
config.setLocale(QStringLiteral("de"));
QEXPECT_FAIL("", "Currently localized values are not deleted correctly", Continue);
QVERIFY(!cg.hasKey("foostring"));
QEXPECT_FAIL("", "Currently localized values are not deleted correctly", Continue);
@ -1580,7 +1580,7 @@ void KConfigTest::testDeleteWhenLocalized()
// Now switch the locale back "ca" and repeat the checks. Results are
// again different.
config.setLocale("ca");
config.setLocale(QStringLiteral("ca"));
// This line worked above. But now it fails.
QEXPECT_FAIL("", "Currently localized values are not deleted correctly", Continue);
QVERIFY(!cg.hasKey("foostring"));
@ -1610,7 +1610,7 @@ void KConfigTest::testDeleteWhenLocalized()
// Now switch the locale to "de" and repeat the checks. All values
// still here because only the primary values are deleted.
config.setLocale("de");
config.setLocale(QStringLiteral("de"));
QEXPECT_FAIL("", "Currently localized values are not deleted correctly", Continue);
QVERIFY(!cg.hasKey("foo"));
QEXPECT_FAIL("", "Currently localized values are not deleted correctly", Continue);
@ -1628,7 +1628,7 @@ void KConfigTest::testDeleteWhenLocalized()
// Now switch the locale to "ca" and repeat the checks
// "foostring" is now really gone because both the primary value and the
// "ca" value are deleted.
config.setLocale("ca");
config.setLocale(QStringLiteral("ca"));
QEXPECT_FAIL("", "Currently localized values are not deleted correctly", Continue);
QVERIFY(!cg.hasKey("foo"));
QVERIFY(!cg.hasKey("foostring"));
@ -1647,13 +1647,13 @@ void KConfigTest::testDeleteWhenLocalized()
void KConfigTest::testKdeGlobals()
{
{
KConfig glob("kdeglobals");
KConfig glob(QStringLiteral("kdeglobals"));
KConfigGroup general(&glob, "General");
general.writeEntry("testKG", "1");
QVERIFY(glob.sync());
}
KConfig globRead("kdeglobals");
KConfig globRead(QStringLiteral("kdeglobals"));
const KConfigGroup general(&globRead, "General");
QCOMPARE(general.readEntry("testKG"), QString("1"));
@ -1664,7 +1664,7 @@ void KConfigTest::testKdeGlobals()
// Writing using NoGlobals
{
KConfig glob("kdeglobals", KConfig::NoGlobals);
KConfig glob(QStringLiteral("kdeglobals"), KConfig::NoGlobals);
KConfigGroup general(&glob, "General");
general.writeEntry("testKG", "2");
QVERIFY(glob.sync());
@ -1674,7 +1674,7 @@ void KConfigTest::testKdeGlobals()
// Reading using NoGlobals
{
KConfig globReadNoGlob("kdeglobals", KConfig::NoGlobals);
KConfig globReadNoGlob(QStringLiteral("kdeglobals"), KConfig::NoGlobals);
const KConfigGroup generalNoGlob(&globReadNoGlob, "General");
QCOMPARE(generalNoGlob.readEntry("testKG"), QString("2"));
}
@ -1732,7 +1732,7 @@ void KConfigTest::testXdgListEntry()
KConfig anonConfig(file.fileName(), KConfig::SimpleConfig);
KConfigGroup grp = anonConfig.group("General");
QStringList invalidList; // use this as a default when an empty list is expected
invalidList << "Error! Default value read!";
invalidList << QStringLiteral("Error! Default value read!");
QCOMPARE(grp.readXdgListEntry("Key1", invalidList), QStringList());
QCOMPARE(grp.readXdgListEntry("Key2", invalidList), QStringList() << QString());
QCOMPARE(grp.readXdgListEntry("Key3", invalidList), QStringList() << QString() << QString());

@ -37,7 +37,7 @@ void KDesktopFileTest::initTestCase()
void KDesktopFileTest::testRead()
{
QTemporaryFile file("testReadXXXXXX.desktop");
QTemporaryFile file(QStringLiteral("testReadXXXXXX.desktop"));
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
@ -87,7 +87,7 @@ void KDesktopFileTest::testReadLocalized_data()
void KDesktopFileTest::testReadLocalized()
{
QTemporaryFile file("testReadLocalizedXXXXXX.desktop");
QTemporaryFile file(QStringLiteral("testReadLocalizedXXXXXX.desktop"));
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
@ -174,20 +174,20 @@ void KDesktopFileTest::testActionGroup()
QCOMPARE(df.hasActionGroup("semi;colon"), true);
QCOMPARE(df.hasActionGroup("decrypt"), true);
QCOMPARE(df.hasActionGroup("doesnotexist"), false);
KConfigGroup cg = df.actionGroup("encrypt");
KConfigGroup cg = df.actionGroup(QStringLiteral("encrypt"));
QVERIFY(cg.hasKey("Name"));
QCOMPARE(cg.readEntry("Name"), QString("Encrypt file"));
cg = df.actionGroup("decrypt");
cg = df.actionGroup(QStringLiteral("decrypt"));
QVERIFY(cg.hasKey("Name"));
QCOMPARE(cg.readEntry("Name"), QString("Decrypt file"));
cg = df.actionGroup("semi;colon");
cg = df.actionGroup(QStringLiteral("semi;colon"));
QVERIFY(cg.hasKey("Name"));
QCOMPARE(cg.readEntry("Name"), QString("With semicolon"));
}
void KDesktopFileTest::testIsAuthorizedDesktopFile()
{
QTemporaryFile file("testAuthXXXXXX.desktop");
QTemporaryFile file(QStringLiteral("testAuthXXXXXX.desktop"));
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
@ -219,7 +219,7 @@ void KDesktopFileTest::testIsAuthorizedDesktopFile()
void KDesktopFileTest::testTryExecWithAuthorizeAction()
{
{
QTemporaryFile file("testAuthActionXXXXXX.desktop");
QTemporaryFile file(QStringLiteral("testAuthActionXXXXXX.desktop"));
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
@ -237,7 +237,7 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction()
QVERIFY(desktopFile.tryExec());
}
{
QTemporaryFile file("testAuthActionXXXXXX.desktop");
QTemporaryFile file(QStringLiteral("testAuthActionXXXXXX.desktop"));
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);

@ -325,7 +325,7 @@ void TestKConfUpdate::test()
QFETCH(bool, shouldUpdateWork);
// Prepend Version and the Id= field to the upd content
const QString header = QString("Id=%1\n").arg(QTest::currentDataTag());
const QString header = QStringLiteral("Id=%1\n").arg(QTest::currentDataTag());
updContent = header + updContent;
if (useVersion5)
updContent.prepend("Version=5\n");
@ -341,7 +341,7 @@ void TestKConfUpdate::test()
QSharedPointer<QTemporaryFile> updFile(writeUpdFile(updContent));
runKConfUpdate(updFile->fileName());
QString updateInfo = QString("%1:%2")
QString updateInfo = QStringLiteral("%1:%2")
.arg(updFile->fileName().section('/', -1))
.arg(QTest::currentDataTag());
@ -557,7 +557,7 @@ void TestKConfUpdate::testScript_data()
"new=value3\n"
;
if (QStandardPaths::findExecutable("sed").isEmpty()) {
if (QStandardPaths::findExecutable(QStringLiteral("sed")).isEmpty()) {
qWarning("sed executable not found, cannot run all tests!");
} else {
QTest::newRow("filter")
@ -610,7 +610,7 @@ void TestKConfUpdate::testScript_data()
void TestKConfUpdate::testScript()
{
if (QStandardPaths::findExecutable("sh").isEmpty()) {
if (QStandardPaths::findExecutable(QStringLiteral("sh")).isEmpty()) {
QSKIP("Could not find sh executable, cannot run test");
return;
}
@ -621,7 +621,7 @@ void TestKConfUpdate::testScript()
QFETCH(QString, expectedNewConfContent);
// Prepend the Version and Id= field to the upd content
updContent = QString("Version=5\nId=%1\n").arg(QTest::currentDataTag()) + updContent;
updContent = QStringLiteral("Version=5\nId=%1\n").arg(QTest::currentDataTag()) + updContent;
QSharedPointer<QTemporaryFile> updFile(writeUpdFile(updContent));
@ -637,7 +637,7 @@ void TestKConfUpdate::testScript()
runKConfUpdate(updFile->fileName());
QString updateInfo = QString("%1:%2")
QString updateInfo = QStringLiteral("%1:%2")
.arg(updFile->fileName().section('/', -1))
.arg(QTest::currentDataTag());
QString newConfContent = readFile(confPath);

@ -36,19 +36,19 @@ void TestKConfigUtils::testParseGroupString_data()
QTest::newRow("simple-group")
<< " group "
<< (QStringList() << "group")
<< (QStringList() << QStringLiteral("group"))
<< true
;
QTest::newRow("sub-group")
<< "[group][sub]"
<< (QStringList() << "group" << "sub")
<< (QStringList() << QStringLiteral("group") << QStringLiteral("sub"))
<< true
;
QTest::newRow("crazy-sub-group")
<< "[a\\ttab\\x5d[and some hex esc\\x61pe]"
<< (QStringList() << "a\ttab" << "and some hex escape")
<< (QStringList() << QStringLiteral("a\ttab") << QStringLiteral("and some hex escape"))
<< true
;

Loading…
Cancel
Save