diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-04-14 01:23:54 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-05-01 00:02:15 +0200 |
commit | 771dd6f9abe29c1d24c5ea8f0e7ca949bc24f84d (patch) | |
tree | 52962ddf547b3227f1b637dd1da2b3d0b5a5a766 /tests/tst_FileSystem.cpp | |
parent | e8ba5dafc63de65ed8a469353b808e391633f0fc (diff) | |
download | MultiMC-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 'tests/tst_FileSystem.cpp')
-rw-r--r-- | tests/tst_FileSystem.cpp | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/tests/tst_FileSystem.cpp b/tests/tst_FileSystem.cpp deleted file mode 100644 index ae1f93bb..00000000 --- a/tests/tst_FileSystem.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include <QTest> -#include <QTemporaryDir> -#include "TestUtil.h" - -#include "FileSystem.h" - -class FileSystemTest : public QObject -{ - Q_OBJECT - - const QString bothSlash = "/foo/"; - const QString trailingSlash = "foo/"; - const QString leadingSlash = "/foo"; - -private -slots: - void test_pathCombine() - { - QCOMPARE(QString("/foo/foo"), FS::PathCombine(bothSlash, bothSlash)); - QCOMPARE(QString("foo/foo"), FS::PathCombine(trailingSlash, trailingSlash)); - QCOMPARE(QString("/foo/foo"), FS::PathCombine(leadingSlash, leadingSlash)); - - QCOMPARE(QString("/foo/foo/foo"), FS::PathCombine(bothSlash, bothSlash, bothSlash)); - QCOMPARE(QString("foo/foo/foo"), FS::PathCombine(trailingSlash, trailingSlash, trailingSlash)); - QCOMPARE(QString("/foo/foo/foo"), FS::PathCombine(leadingSlash, leadingSlash, leadingSlash)); - } - - void test_PathCombine1_data() - { - QTest::addColumn<QString>("result"); - QTest::addColumn<QString>("path1"); - QTest::addColumn<QString>("path2"); - - QTest::newRow("qt 1") << "/abc/def/ghi/jkl" << "/abc/def" << "ghi/jkl"; - QTest::newRow("qt 2") << "/abc/def/ghi/jkl" << "/abc/def/" << "ghi/jkl"; -#if defined(Q_OS_WIN) - QTest::newRow("win native, from C:") << "C:/abc" << "C:" << "abc"; - QTest::newRow("win native 1") << "C:/abc/def/ghi/jkl" << "C:\\abc\\def" << "ghi\\jkl"; - QTest::newRow("win native 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(FS::PathCombine(path1, path2), result); - } - - void test_PathCombine2_data() - { - QTest::addColumn<QString>("result"); - QTest::addColumn<QString>("path1"); - QTest::addColumn<QString>("path2"); - QTest::addColumn<QString>("path3"); - - QTest::newRow("qt 1") << "/abc/def/ghi/jkl" << "/abc" << "def" << "ghi/jkl"; - QTest::newRow("qt 2") << "/abc/def/ghi/jkl" << "/abc/" << "def" << "ghi/jkl"; - QTest::newRow("qt 3") << "/abc/def/ghi/jkl" << "/abc" << "def/" << "ghi/jkl"; - QTest::newRow("qt 4") << "/abc/def/ghi/jkl" << "/abc/" << "def/" << "ghi/jkl"; -#if 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(FS::PathCombine(path1, path2, path3), result); - } - - void test_copy() - { - QString folder = QFINDTESTDATA("tests/data/test_folder"); - auto f = [&folder]() - { - QTemporaryDir tempDir; - tempDir.setAutoRemove(true); - qDebug() << "From:" << folder << "To:" << tempDir.path(); - - QDir target_dir(FS::PathCombine(tempDir.path(), "test_folder")); - qDebug() << tempDir.path(); - qDebug() << target_dir.path(); - FS::copy c(folder, target_dir.path()); - c(); - - for(auto entry: target_dir.entryList()) - { - qDebug() << entry; - } - QVERIFY(target_dir.entryList().contains("pack.mcmeta")); - QVERIFY(target_dir.entryList().contains("assets")); - }; - - // first try variant without trailing / - QVERIFY(!folder.endsWith('/')); - f(); - - // then variant with trailing / - folder.append('/'); - QVERIFY(folder.endsWith('/')); - f(); - } -}; - -QTEST_GUILESS_MAIN(FileSystemTest) - -#include "tst_FileSystem.moc" |