2013-12-02 15:39:56 +05:30
|
|
|
#include <QTest>
|
|
|
|
#include "TestUtil.h"
|
|
|
|
|
2015-02-09 06:21:14 +05:30
|
|
|
#include "pathutils.h"
|
2013-12-02 15:39:56 +05:30
|
|
|
|
|
|
|
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");
|
|
|
|
|
2013-12-17 06:39:58 +05:30
|
|
|
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";
|
2013-12-02 15:39:56 +05:30
|
|
|
#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");
|
|
|
|
|
2013-12-17 06:39:58 +05:30
|
|
|
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";
|
2013-12-02 15:39:56 +05:30
|
|
|
#endif
|
|
|
|
}
|
|
|
|
void test_PathCombine2()
|
|
|
|
{
|
|
|
|
QFETCH(QString, result);
|
|
|
|
QFETCH(QString, path1);
|
|
|
|
QFETCH(QString, path2);
|
|
|
|
QFETCH(QString, path3);
|
|
|
|
|
|
|
|
QCOMPARE(PathCombine(path1, path2, path3), result);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-01-31 23:51:47 +05:30
|
|
|
QTEST_GUILESS_MAIN(PathUtilsTest)
|
2013-12-02 15:39:56 +05:30
|
|
|
|
|
|
|
#include "tst_pathutils.moc"
|