2014-03-30 01:46:54 +05:30
|
|
|
#include <QTest>
|
|
|
|
#include "TestUtil.h"
|
|
|
|
|
2015-02-09 06:21:14 +05:30
|
|
|
#include "settings/INIFile.h"
|
2014-03-30 01:46:54 +05:30
|
|
|
|
|
|
|
class IniFileTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private
|
|
|
|
slots:
|
|
|
|
void initTestCase()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
void cleanupTestCase()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-26 11:59:43 +05:30
|
|
|
void test_Escape_data()
|
2014-03-30 01:46:54 +05:30
|
|
|
{
|
|
|
|
QTest::addColumn<QString>("through");
|
|
|
|
|
|
|
|
QTest::newRow("unix path") << "/abc/def/ghi/jkl";
|
|
|
|
QTest::newRow("windows path") << "C:\\Program files\\terrible\\name\\of something\\";
|
|
|
|
QTest::newRow("Plain text") << "Lorem ipsum dolor sit amet.";
|
|
|
|
QTest::newRow("Escape sequences") << "Lorem\n\t\n\\n\\tAAZ\nipsum dolor\n\nsit amet.";
|
|
|
|
QTest::newRow("Escape sequences 2") << "\"\n\n\"";
|
|
|
|
}
|
2015-05-26 11:59:43 +05:30
|
|
|
void test_Escape()
|
2014-03-30 01:46:54 +05:30
|
|
|
{
|
|
|
|
QFETCH(QString, through);
|
|
|
|
|
|
|
|
QString there = INIFile::escape(through);
|
|
|
|
QString back = INIFile::unescape(there);
|
2015-01-31 23:51:47 +05:30
|
|
|
|
2014-03-30 01:46:54 +05:30
|
|
|
QCOMPARE(back, through);
|
|
|
|
}
|
2015-05-26 11:59:43 +05:30
|
|
|
|
|
|
|
void test_SaveLoad()
|
|
|
|
{
|
|
|
|
QString a = "a";
|
|
|
|
QString b = "a\nb\t\n\\\\\\C:\\Program files\\terrible\\name\\of something\\";
|
|
|
|
QString filename = "test_SaveLoad.ini";
|
|
|
|
|
|
|
|
// save
|
|
|
|
INIFile f;
|
|
|
|
f.set("a", a);
|
|
|
|
f.set("b", b);
|
|
|
|
f.saveFile(filename);
|
|
|
|
|
|
|
|
// load
|
|
|
|
INIFile f2;
|
|
|
|
f2.loadFile(filename);
|
|
|
|
QCOMPARE(a, f2.get("a","NOT SET").toString());
|
|
|
|
QCOMPARE(b, f2.get("b","NOT SET").toString());
|
|
|
|
}
|
2014-03-30 01:46:54 +05:30
|
|
|
};
|
|
|
|
|
2015-01-31 23:51:47 +05:30
|
|
|
QTEST_GUILESS_MAIN(IniFileTest)
|
2014-03-30 01:46:54 +05:30
|
|
|
|
|
|
|
#include "tst_inifile.moc"
|