summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2026-06-05 16:52:16 +0200
committerFelix Morgner <felix.morgner@gmail.com>2026-06-05 16:52:16 +0200
commita03409696680e34a860138387651f8257097af41 (patch)
tree2ee0f62ec000bc53252516c586e372a909e903ac
parent79549aab5b9ca8f0cad4f00bc8ad68b7091ab65f (diff)
downloadcabinet-a03409696680e34a860138387651f8257097af41.tar.xz
cabinet-a03409696680e34a860138387651f8257097af41.zip
magic: add test skeleton
-rw-r--r--CMakeLists.txt32
-rw-r--r--cabinet/magic.tests.cpp10
2 files changed, 42 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f2970ac..2954fc6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
+include("FetchContent")
+include("CTest")
+
+
find_package("PkgConfig")
pkg_check_modules("magic" REQUIRED
@@ -43,3 +47,31 @@ target_sources("cabinet" PRIVATE
target_link_libraries("cabinet" PRIVATE
"cabinet::core"
)
+
+if(BUILD_TESTING)
+ FetchContent_Declare("Catch2"
+ URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.15.0.tar.gz"
+ URL_HASH "SHA256=9650c55e497759cc39b977e45524bc8acb15256061c112080916ab6cb0b1ea66"
+ EXCLUDE_FROM_ALL
+ FIND_PACKAGE_ARGS "3.15.0"
+ )
+
+ FetchContent_MakeAvailable("Catch2")
+
+ include("Catch")
+
+ add_compile_definitions("CATCH_CONFIG_NO_COUNTER")
+ add_executable("tests")
+ add_executable("cabinet::tests" ALIAS "tests")
+
+ target_sources("tests" PRIVATE
+ "cabinet/magic.tests.cpp"
+ )
+
+ target_link_libraries("tests" PRIVATE
+ "cabinet::core"
+ "Catch2::Catch2WithMain"
+ )
+
+ catch_discover_tests("cabinet::tests")
+endif()
diff --git a/cabinet/magic.tests.cpp b/cabinet/magic.tests.cpp
new file mode 100644
index 0000000..43102ff
--- /dev/null
+++ b/cabinet/magic.tests.cpp
@@ -0,0 +1,10 @@
+#include <cabinet/magic.hpp>
+
+#include <catch2/catch_test_macros.hpp>
+
+TEST_CASE("Constructing a magic instance", "[magic]")
+{
+ auto instance = cab::magic::open(cab::magic::flags::none);
+
+ REQUIRE(instance.has_value());
+}