mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-20 22:05:06 +00:00
sys_fs: Add unit tests
This commit is contained in:
parent
5be10bbce8
commit
389fa7d05b
4 changed files with 54 additions and 0 deletions
|
|
@ -187,6 +187,7 @@ if(BUILD_RPCS3_TESTS)
|
|||
tests/test_tuple.cpp
|
||||
tests/test_simple_array.cpp
|
||||
tests/test_address_range.cpp
|
||||
tests/test_sys_fs.cpp
|
||||
tests/test_rsx_cfg.cpp
|
||||
tests/test_rsx_fp_asm.cpp
|
||||
tests/test_dmux_pamf.cpp
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "Emu/Cell/ErrorCodes.h"
|
||||
#include "Utilities/File.h"
|
||||
#include "Utilities/StrUtil.h"
|
||||
#include "Utilities/mutex.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
<ClCompile Include="test_rsx_fp_asm.cpp" />
|
||||
<ClCompile Include="test_simple_array.cpp" />
|
||||
<ClCompile Include="test_address_range.cpp" />
|
||||
<ClCompile Include="test_sys_fs.cpp" />
|
||||
<ClCompile Include="test_tuple.cpp" />
|
||||
<ClCompile Include="test_pair.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
51
rpcs3/tests/test_sys_fs.cpp
Normal file
51
rpcs3/tests/test_sys_fs.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "Emu/Cell/lv2/sys_fs.h"
|
||||
#undef private
|
||||
|
||||
using namespace utils;
|
||||
|
||||
namespace utils
|
||||
{
|
||||
TEST(cellFs, PathRoot)
|
||||
{
|
||||
std::string path = "/.";
|
||||
auto [root, trail] = lv2_fs_object::get_path_root_and_trail(path);
|
||||
EXPECT_TRUE(root.empty());
|
||||
EXPECT_TRUE(trail.empty());
|
||||
|
||||
path = "/./././dev_bdvd/./";
|
||||
std::tie(root, trail) = lv2_fs_object::get_path_root_and_trail(path);
|
||||
EXPECT_EQ(root, "dev_bdvd"sv);
|
||||
EXPECT_TRUE(trail.empty());
|
||||
|
||||
path = "/../";
|
||||
std::tie(root, trail) = lv2_fs_object::get_path_root_and_trail(path);
|
||||
EXPECT_TRUE(root.empty());
|
||||
EXPECT_EQ(trail, "ENOENT"sv);
|
||||
}
|
||||
|
||||
TEST(cellFs, PathSimplify)
|
||||
{
|
||||
std::string path = "/dev_hdd0/";
|
||||
auto [root, trail] = lv2_fs_object::get_path_root_and_trail(path);
|
||||
EXPECT_EQ(root, "dev_hdd0"sv);
|
||||
EXPECT_TRUE(trail.empty());
|
||||
|
||||
path = "/dev_hdd0/game";
|
||||
std::tie(root, trail) = lv2_fs_object::get_path_root_and_trail(path);
|
||||
EXPECT_EQ(root, "dev_hdd0"sv);
|
||||
EXPECT_EQ(trail, "game"sv);
|
||||
|
||||
path = "/dev_hdd0/game/NP1234567";
|
||||
std::tie(root, trail) = lv2_fs_object::get_path_root_and_trail(path);
|
||||
EXPECT_EQ(root, "dev_hdd0"sv);
|
||||
EXPECT_EQ(trail, "game/NP1234567"sv);
|
||||
|
||||
path = "/dev_hdd0/game/NP1234567/../../NP1234568/.";
|
||||
std::tie(root, trail) = lv2_fs_object::get_path_root_and_trail(path);
|
||||
EXPECT_EQ(root, "dev_hdd0"sv);
|
||||
EXPECT_EQ(trail, "NP1234568"sv);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue