summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2024-07-12 18:16:06 +0200
committerFelix Morgner <felix.morgner@gmail.com>2024-07-12 18:16:20 +0200
commit2b3fc8f53de9d0d547e4e5b7900c7257bdd1be1a (patch)
tree8f6d4a8fb680727cecd791c68ba187e333222f18
parent087e99c2ba0ddd7928208f3dc244c567b6d0b0dd (diff)
downloadturns-2b3fc8f53de9d0d547e4e5b7900c7257bdd1be1a.tar.xz
turns-2b3fc8f53de9d0d547e4e5b7900c7257bdd1be1a.zip
domain/tests: initialize glib
-rw-r--r--domain/CMakeLists.txt3
-rw-r--r--domain/tests/participant.cpp2
-rw-r--r--test_support/CMakeLists.txt20
-rw-r--r--test_support/src/glib_main.cpp10
4 files changed, 33 insertions, 2 deletions
diff --git a/domain/CMakeLists.txt b/domain/CMakeLists.txt
index 5e4201c..2de847a 100644
--- a/domain/CMakeLists.txt
+++ b/domain/CMakeLists.txt
@@ -38,9 +38,10 @@ add_executable("domain-tests"
)
target_link_libraries("domain-tests"
- "Catch2::Catch2WithMain"
+ "Catch2::Catch2"
"turns::domain"
+ "turns::glib-test-main"
)
catch_discover_tests("domain-tests") \ No newline at end of file
diff --git a/domain/tests/participant.cpp b/domain/tests/participant.cpp
index 7220209..b7429aa 100644
--- a/domain/tests/participant.cpp
+++ b/domain/tests/participant.cpp
@@ -1,13 +1,13 @@
#include "turns/domain/participant.hpp"
#include <catch2/catch_test_macros.hpp>
+#include <glibmm/init.h>
namespace turns::domain::tests
{
TEST_CASE("A participant")
{
-
auto constexpr constructed_name = "Vana Thistletop";
auto constexpr constructed_order = 17;
auto instance = participant::create(constructed_name, constructed_order);
diff --git a/test_support/CMakeLists.txt b/test_support/CMakeLists.txt
index bb2ae4f..ce77a90 100644
--- a/test_support/CMakeLists.txt
+++ b/test_support/CMakeLists.txt
@@ -1,5 +1,25 @@
get_target_property(TRANSLATIONS_BINARY_DIR "lang" BINARY_DIR)
+# Glib test support
+
+add_library("test_support-glib" OBJECT
+ "src/glib_main.cpp"
+)
+
+add_library("turns::glib-test-main" ALIAS "test_support-glib")
+
+target_compile_features("test_support-glib" PRIVATE
+ "cxx_std_23"
+)
+
+target_compile_definitions("test_support-glib" PUBLIC
+ "TESTLOCALEDIR=\"${TRANSLATIONS_BINARY_DIR}\""
+)
+
+target_link_libraries("test_support-glib" PUBLIC
+ "PkgConfig::glibmm"
+)
+
# GTK test support
add_library("test_support-gtk" OBJECT
diff --git a/test_support/src/glib_main.cpp b/test_support/src/glib_main.cpp
new file mode 100644
index 0000000..d224bad
--- /dev/null
+++ b/test_support/src/glib_main.cpp
@@ -0,0 +1,10 @@
+#include <catch2/catch_session.hpp>
+
+#include <glibmm/init.h>
+
+auto main(int argc, char * argv[]) -> int
+{
+ Glib::init();
+
+ return Catch::Session().run(argc, argv);
+} \ No newline at end of file