Skip to content

Commit

Permalink
Merge pull request #1364 from strukturag/catch2-v3
Browse files Browse the repository at this point in the history
Catch2 v3
  • Loading branch information
farindk authored Nov 4, 2024
2 parents 0ae5ad9 + 67a132d commit a5ea7ac
Show file tree
Hide file tree
Showing 32 changed files with 96 additions and 18,032 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ if(ENABLE_COVERAGE)
endif()

option(BUILD_TESTING "" ON)
set(CMAKE_CTEST_ARGUMENTS "--output-on-failure")
include(CTest)
if(BUILD_TESTING)
# TODO: fix tests on windows.
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ before_build:
- mkdir build
- cd build
- cmake .. -A %arch% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DWITH_DAV1D=ON -DWITH_AOM_DECODER=ON -DWITH_AOM_ENCODER=ON -DWITH_JPEG_DECODER=ON -DWITH_JPEG_ENCODER=ON -DWITH_UNCOMPRESSED_CODEC=ON -DWITH_HEADER_COMPRESSION=ON -DWITH_FFMPEG_DECODER=ON
- dir

build:
project: build\libheif.sln
parallel: true
verbosity: normal

Expand Down
26 changes: 22 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Needed to find libheif/heif_version.h while compiling the library
include_directories(${libheif_BINARY_DIR} ${libheif_SOURCE_DIR}/libheif ${libheif_SOURCE_DIR}/libheif/api)

Include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.7.1
GIT_PROGRESS TRUE
)

FetchContent_MakeAvailable(Catch2)


# prepare C++ configuration file (test-config.cc)

set(TESTING_DATA_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data")
Expand All @@ -9,17 +22,19 @@ configure_file(test-config.cc.in ${CMAKE_BINARY_DIR}/generated/test-config.cc)

macro(add_libheif_test TEST_FILE)
set(TEST_NAME ${TEST_FILE})
add_executable(${TEST_NAME} main.cc catch.hpp ${CMAKE_BINARY_DIR}/generated/test-config.cc test_utils.cc ${TEST_FILE}.cc)
target_link_libraries(${TEST_NAME} PRIVATE heif)
add_executable(${TEST_NAME} ${CMAKE_BINARY_DIR}/generated/test-config.cc test_utils.cc ${TEST_FILE}.cc)
target_link_libraries(${TEST_NAME} PRIVATE heif Catch2::Catch2WithMain)
add_test(NAME ${TEST_NAME} COMMAND ./${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES SKIP_REGULAR_EXPRESSION "[1-9][0-9]* skipped")
endmacro()

macro(add_heifio_test TEST_FILE)
set(TEST_NAME ${TEST_FILE})
add_executable(${TEST_NAME} main.cc catch.hpp ${CMAKE_BINARY_DIR}/generated/test-config.cc test_utils.cc ${TEST_FILE}.cc)
target_link_libraries(${TEST_NAME} PRIVATE heif heifio)
add_executable(${TEST_NAME} main.cc ${CMAKE_BINARY_DIR}/generated/test-config.cc test_utils.cc ${TEST_FILE}.cc)
target_link_libraries(${TEST_NAME} PRIVATE heif heifio Catch2::Catch2WithMain)
target_include_directories(${TEST_NAME} PRIVATE ${libheif_SOURCE_DIR})
add_test(NAME ${TEST_NAME} COMMAND ./${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES SKIP_REGULAR_EXPRESSION "[1-9][0-9]* skipped")
endmacro()

# --- tests that require access to internal symbols
Expand Down Expand Up @@ -96,3 +111,6 @@ if (ENABLE_PLUGIN_LOADING)
get_directory_property(ALL_TESTS TESTS)
set_tests_properties(${ALL_TESTS} PROPERTIES ENVIRONMENT "LIBHEIF_PLUGIN_PATH=${CMAKE_BINARY_DIR}/libheif/plugins")
endif ()

set_source_files_properties(catch_amalgamated.cc PROPERTIES COMPILE_FLAGS -Wno-conversion)

2 changes: 1 addition & 1 deletion tests/avc_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SOFTWARE.
*/

#include "catch.hpp"
#include "catch2/catch_test_macros.hpp"
#include "codecs/avc_boxes.h"
#include "error.h"
#include <cstdint>
Expand Down
2 changes: 1 addition & 1 deletion tests/bitstream_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SOFTWARE.
*/

#include "catch.hpp"
#include "catch2/catch_test_macros.hpp"
#include "error.h"
#include <cstdint>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion tests/box_equals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SOFTWARE.
*/

#include "catch.hpp"
#include "catch2/catch_test_macros.hpp"
#include "box.h"

TEST_CASE("box equals") {
Expand Down
Loading

0 comments on commit a5ea7ac

Please sign in to comment.