summaryrefslogtreecommitdiffstats
path: root/tests/tst_pathutils.cpp
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-12-02 11:09:56 +0100
committerJan Dalheimer <jan@dalheimer.de>2013-12-02 11:09:56 +0100
commit0a6399b52cc72980b4847510cc183b54c75d1821 (patch)
treecc3087d7fce7fbbe39836f49d5eed1da86cea048 /tests/tst_pathutils.cpp
parent613699b3626aea750093ab7eaaeccaa28c0e87c6 (diff)
downloadMultiMC-0a6399b52cc72980b4847510cc183b54c75d1821.tar
MultiMC-0a6399b52cc72980b4847510cc183b54c75d1821.tar.gz
MultiMC-0a6399b52cc72980b4847510cc183b54c75d1821.tar.lz
MultiMC-0a6399b52cc72980b4847510cc183b54c75d1821.tar.xz
MultiMC-0a6399b52cc72980b4847510cc183b54c75d1821.zip
Unit testing
Diffstat (limited to 'tests/tst_pathutils.cpp')
-rw-r--r--tests/tst_pathutils.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/tst_pathutils.cpp b/tests/tst_pathutils.cpp
new file mode 100644
index 00000000..1e4a83bf
--- /dev/null
+++ b/tests/tst_pathutils.cpp
@@ -0,0 +1,76 @@
+#include <QTest>
+#include "TestUtil.h"
+
+#include "depends/util/include/pathutils.h"
+
+class PathUtilsTest : public QObject
+{
+ Q_OBJECT
+private
+slots:
+ void initTestCase()
+ {
+
+ }
+ void cleanupTestCase()
+ {
+
+ }
+
+ void test_PathCombine1_data()
+ {
+ QTest::addColumn<QString>("result");
+ QTest::addColumn<QString>("path1");
+ QTest::addColumn<QString>("path2");
+
+#if defined(Q_OS_UNIX)
+ QTest::newRow("unix 1") << "/abc/def/ghi/jkl" << "/abc/def" << "ghi/jkl";
+ QTest::newRow("unix 2") << "/abc/def/ghi/jkl" << "/abc/def/" << "ghi/jkl";
+#elif defined(Q_OS_WIN)
+ QTest::newRow("win, from C:") << "C:\\abc" << "C:" << "abc\\def";
+ QTest::newRow("win 1") << "C:\\abc\\def\\ghi\\jkl" << "C:\\abc\\def" << "ghi\\jkl";
+ QTest::newRow("win 2") << "C:\\abc\\def\\ghi\\jkl" << "C:\\abc\\def\\" << "ghi\\jkl";
+#endif
+ }
+ void test_PathCombine1()
+ {
+ QFETCH(QString, result);
+ QFETCH(QString, path1);
+ QFETCH(QString, path2);
+
+ QCOMPARE(PathCombine(path1, path2), result);
+ }
+
+ void test_PathCombine2_data()
+ {
+ QTest::addColumn<QString>("result");
+ QTest::addColumn<QString>("path1");
+ QTest::addColumn<QString>("path2");
+ QTest::addColumn<QString>("path3");
+
+#if defined(Q_OS_UNIX)
+ QTest::newRow("unix 1") << "/abc/def/ghi/jkl" << "/abc" << "def" << "ghi/jkl";
+ QTest::newRow("unix 2") << "/abc/def/ghi/jkl" << "/abc/" << "def" << "ghi/jkl";
+ QTest::newRow("unix 3") << "/abc/def/ghi/jkl" << "/abc" << "def/" << "ghi/jkl";
+ QTest::newRow("unix 4") << "/abc/def/ghi/jkl" << "/abc/" << "def/" << "ghi/jkl";
+#elif defined(Q_OS_WIN)
+ QTest::newRow("win 1") << "C:\\abc\\def\\ghi\\jkl" << "C:\\abc" << "def" << "ghi\\jkl";
+ QTest::newRow("win 2") << "C:\\abc\\def\\ghi\\jkl" << "C:\\abc\\" << "def" << "ghi\\jkl";
+ QTest::newRow("win 3") << "C:\\abc\\def\\ghi\\jkl" << "C:\\abc" << "def\\" << "ghi\\jkl";
+ QTest::newRow("win 4") << "C:\\abc\\def\\ghi\\jkl" << "C:\\abc\\" << "def" << "ghi\\jkl";
+#endif
+ }
+ void test_PathCombine2()
+ {
+ QFETCH(QString, result);
+ QFETCH(QString, path1);
+ QFETCH(QString, path2);
+ QFETCH(QString, path3);
+
+ QCOMPARE(PathCombine(path1, path2, path3), result);
+ }
+};
+
+QTEST_GUILESS_MAIN_MULTIMC(PathUtilsTest)
+
+#include "tst_pathutils.moc"