mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-28 18:54:33 +00:00
added tests for out dirs
This commit is contained in:
parent
9bedeece9e
commit
0f7e015c95
@ -58,10 +58,24 @@ void DistroStruct::setPluginsOutDir(const QString &value) {
|
||||
}
|
||||
|
||||
QString DistroStruct::getRelativePath(QString path) const {
|
||||
if (!path.size() || !(path[0] == "/" || path[0] == "\\"))
|
||||
return "";
|
||||
|
||||
int count = path.count(QRegExp("[\\/]")) - 1;
|
||||
path.replace('\\', '/');
|
||||
|
||||
int index = -1;
|
||||
do {
|
||||
path.replace("//", "/");
|
||||
} while ((index = path.indexOf("//")) >= 0);
|
||||
|
||||
if (path.left(1) != '/') {
|
||||
path.insert(0, '/');
|
||||
}
|
||||
|
||||
if (path.right(1) != '/') {
|
||||
path.insert(path.size(), '/');
|
||||
}
|
||||
|
||||
int count = path.count('/') - 1;
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
path += "../";
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ public:
|
||||
void setResOutDeir(const QString &value);
|
||||
QString getPluginsOutDir(const QString& basePath = "/") const;
|
||||
void setPluginsOutDir(const QString &value);
|
||||
|
||||
friend class deploytest;
|
||||
};
|
||||
|
||||
#endif // DISTROSTRUCT_H
|
||||
|
@ -618,12 +618,33 @@ void deploytest::testDistroStruct() {
|
||||
DistroStruct distro;
|
||||
|
||||
auto cases = QList<QPair<QString,QString>>{
|
||||
{"", ""},
|
||||
{"", "/"},
|
||||
{"/", "/"},
|
||||
{"/res","/res/../"},
|
||||
{"/res/","/res/../"},
|
||||
{"\\","\\"},
|
||||
{"/res/type","/res/type/../../"},
|
||||
{"/res/type/","/res/type/../../"},
|
||||
{"res/type","/res/type/../../"},
|
||||
{"res/type/","/res/type/../../"},
|
||||
{"res//type/","/res/type/../../"},
|
||||
{"res////type/","/res/type/../../"},
|
||||
{"//res///type/////","/res/type/../../"},
|
||||
{"\\", "/"},
|
||||
{"\\res","/res/../"},
|
||||
{"\\res\\","/res/../"},
|
||||
{"\\res\\type","/res/type/../../"},
|
||||
{"\\res\\type\\","/res/type/../../"},
|
||||
{"res\\type","/res/type/../../"},
|
||||
{"res\\type\\","/res/type/../../"},
|
||||
{"res\\\\type\\","/res/type/../../"},
|
||||
{"res\\\\\\\\type\\","/res/type/../../"},
|
||||
{"\\\\res\\\\\\type\\\\\\\\\\","/res/type/../../"},
|
||||
};
|
||||
|
||||
for (auto &i: cases) {
|
||||
QVERIFY(distro.getRelativePath(i.first) == i.second);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void deploytest::mainTests() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user