From 8a874fc49c1813e5f31582269fe9d2652a68d51d Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Thu, 21 Mar 2024 11:21:43 -0400 Subject: [PATCH] tests: Prevent tests from crashing when manager is invalid (#9) --- tests/test.c | 4 ++++ tests/test.cpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test.c b/tests/test.c index 749fbd3..d5fa80a 100644 --- a/tests/test.c +++ b/tests/test.c @@ -9,6 +9,10 @@ int main(int argc, char** argv) { printf("mgr null\n"); return 1; } + if (!hyprcursor_manager_valid(mgr)) { + printf("mgr is invalid\n"); + return 1; + } struct hyprcursor_cursor_style_info info = {.size = 48}; if (!hyprcursor_load_theme_style(mgr, info)) { diff --git a/tests/test.cpp b/tests/test.cpp index 155f120..95377d7 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -4,8 +4,12 @@ int main(int argc, char** argv) { Hyprcursor::CHyprcursorManager mgr(nullptr); - Hyprcursor::SCursorStyleInfo style{.size = 48}; + if (!mgr.valid()) { + std::cout << "mgr is invalid\n"; + return 1; + } + Hyprcursor::SCursorStyleInfo style{.size = 48}; // preload size 48 for testing if (!mgr.loadThemeStyle(style)) { std::cout << "failed loading style\n";