refactor: Move ini to use QSettings && drop get/setList functions
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <QVariant>
|
||||
#include <settings/INIFile.h>
|
||||
|
||||
#include <QVariantUtils.h>
|
||||
|
||||
class IniFileTest : public QObject
|
||||
{
|
||||
@ -30,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()
|
||||
{
|
||||
@ -61,32 +53,30 @@ slots:
|
||||
|
||||
void test_SaveLoadLists()
|
||||
{
|
||||
QString slist_strings = "[\"a\",\"b\",\"c\"]";
|
||||
QString slist_strings = "(\"a\",\"b\",\"c\")";
|
||||
QStringList list_strings = {"a", "b", "c"};
|
||||
|
||||
QString slist_numbers = "[1,2,3,10]";
|
||||
QString slist_numbers = "(1,2,3,10)";
|
||||
QList<int> list_numbers = {1, 2, 3, 10};
|
||||
|
||||
QString filename = "test_SaveLoadLists.ini";
|
||||
|
||||
INIFile f;
|
||||
f.setList("list_strings", list_strings);
|
||||
f.setList("list_numbers", list_numbers);
|
||||
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.getList<QString>("list_strings", QStringList());
|
||||
QStringList out_list_strings = f2.get("list_strings", QStringList()).toStringList();
|
||||
qDebug() << "OutStringList" << out_list_strings;
|
||||
|
||||
QList<int> out_list_numbers = f2.getList<int>("list_numbers", QList<int>());
|
||||
QList<int> out_list_numbers = QVariantUtils::toList<int>(f2.get("list_numbers", QVariantUtils::fromList(QList<int>())));
|
||||
qDebug() << "OutNumbersList" << out_list_numbers;
|
||||
|
||||
QCOMPARE(f2.get("list_strings","NOT SET").toString(), slist_strings);
|
||||
QCOMPARE(out_list_strings, list_strings);
|
||||
QCOMPARE(f2.get("list_numbers","NOT SET").toString(), slist_numbers);
|
||||
QCOMPARE(out_list_numbers, list_numbers);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user