mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-29 11:14: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 {
|
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) {
|
for (int i = 0; i < count; ++i) {
|
||||||
path += "../";
|
path += "../";
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@ public:
|
|||||||
void setResOutDeir(const QString &value);
|
void setResOutDeir(const QString &value);
|
||||||
QString getPluginsOutDir(const QString& basePath = "/") const;
|
QString getPluginsOutDir(const QString& basePath = "/") const;
|
||||||
void setPluginsOutDir(const QString &value);
|
void setPluginsOutDir(const QString &value);
|
||||||
|
|
||||||
|
friend class deploytest;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DISTROSTRUCT_H
|
#endif // DISTROSTRUCT_H
|
||||||
|
@ -618,12 +618,33 @@ void deploytest::testDistroStruct() {
|
|||||||
DistroStruct distro;
|
DistroStruct distro;
|
||||||
|
|
||||||
auto cases = QList<QPair<QString,QString>>{
|
auto cases = QList<QPair<QString,QString>>{
|
||||||
{"", ""},
|
{"", "/"},
|
||||||
{"/", "/"},
|
{"/", "/"},
|
||||||
{"/res","/res/../"},
|
{"/res","/res/../"},
|
||||||
{"/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() {
|
void deploytest::mainTests() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user