1
0
mirror of synced 2024-11-25 00:00:27 +01:00
ImHex/tests/helpers/source/file.cpp
2022-03-04 11:36:37 +01:00

42 lines
907 B
C++

#include <hex/test/tests.hpp>
#include <hex/helpers/file.hpp>
#include <hex/helpers/fs.hpp>
using namespace std::literals::string_literals;
TEST_SEQUENCE("FileAccess") {
const auto FilePath = hex::fs::current_path() / "file.txt";
const auto FileContent = "Hello World";
{
hex::File file(FilePath, hex::File::Mode::Create);
TEST_ASSERT(file.isValid());
file.write(FileContent);
}
{
hex::File file(FilePath, hex::File::Mode::Read);
TEST_ASSERT(file.isValid());
TEST_ASSERT(file.readString() == FileContent);
}
{
hex::File file(FilePath, hex::File::Mode::Write);
TEST_ASSERT(file.isValid());
file.remove();
TEST_ASSERT(!file.isValid());
}
{
hex::File file(FilePath, hex::File::Mode::Read);
if (file.isValid())
TEST_FAIL();
}
TEST_SUCCESS();
};