aboutsummaryrefslogtreecommitdiff
path: root/autotests/kconfigguitest.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2021-02-03 15:28:38 +0200
committerAhmad Samir <a.samirh78@gmail.com>2021-02-06 22:11:41 +0200
commitdc878289c01011c59615746655b4e78d4bc90b91 (patch)
treea5c547a6d05e46efac6e17725d75343b40e78440 /autotests/kconfigguitest.cpp
parentbb16fda4e5f7caa9e892540ec69a202cec9eb16f (diff)
downloadkconfig-dc878289c01011c59615746655b4e78d4bc90b91.tar.gz
kconfig-dc878289c01011c59615746655b4e78d4bc90b91.tar.bz2
Minor code optimisations
- Use a global var for a QString that's used many times - Break up long-all-cap variable names, it makes it harder to read (and I've fixed one typo in one of those ALLCAPS) - Fix some clazy warnings, make global QString objects in unit tests static (so that the compiler doesn't create symbols for them, it doesn't matter in a unit test but KF code acts as a reference sometimes that others copy from, tip from dfaure) - Add TODO note about changing kconfig_compiler to generate C++ code that uses multi-arg QString::arg(QString, QString, QString) instead of QString::arg().arg() - More const; more QString::at() instead of operator[] where appropriate - Use a ternary where it makes the code more readable (and uses less lines :)) NO_CHANGELOG
Diffstat (limited to 'autotests/kconfigguitest.cpp')
-rw-r--r--autotests/kconfigguitest.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp
index 87168a7f..2744d272 100644
--- a/autotests/kconfigguitest.cpp
+++ b/autotests/kconfigguitest.cpp
@@ -18,9 +18,9 @@ QTEST_MAIN(KConfigTest)
// clazy:excludeall=non-pod-global-static
-const QColor COLORENTRY1(QLatin1String{"steelblue"});
-const QColor COLORENTRY2(235, 235, 100, 125);
-const QColor COLORENTRY3(234, 234, 127);
+static const QColor s_color_entry1(QLatin1String{"steelblue"});
+static const QColor s_color_entry2(235, 235, 100, 125);
+static const QColor s_color_entry3(234, 234, 127);
static QFont fontEntry()
{
@@ -38,8 +38,8 @@ void KConfigTest::initTestCase()
KConfig sc(QStringLiteral("kconfigtest"));
KConfigGroup cg(&sc, "ComplexTypes");
- cg.writeEntry("colorEntry1", COLORENTRY1);
- cg.writeEntry("colorEntry2", COLORENTRY2);
+ cg.writeEntry("colorEntry1", s_color_entry1);
+ cg.writeEntry("colorEntry2", s_color_entry2);
cg.writeEntry("colorEntry3", (QList<int>() << 234 << 234 << 127));
cg.writeEntry("colorEntry4", (QList<int>() << 235 << 235 << 100 << 125));
cg.writeEntry("fontEntry", fontEntry());
@@ -78,11 +78,11 @@ void KConfigTest::testComplex()
KConfigGroup sc3(&sc2, "ComplexTypes");
QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(),
- QVariant(COLORENTRY1).toString());
- QCOMPARE(sc3.readEntry("colorEntry1", QColor()), COLORENTRY1);
- QCOMPARE(sc3.readEntry("colorEntry2", QColor()), COLORENTRY2);
- QCOMPARE(sc3.readEntry("colorEntry3", QColor()), COLORENTRY3);
- QCOMPARE(sc3.readEntry("colorEntry4", QColor()), COLORENTRY2);
+ QVariant(s_color_entry1).toString());
+ QCOMPARE(sc3.readEntry("colorEntry1", QColor()), s_color_entry1);
+ QCOMPARE(sc3.readEntry("colorEntry2", QColor()), s_color_entry2);
+ QCOMPARE(sc3.readEntry("colorEntry3", QColor()), s_color_entry3);
+ QCOMPARE(sc3.readEntry("colorEntry4", QColor()), s_color_entry2);
QCOMPARE(sc3.readEntry("defaultColorTest", QColor("black")), QColor("black"));
if (m_fontFromStringBug) {
QEXPECT_FAIL("", "QFont fromString bug from Qt 5.8.0", Continue);