yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie HermaszewskaCorrect include dir for libslang (#5539)7b570feed

master
2.0 KiB60 linesraw
1// unit-test-path.cpp
2
3#include "../../source/core/slang-io.h"
4#include "unit-test/slang-unit-test.h"
5
6using namespace Slang;
7
8SLANG_UNIT_TEST(path)
9{
10#if SLANG_WINDOWS_FAMILY
11    // Disable for now on non windows has some problems on *some* Linux based CI.
12    {
13        String path;
14        SlangResult res = Path::getCanonical("source/slang", path);
15        SLANG_CHECK(SLANG_SUCCEEDED(res));
16
17        String parentPath;
18        res = Path::getCanonical("source", parentPath);
19        SLANG_CHECK(SLANG_SUCCEEDED(res));
20
21        String parentPath2 = Path::getParentDirectory(path);
22        SLANG_CHECK(parentPath == parentPath2);
23    }
24#endif
25    // Test the paths
26    {
27        SLANG_CHECK(Path::simplify(".") == ".");
28        SLANG_CHECK(Path::simplify("..") == "..");
29        SLANG_CHECK(Path::simplify("blah/..") == ".");
30
31        SLANG_CHECK(Path::simplify("blah/.././a") == "a");
32
33        SLANG_CHECK(Path::simplify("a:/what/.././../is/./../this/.") == "a:/../this");
34
35        SLANG_CHECK(Path::simplify("a:/what/.././../is/./../this/./") == "a:/../this");
36
37        SLANG_CHECK(Path::simplify("a:\\what\\..\\.\\..\\is\\.\\..\\this\\.\\") == "a:/../this");
38
39        SLANG_CHECK(
40            Path::simplify("tests/preprocessor/.\\pragma-once-a.h") ==
41            "tests/preprocessor/pragma-once-a.h");
42
43
44        SLANG_CHECK(Path::hasRelativeElement("."));
45        SLANG_CHECK(Path::hasRelativeElement(".."));
46        SLANG_CHECK(Path::hasRelativeElement("blah/.."));
47
48        SLANG_CHECK(Path::hasRelativeElement("blah/.././a"));
49        SLANG_CHECK(Path::hasRelativeElement("a") == false);
50        SLANG_CHECK(Path::hasRelativeElement("blah/a") == false);
51        SLANG_CHECK(Path::hasRelativeElement("a:\\blah/a") == false);
52
53
54        SLANG_CHECK(Path::hasRelativeElement("a:/what/.././../is/./../this/."));
55
56        SLANG_CHECK(Path::hasRelativeElement("a:/what/.././../is/./../this/./"));
57
58        SLANG_CHECK(Path::hasRelativeElement("a:\\what\\..\\.\\..\\is\\.\\..\\this\\.\\"));
59    }
60}