diff options
author | wwylele <wwylele@gmail.com> | 2016-10-16 16:19:13 +0200 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2016-11-19 16:17:19 +0100 |
commit | 75ee2f8c67022b0731e438b34fa65216531eccd1 (patch) | |
tree | df4293ddc6a1712e102a7f2d8d71205364b02d6b /src/tests/core | |
parent | FileSys: make Archive interfaces return error code (diff) | |
download | yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.tar yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.tar.gz yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.tar.bz2 yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.tar.lz yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.tar.xz yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.tar.zst yuzu-75ee2f8c67022b0731e438b34fa65216531eccd1.zip |
Diffstat (limited to 'src/tests/core')
-rw-r--r-- | src/tests/core/file_sys/path_parser.cpp | 38 |
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 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <catch.hpp> +#include "common/file_util.h" +#include "core/file_sys/path_parser.h" + +namespace FileSys { + +TEST_CASE("PathParser", "[core][file_sys]") { + REQUIRE(!PathParser(Path(std::vector<u8>{})).IsValid()); + REQUIRE(!PathParser(Path("a")).IsValid()); + REQUIRE(!PathParser(Path("/|")).IsValid()); + REQUIRE(PathParser(Path("/a")).IsValid()); + REQUIRE(!PathParser(Path("/a/b/../../c/../../d")).IsValid()); + REQUIRE(PathParser(Path("/a/b/../c/../../d")).IsValid()); + REQUIRE(PathParser(Path("/")).IsRootDirectory()); + REQUIRE(!PathParser(Path("/a")).IsRootDirectory()); + REQUIRE(PathParser(Path("/a/..")).IsRootDirectory()); +} + +TEST_CASE("PathParser - Host file system", "[core][file_sys]") { + std::string test_dir = "./test"; + FileUtil::CreateDir(test_dir); + FileUtil::CreateDir(test_dir + "/z"); + FileUtil::CreateEmptyFile(test_dir + "/a"); + + REQUIRE(PathParser(Path("/a")).GetHostStatus(test_dir) == PathParser::FileFound); + REQUIRE(PathParser(Path("/b")).GetHostStatus(test_dir) == PathParser::NotFound); + REQUIRE(PathParser(Path("/z")).GetHostStatus(test_dir) == PathParser::DirectoryFound); + REQUIRE(PathParser(Path("/a/c")).GetHostStatus(test_dir) == PathParser::FileInPath); + REQUIRE(PathParser(Path("/b/c")).GetHostStatus(test_dir) == PathParser::PathNotFound); + + FileUtil::DeleteDirRecursively(test_dir); +} + +} // namespace FileSys |