forked from autodesk-forks/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFile.cpp
68 lines (58 loc) · 1.99 KB
/
File.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
// All rights reserved. See LICENSE.txt for license.
//
#include <MaterialXTest/Catch/catch.hpp>
#include <MaterialXFormat/File.h>
namespace mx = MaterialX;
TEST_CASE("Syntactic operations", "[file]")
{
using InputPair = std::pair<std::string, mx::FilePath::Format>;
std::vector<InputPair> inputPairs =
{
{"D:\\Assets\\Materials\\Robot.mtlx", mx::FilePath::FormatWindows},
{"\\\\Show\\Assets\\Materials\\Robot.mtlx", mx::FilePath::FormatWindows},
{"Materials\\Robot.mtlx", mx::FilePath::FormatWindows},
{"/Assets/Materials/Robot.mtlx", mx::FilePath::FormatPosix},
{"Assets/Materials/Robot.mtlx", mx::FilePath::FormatPosix},
{"Materials/Robot.mtlx", mx::FilePath::FormatPosix}
};
for (const InputPair& pair : inputPairs)
{
mx::FilePath path;
path.assign(pair.first, pair.second);
REQUIRE(path.asString(pair.second) == pair.first);
}
}
TEST_CASE("File system operations", "[file]")
{
mx::StringVec filenames =
{
"libraries/stdlib/stdlib_defs.mtlx",
"resources/Materials/Examples/Syntax/MaterialBasic.mtlx",
"resources/Materials/Examples/Syntax/PaintMaterials.mtlx",
};
for (const std::string& filename : filenames)
{
mx::FilePath path(filename);
REQUIRE(path.exists());
REQUIRE(mx::FileSearchPath().find(path).exists());
}
}
TEST_CASE("File search path operations", "[file]")
{
std::string searchPath = "libraries/stdlib" +
mx::PATH_LIST_SEPARATOR +
"resources/Materials/Examples/Syntax";
mx::StringVec filenames =
{
"stdlib_defs.mtlx",
"MaterialBasic.mtlx",
"PaintMaterials.mtlx",
};
for (const std::string& filename : filenames)
{
mx::FilePath path(filename);
REQUIRE(mx::FileSearchPath(searchPath, mx::PATH_LIST_SEPARATOR).find(path).exists());
}
}