diff options
author | Alex Richardson <arichardson.kde@gmail.com> | 2014-07-01 20:33:41 +0200 |
---|---|---|
committer | Alex Richardson <arichardson.kde@gmail.com> | 2014-07-01 20:49:45 +0200 |
commit | ae51450ea64970dcdc544185d68e1e73fb390caa (patch) | |
tree | 8047cfbf70cd0276f2f4fc562589d208cf6a417d /autotests/kconfigtest.cpp | |
parent | fde2f3c847d2fb90c3354e045bf7d82b04d6e169 (diff) | |
download | kconfig-ae51450ea64970dcdc544185d68e1e73fb390caa.tar.gz kconfig-ae51450ea64970dcdc544185d68e1e73fb390caa.tar.bz2 |
Fix reading of XDG style semicolon separated lists with escaped ';'
Previously the warning "Invalid escape sequence "\;"." would appear and
"\;" was replaced with just the backslash as is done for all
unrecognized escape sequences. Keep both characters so that
readXdgListEntry() works with values containing semicolons
REVIEW: 119074
Diffstat (limited to 'autotests/kconfigtest.cpp')
-rw-r--r-- | autotests/kconfigtest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 5f2c7989..7cb3f903 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1672,6 +1672,33 @@ void KConfigTest::testNewlines() } +void KConfigTest::testXdgListEntry() +{ + QTemporaryFile file; + QVERIFY(file.open()); + QTextStream out(&file); + out << "[General]" << endl + << "Key1=" << endl // empty list + // emtpty entries + << "Key2=;" << endl + << "Key3=;;" << endl + << "Key4=;;;" << endl + << "Key5=\\;" << endl + << "Key6=1;2\\;3;;" << endl; + out.flush(); + file.close(); + 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!"; + QCOMPARE(grp.readXdgListEntry("Key1", invalidList), QStringList()); + QCOMPARE(grp.readXdgListEntry("Key2", invalidList), QStringList() << QString()); + QCOMPARE(grp.readXdgListEntry("Key3", invalidList), QStringList() << QString() << QString()); + QCOMPARE(grp.readXdgListEntry("Key4", invalidList), QStringList()<< QString() << QString() << QString()); + QCOMPARE(grp.readXdgListEntry("Key5", invalidList), QStringList() << ";"); + QCOMPARE(grp.readXdgListEntry("Key6", invalidList), QStringList() << "1" << "2;3" << QString()); +} + #include <QThreadPool> #include <qtconcurrentrun.h> |