Skip to content

Commit df9bba2

Browse files
committed
replace catch.hpp with catch2
Signed-off-by: Rosen Penev <rosenp@gmail.com>
1 parent cfaf0c5 commit df9bba2

File tree

7 files changed

+42
-10451
lines changed

7 files changed

+42
-10451
lines changed

flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@
218218
else
219219
libpng
220220
)
221+
(
222+
catch2
223+
)
221224

222225
]
223226
++ pkgsForHost.lib.optionals isWindows [

test/CMakeLists.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
find_package(Catch2 CONFIG REQUIRED)
2+
3+
include(CTest)
4+
include(Catch)
5+
16
add_executable(ffmpegthumbnailertest
27
testrunner.cpp
38
histogramtest.cpp
@@ -23,12 +28,20 @@ target_compile_definitions(ffmpegthumbnailertest PRIVATE TEST_DATADIR="${CMAKE_C
2328
target_compile_definitions(ffmpegthumbnailerctest PRIVATE TEST_DATADIR="${CMAKE_CURRENT_SOURCE_DIR}")
2429

2530
if (ENABLE_SHARED)
26-
target_link_libraries(ffmpegthumbnailertest libffmpegthumbnailer)
31+
if (TARGET Catch2::Catch2WithMain)
32+
target_link_libraries(ffmpegthumbnailertest libffmpegthumbnailer Catch2::Catch2WithMain)
33+
else ()
34+
target_link_libraries(ffmpegthumbnailertest libffmpegthumbnailer Catch2::Catch2)
35+
endif ()
2736
target_link_libraries(ffmpegthumbnailerctest libffmpegthumbnailer)
2837
else ()
29-
target_link_libraries(ffmpegthumbnailertest libffmpegthumbnailerstatic)
38+
if (TARGET Catch2::Catch2WithMain)
39+
target_link_libraries(ffmpegthumbnailertest libffmpegthumbnailerstatic Catch2::Catch2WithMain)
40+
else ()
41+
target_link_libraries(ffmpegthumbnailertest libffmpegthumbnailerstatic Catch2::Catch2)
42+
endif ()
3043
target_link_libraries(ffmpegthumbnailerctest libffmpegthumbnailerstatic)
3144
endif ()
3245

33-
add_test(NAME ffmpegthumbnailertest COMMAND ffmpegthumbnailertest)
46+
catch_discover_tests(ffmpegthumbnailertest)
3447
add_test(NAME ffmpegthumbnailerctest COMMAND ffmpegthumbnailerctest)

test/histogramtest.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
#include <vector>
44

55
#include "libffmpegthumbnailer/histogram.h"
6-
#include <catch.hpp>
6+
7+
#if __has_include(<catch2/catch_test_macros.hpp>)
8+
#include <catch2/catch_test_macros.hpp>
9+
#else
10+
#include <catch2/catch.hpp>
11+
#endif
712

813
namespace ffmpegthumbnailer {
914

0 commit comments

Comments
 (0)