1
0
mirror of synced 2024-12-01 02:37:18 +01:00

sys: Fixed unit test building

This commit is contained in:
WerWolv 2022-03-04 14:34:37 +01:00
parent 6a517feda3
commit 96e9400761
4 changed files with 10 additions and 10 deletions

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#if defined(OS_MACOS) #if defined(OS_MACOS)
#include <hex/helpers/paths.hpp> #include <hex/helpers/fs.hpp>
namespace hex { namespace hex {
std::string getMacExecutableDirectoryPath(); std::string getMacExecutableDirectoryPath();

View File

@ -6,25 +6,25 @@
using namespace std::literals::string_literals; using namespace std::literals::string_literals;
TEST_SEQUENCE("FileAccess") { TEST_SEQUENCE("FileAccess") {
const auto FilePath = hex::fs::current_path() / "file.txt"; const auto FilePath = std::fs::current_path() / "file.txt";
const auto FileContent = "Hello World"; const auto FileContent = "Hello World";
{ {
hex::File file(FilePath, hex::File::Mode::Create); hex::fs::File file(FilePath, hex::fs::File::Mode::Create);
TEST_ASSERT(file.isValid()); TEST_ASSERT(file.isValid());
file.write(FileContent); file.write(FileContent);
} }
{ {
hex::File file(FilePath, hex::File::Mode::Read); hex::fs::File file(FilePath, hex::fs::File::Mode::Read);
TEST_ASSERT(file.isValid()); TEST_ASSERT(file.isValid());
TEST_ASSERT(file.readString() == FileContent); TEST_ASSERT(file.readString() == FileContent);
} }
{ {
hex::File file(FilePath, hex::File::Mode::Write); hex::fs::File file(FilePath, hex::fs::File::Mode::Write);
TEST_ASSERT(file.isValid()); TEST_ASSERT(file.isValid());
@ -33,7 +33,7 @@ TEST_SEQUENCE("FileAccess") {
} }
{ {
hex::File file(FilePath, hex::File::Mode::Read); hex::fs::File file(FilePath, hex::fs::File::Mode::Read);
if (file.isValid()) if (file.isValid())
TEST_FAIL(); TEST_FAIL();
} }

View File

@ -37,13 +37,13 @@ TEST_SEQUENCE("TipsAPI") {
TEST_SEQUENCE("ContentAPI") { TEST_SEQUENCE("ContentAPI") {
hex::Net net; hex::Net net;
const auto FilePath = hex::fs::current_path() / "elf.hexpat"; const auto FilePath = std::fs::current_path() / "elf.hexpat";
auto result = net.downloadFile("https://api.werwolv.net/content/imhex/patterns/elf.hexpat", FilePath).get(); auto result = net.downloadFile("https://api.werwolv.net/content/imhex/patterns/elf.hexpat", FilePath).get();
TEST_ASSERT(result.code == 200); TEST_ASSERT(result.code == 200);
hex::File file(FilePath, hex::File::Mode::Read); hex::fs::File file(FilePath, hex::fs::File::Mode::Read);
if (!file.isValid()) if (!file.isValid())
TEST_FAIL(); TEST_FAIL();

View File

@ -9,7 +9,7 @@ namespace hex::test {
class TestProvider : public prv::Provider { class TestProvider : public prv::Provider {
public: public:
TestProvider() : Provider(), m_testFile(File("test_data", File::Mode::Read)) { TestProvider() : Provider(), m_testFile(fs::File("test_data", fs::File::Mode::Read)) {
if (!this->m_testFile.isValid() || this->m_testFile.getSize() == 0) { if (!this->m_testFile.isValid() || this->m_testFile.getSize() == 0) {
hex::log::fatal("Failed to open test data!"); hex::log::fatal("Failed to open test data!");
throw std::runtime_error(""); throw std::runtime_error("");
@ -49,7 +49,7 @@ namespace hex::test {
void close() override { } void close() override { }
private: private:
File m_testFile; fs::File m_testFile;
}; };
} }