1
0
mirror of synced 2024-11-12 10:10:53 +01:00

tests: Fixed unit test compiling

This commit is contained in:
WerWolv 2021-09-21 02:48:41 +02:00
parent 8631cb0c2a
commit 26a0352851
5 changed files with 66 additions and 11 deletions

View File

@ -0,0 +1,25 @@
#pragma once
#include <hex.hpp>
#include <imgui.h>
#include <hex/views/view.hpp>
#include <array>
#include <string>
namespace hex {
namespace prv { class Provider; }
class ViewTools : public View {
public:
ViewTools();
~ViewTools() override;
void drawContent() override;
void drawMenu() override;
};
}

View File

@ -30,7 +30,7 @@ namespace hex {
~File();
bool isValid() { return this->m_file != nullptr; }
bool isValid() const { return this->m_file != nullptr; }
void seek(u64 offset);
@ -42,7 +42,7 @@ namespace hex {
void write(const std::vector<u8> &bytes);
void write(const std::string &string);
size_t getSize();
size_t getSize() const;
void setSize(u64 size);
auto getHandle() { return this->m_file; }

View File

@ -72,7 +72,7 @@ namespace hex {
fwrite(string.data(), string.size(), 1, this->m_file);
}
size_t File::getSize() {
size_t File::getSize() const {
if (!isValid()) return 0;
auto startPos = ftello64(this->m_file);

View File

@ -0,0 +1,26 @@
#include "views/view_tools.hpp"
#include <hex/providers/provider.hpp>
namespace hex {
ViewTools::ViewTools() : View("hex.view.tools.name") { }
ViewTools::~ViewTools() { }
void ViewTools::drawContent() {
if (ImGui::Begin(View::toWindowName("hex.view.tools.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
for (const auto& [name, function] : ContentRegistry::Tools::getEntries()) {
if (ImGui::CollapsingHeader(LangEntry(name))) {
function();
}
}
}
ImGui::End();
}
void ViewTools::drawMenu() {
}
}

View File

@ -17,13 +17,17 @@ namespace hex::test {
}
~TestProvider() override = default;
bool isAvailable() override { return true; }
bool isReadable() override { return true; }
bool isWritable() override { return false; }
bool isResizable() override { return false; }
bool isSavable() override { return false; }
[[nodiscard]] bool isAvailable() const override { return true; }
[[nodiscard]] bool isReadable() const override { return true; }
[[nodiscard]] bool isWritable() const override { return false; }
[[nodiscard]] bool isResizable() const override { return false; }
[[nodiscard]] bool isSavable() const override { return false; }
std::vector<std::pair<std::string, std::string>> getDataInformation() override {
[[nodiscard]] std::string getName() const override {
return "";
}
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override {
return { };
}
@ -37,8 +41,8 @@ namespace hex::test {
this->m_testFile.write(static_cast<const u8*>(buffer), size);
}
size_t getActualSize() override {
return m_testFile.getSize();
size_t getActualSize() const override {
return this->m_testFile.getSize();
}
private: