1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include "FileUtils.h"
#include "Log.h"
#include <cstdlib>
#include <vector>
std::vector<std::pair<std::string, std::string>> pathList = {
{ "C:/Foo/Bar/test.exe", "C:/Foo/Bar/test.exe" },
{ "C:/Foo/Bar/./test.exe", "C:/Foo/Bar/test.exe" },
{ "C:/Foo/../Bar/./test.exe", "C:/Bar/test.exe" },
{ "C:/../Foo/Bar/./test.exe", "C:/Foo/Bar/test.exe" },
{ "C:/../../Foo/Bar/./test.exe", "C:/Foo/Bar/test.exe" },
{ "C://Foo///Bar/////test.exe", "C:/Foo/Bar/test.exe" },
{ "C:/Foo//Bar/////test.exe", "C:/Foo/Bar/test.exe" },
{ "C:/Foo/././Bar/././././test.exe", "C:/Foo/Bar/test.exe" },
{ "C:/./Foo/././Bar/./test.exe", "C:/Foo/Bar/test.exe" },
{ "/Foo/Bar/./test.exe", "/Foo/Bar/test.exe" },
{ "/Foo/./Bar/./test.exe", "/Foo/Bar/test.exe" },
{ "/Foo/../Bar/./test.exe", "/Bar/test.exe" },
{ "/../Foo/Bar/./test.exe", "/Foo/Bar/test.exe" },
{ "/../../Foo/Bar/./test.exe", "/Foo/Bar/test.exe" },
{ "/Foo/../../Bar/./test.exe", "/Bar/test.exe" },
{ "/Foo/Bar/Baz/../../test.exe", "/Foo/test.exe" },
{ "/Foo/Bar/Baz/../../../test.exe", "/test.exe" },
{ "//Foo///Bar/////test.exe", "/Foo/Bar/test.exe" },
{ "/Foo//Bar/////test.exe", "/Foo/Bar/test.exe" },
{ "/./Foo/././Bar/././././test.exe", "/Foo/Bar/test.exe" },
{ "/Foo/././Bar/././././test.exe", "/Foo/Bar/test.exe" }
};
int main(int argc, const char *argv[]) {
for (auto& [test, expected] : pathList) {
auto normalized = vst::normalizePath(test);
if (normalized != expected) {
LOG_ERROR("path " << normalized << " (normalized from "
<< test << ") does not match " << expected);
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
|