aboutsummaryrefslogtreecommitdiff
path: root/tests/INIFile_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/INIFile_test.cpp')
-rw-r--r--tests/INIFile_test.cpp46
1 files changed, 35 insertions, 11 deletions
diff --git a/tests/INIFile_test.cpp b/tests/INIFile_test.cpp
index b64b031b..4be8133c 100644
--- a/tests/INIFile_test.cpp
+++ b/tests/INIFile_test.cpp
@@ -1,7 +1,11 @@
#include <QTest>
+#include <QList>
+#include <QVariant>
#include <settings/INIFile.h>
+#include <QVariantUtils.h>
+
class IniFileTest : public QObject
{
Q_OBJECT
@@ -27,15 +31,6 @@ slots:
QTest::newRow("Escape sequences 2") << "\"\n\n\"";
QTest::newRow("Hashtags") << "some data#something";
}
- void test_Escape()
- {
- QFETCH(QString, through);
-
- QString there = INIFile::escape(through);
- QString back = INIFile::unescape(there);
-
- QCOMPARE(back, through);
- }
void test_SaveLoad()
{
@@ -52,8 +47,37 @@ slots:
// load
INIFile f2;
f2.loadFile(filename);
- QCOMPARE(a, f2.get("a","NOT SET").toString());
- QCOMPARE(b, f2.get("b","NOT SET").toString());
+ QCOMPARE(f2.get("a","NOT SET").toString(), a);
+ QCOMPARE(f2.get("b","NOT SET").toString(), b);
+ }
+
+ void test_SaveLoadLists()
+ {
+ QString slist_strings = "(\"a\",\"b\",\"c\")";
+ QStringList list_strings = {"a", "b", "c"};
+
+ QString slist_numbers = "(1,2,3,10)";
+ QList<int> list_numbers = {1, 2, 3, 10};
+
+ QString filename = "test_SaveLoadLists.ini";
+
+ INIFile f;
+ f.set("list_strings", list_strings);
+ f.set("list_numbers", QVariantUtils::fromList(list_numbers));
+ f.saveFile(filename);
+
+ // load
+ INIFile f2;
+ f2.loadFile(filename);
+
+ QStringList out_list_strings = f2.get("list_strings", QStringList()).toStringList();
+ qDebug() << "OutStringList" << out_list_strings;
+
+ QList<int> out_list_numbers = QVariantUtils::toList<int>(f2.get("list_numbers", QVariantUtils::fromList(QList<int>())));
+ qDebug() << "OutNumbersList" << out_list_numbers;
+
+ QCOMPARE(out_list_strings, list_strings);
+ QCOMPARE(out_list_numbers, list_numbers);
}
};