summaryrefslogtreecommitdiffstats
path: root/api/logic/settings/INIFile_test.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-04-14 01:23:54 +0200
committerPetr Mrázek <peterix@gmail.com>2016-05-01 00:02:15 +0200
commit771dd6f9abe29c1d24c5ea8f0e7ca949bc24f84d (patch)
tree52962ddf547b3227f1b637dd1da2b3d0b5a5a766 /api/logic/settings/INIFile_test.cpp
parente8ba5dafc63de65ed8a469353b808e391633f0fc (diff)
downloadMultiMC-771dd6f9abe29c1d24c5ea8f0e7ca949bc24f84d.tar
MultiMC-771dd6f9abe29c1d24c5ea8f0e7ca949bc24f84d.tar.gz
MultiMC-771dd6f9abe29c1d24c5ea8f0e7ca949bc24f84d.tar.lz
MultiMC-771dd6f9abe29c1d24c5ea8f0e7ca949bc24f84d.tar.xz
MultiMC-771dd6f9abe29c1d24c5ea8f0e7ca949bc24f84d.zip
NOISSUE reorganize unit tests to be placed next to the code they test. Nuke more dead tests.
Diffstat (limited to 'api/logic/settings/INIFile_test.cpp')
-rw-r--r--api/logic/settings/INIFile_test.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/api/logic/settings/INIFile_test.cpp b/api/logic/settings/INIFile_test.cpp
new file mode 100644
index 00000000..b3ae7375
--- /dev/null
+++ b/api/logic/settings/INIFile_test.cpp
@@ -0,0 +1,62 @@
+#include <QTest>
+#include "TestUtil.h"
+
+#include "settings/INIFile.h"
+
+class IniFileTest : public QObject
+{
+ Q_OBJECT
+private
+slots:
+ void initTestCase()
+ {
+
+ }
+ void cleanupTestCase()
+ {
+
+ }
+
+ void test_Escape_data()
+ {
+ 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\"";
+ }
+ void test_Escape()
+ {
+ QFETCH(QString, through);
+
+ QString there = INIFile::escape(through);
+ QString back = INIFile::unescape(there);
+
+ QCOMPARE(back, through);
+ }
+
+ 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());
+ }
+};
+
+QTEST_GUILESS_MAIN(IniFileTest)
+
+#include "INIFile_test.moc"