aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-17 15:32:57 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-17 15:32:57 +0100
commitb4335bd670cb7f3f622e6ab701123cfbabd15d37 (patch)
treed0c6193e48a7555811bdb22228105374599747f2
parent2772bb158f10fc051d35006041303f2e5418e817 (diff)
fix tests + nitpick #77
-rw-r--r--src/crepe/facade/FontFacade.cpp32
-rw-r--r--src/test/InputTest.cpp7
2 files changed, 19 insertions, 20 deletions
diff --git a/src/crepe/facade/FontFacade.cpp b/src/crepe/facade/FontFacade.cpp
index 5db06d2..d47095f 100644
--- a/src/crepe/facade/FontFacade.cpp
+++ b/src/crepe/facade/FontFacade.cpp
@@ -10,44 +10,38 @@ using namespace std;
using namespace crepe;
FontFacade::FontFacade() {
- if (!FcInit()) {
+ if (!FcInit())
throw runtime_error("Failed to initialize Fontconfig.");
- }
}
FontFacade::~FontFacade() { FcFini(); }
Asset FontFacade::get_font_asset(const string & font_family) {
-
FcPattern * raw_pattern
= FcNameParse(reinterpret_cast<const FcChar8 *>(font_family.c_str()));
- if (!raw_pattern) {
- throw runtime_error("Failed to create font pattern.");
- }
+ if (raw_pattern == NULL) throw runtime_error("Failed to create font pattern.");
- std::unique_ptr<FcPattern, std::function<void(FcPattern *)>> pattern(
- raw_pattern, [](FcPattern * p) { FcPatternDestroy(p); });
+ unique_ptr<FcPattern, function<void(FcPattern *)>> pattern{
+ raw_pattern, [](FcPattern * p) { FcPatternDestroy(p); }
+ };
FcConfig * config = FcConfigGetCurrent();
- if (!config) {
- throw runtime_error("Failed to get current Fontconfig configuration.");
- }
+ if (config == NULL) throw runtime_error("Failed to get current Fontconfig configuration.");
FcResult result;
FcPattern * raw_matched_pattern = FcFontMatch(config, pattern.get(), &result);
- if (!raw_matched_pattern) {
- throw runtime_error("No matching font found.");
- }
+ if (raw_matched_pattern == NULL) throw runtime_error("No matching font found.");
- std::unique_ptr<FcPattern, std::function<void(FcPattern *)>> matched_pattern(
- raw_matched_pattern, [](FcPattern * p) { FcPatternDestroy(p); });
+ unique_ptr<FcPattern, function<void(FcPattern *)>> matched_pattern = {
+ raw_matched_pattern, [](FcPattern * p) { FcPatternDestroy(p); }
+ };
FcChar8 * file_path = nullptr;
- if (FcPatternGetString(matched_pattern.get(), FC_FILE, 0, &file_path) != FcResultMatch
- || !file_path) {
+ FcResult res = FcPatternGetString(matched_pattern.get(), FC_FILE, 0, &file_path);
+ if (res != FcResultMatch || file_path == NULL)
throw runtime_error("Failed to get font file path.");
- }
string font_file_path = reinterpret_cast<const char *>(file_path);
return Asset(font_file_path);
}
+
diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp
index d893276..2d844d4 100644
--- a/src/test/InputTest.cpp
+++ b/src/test/InputTest.cpp
@@ -1,7 +1,11 @@
-#include "system/RenderSystem.h"
#include <gtest/gtest.h>
+
+#include <crepe/manager/ResourceManager.h>
+#include <crepe/system/RenderSystem.h>
+
#define protected public
#define private public
+
#include "api/KeyCodes.h"
#include "manager/ComponentManager.h"
#include "manager/EventManager.h"
@@ -29,6 +33,7 @@ public:
SDLContext sdl_context{mediator};
InputSystem input_system{mediator};
+ ResourceManager resman{mediator};
RenderSystem render{mediator};
EventManager event_manager{mediator};
//GameObject camera;