summaryrefslogtreecommitdiff
path: root/src/tests/core
diff options
context:
space:
mode:
authorGravatar wwylele2016-10-16 22:19:13 +0800
committerGravatar wwylele2016-11-19 17:17:19 +0200
commit75ee2f8c67022b0731e438b34fa65216531eccd1 (patch)
treedf4293ddc6a1712e102a7f2d8d71205364b02d6b /src/tests/core
parentFileSys: make Archive interfaces return error code (diff)
downloadyuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.tar.gz
yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.tar.xz
yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.zip
FileSys: add PathParser
Diffstat (limited to 'src/tests/core')
-rw-r--r--src/tests/core/file_sys/path_parser.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tests/core/file_sys/path_parser.cpp b/src/tests/core/file_sys/path_parser.cpp
new file mode 100644
index 000000000..2b543e438
--- /dev/null
+++ b/src/tests/core/file_sys/path_parser.cpp
@@ -0,0 +1,38 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <catch.hpp>
6#include "common/file_util.h"
7#include "core/file_sys/path_parser.h"
8
9namespace FileSys {
10
11TEST_CASE("PathParser", "[core][file_sys]") {
12 REQUIRE(!PathParser(Path(std::vector<u8>{})).IsValid());
13 REQUIRE(!PathParser(Path("a")).IsValid());
14 REQUIRE(!PathParser(Path("/|")).IsValid());
15 REQUIRE(PathParser(Path("/a")).IsValid());
16 REQUIRE(!PathParser(Path("/a/b/../../c/../../d")).IsValid());
17 REQUIRE(PathParser(Path("/a/b/../c/../../d")).IsValid());
18 REQUIRE(PathParser(Path("/")).IsRootDirectory());
19 REQUIRE(!PathParser(Path("/a")).IsRootDirectory());
20 REQUIRE(PathParser(Path("/a/..")).IsRootDirectory());
21}
22
23TEST_CASE("PathParser - Host file system", "[core][file_sys]") {
24 std::string test_dir = "./test";
25 FileUtil::CreateDir(test_dir);
26 FileUtil::CreateDir(test_dir + "/z");
27 FileUtil::CreateEmptyFile(test_dir + "/a");
28
29 REQUIRE(PathParser(Path("/a")).GetHostStatus(test_dir) == PathParser::FileFound);
30 REQUIRE(PathParser(Path("/b")).GetHostStatus(test_dir) == PathParser::NotFound);
31 REQUIRE(PathParser(Path("/z")).GetHostStatus(test_dir) == PathParser::DirectoryFound);
32 REQUIRE(PathParser(Path("/a/c")).GetHostStatus(test_dir) == PathParser::FileInPath);
33 REQUIRE(PathParser(Path("/b/c")).GetHostStatus(test_dir) == PathParser::PathNotFound);
34
35 FileUtil::DeleteDirRecursively(test_dir);
36}
37
38} // namespace FileSys