Files
windows-user-space-emulator/src/windows-emulator-test/file_system_test.cpp
2025-03-18 08:49:13 +01:00

18 lines
562 B
C++

#include <gtest/gtest.h>
#include <file_system.hpp>
namespace test
{
TEST(FileSystemTest, PathTraversalIsNotPossible)
{
const auto current_dir = std::filesystem::current_path();
const file_system fs{current_dir};
EXPECT_EQ(current_dir / "a", fs.translate(windows_path('a', {u"..", u"..", u"..", u"..", u"a.txt"})));
EXPECT_EQ(current_dir / "a", fs.translate(windows_path('a', {u"b", u"..", u"..", u"b", u"..", u"a.txt"})));
EXPECT_EQ(current_dir / "a", fs.translate(windows_path('a', {u"..", u"b"})));
}
}