mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
tests: Added UTF-8 file operation tests
This commit is contained in:
@@ -9,6 +9,8 @@ TEST_SEQUENCE("FileAccess") {
|
||||
const auto FilePath = std::fs::current_path() / "file.txt";
|
||||
const auto FileContent = "Hello World";
|
||||
|
||||
std::fs::create_directories(FilePath.parent_path());
|
||||
|
||||
{
|
||||
hex::fs::File file(FilePath, hex::fs::File::Mode::Create);
|
||||
TEST_ASSERT(file.isValid());
|
||||
@@ -38,5 +40,43 @@ TEST_SEQUENCE("FileAccess") {
|
||||
TEST_FAIL();
|
||||
}
|
||||
|
||||
TEST_SUCCESS();
|
||||
};
|
||||
|
||||
TEST_SEQUENCE("UTF-8 Path") {
|
||||
const auto FilePath = std::fs::current_path() / u8"读写汉字" / u8"привет.txt";
|
||||
const auto FileContent = u8"שלום עולם";
|
||||
|
||||
std::fs::create_directories(FilePath.parent_path());
|
||||
|
||||
{
|
||||
hex::fs::File file(FilePath, hex::fs::File::Mode::Create);
|
||||
TEST_ASSERT(file.isValid());
|
||||
|
||||
file.write(FileContent);
|
||||
}
|
||||
|
||||
{
|
||||
hex::fs::File file(FilePath, hex::fs::File::Mode::Read);
|
||||
TEST_ASSERT(file.isValid());
|
||||
|
||||
TEST_ASSERT(file.readU8String() == FileContent);
|
||||
}
|
||||
|
||||
{
|
||||
hex::fs::File file(FilePath, hex::fs::File::Mode::Write);
|
||||
TEST_ASSERT(file.isValid());
|
||||
|
||||
|
||||
file.remove();
|
||||
TEST_ASSERT(!file.isValid());
|
||||
}
|
||||
|
||||
{
|
||||
hex::fs::File file(FilePath, hex::fs::File::Mode::Read);
|
||||
if (file.isValid())
|
||||
TEST_FAIL();
|
||||
}
|
||||
|
||||
TEST_SUCCESS();
|
||||
};
|
||||
Reference in New Issue
Block a user