Skip to content

Commit

Permalink
Get the unit test to work
Browse files Browse the repository at this point in the history
  • Loading branch information
abique committed Dec 14, 2023
1 parent 7ff7498 commit a7f24f0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ project(CLAP_PLUGINS C CXX)

set(CMAKE_AUTOMOC ON)

include_directories(catch2/single_include)

if(${CMAKE_CXX_COMPILER_ID} MATCHES "AppleClang|Clang|GNU")
add_compile_options(-fvisibility=hidden -fvisibility-inlines-hidden
-Werror=return-type -Werror=unused-result -Wno-unused-parameter
Expand Down
41 changes: 23 additions & 18 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else()
endif()

add_library(
clap-plugins MODULE
clap-plugins-core STATIC

audio-buffer.cc
audio-buffer.hh
Expand Down Expand Up @@ -93,27 +93,32 @@ add_library(
value-types/enumerated-value-type.hh
value-types/enumerated-value-type.cc
)
target_compile_definitions(clap-plugins PRIVATE _USE_MATH_DEFINES)
target_compile_definitions(clap-plugins-core PRIVATE _USE_MATH_DEFINES)
set_target_properties(clap-plugins-core PROPERTIES CXX_STANDARD 20)
set_target_properties(clap-plugins-core PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

if(NOT CLAP_PLUGINS_HEADLESS)
if(CLAP_PLUGINS_REMOTE_GUI)
target_compile_definitions(clap-plugins PUBLIC CLAP_REMOTE_GUI)
target_link_libraries(clap-plugins PUBLIC clap-plugin-remote-gui)
add_dependencies(clap-plugins clap-gui)
target_compile_definitions(clap-plugins-core PUBLIC CLAP_REMOTE_GUI)
target_link_libraries(clap-plugins-core PUBLIC clap-plugin-remote-gui)
add_dependencies(clap-plugins-core clap-gui)
else()
target_compile_definitions(clap-plugins PUBLIC CLAP_LOCAL_GUI)
target_link_libraries(clap-plugins PUBLIC clap-plugin-local-gui)
target_compile_definitions(clap-plugins-core PUBLIC CLAP_LOCAL_GUI)
target_link_libraries(clap-plugins-core PUBLIC clap-plugin-local-gui)
endif()

target_link_libraries(clap-plugins PUBLIC clap-io)
target_link_libraries(clap-plugins-core PUBLIC clap-io)
endif()

set_target_properties(clap-plugins PROPERTIES CXX_STANDARD 20)
set_target_properties(clap-plugins-core PROPERTIES CXX_STANDARD 20)

if (NOT CLAP_PLUGINS_HEADLESS)
target_link_libraries(clap-plugins PUBLIC clap-plugin-gui-common)
target_link_libraries(clap-plugins-core PUBLIC clap-plugin-gui-common)
endif()
target_link_libraries(clap-plugins PUBLIC clap-helpers)
target_link_libraries(clap-plugins-core PUBLIC clap-helpers)

add_library(clap-plugins MODULE)
target_link_libraries(clap-plugins PUBLIC clap-plugins-core)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(clap-plugins PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/linux-clap-plugins.version)
Expand Down Expand Up @@ -149,13 +154,13 @@ if (${CLAP_BUILD_TESTS})
find_package(Catch2 3 QUIET)

if (Catch2_FOUND)
add_executable(clap-plugins-tests EXCLUDE_FROM_ALL
tests/value-type-tests.cc)
set_target_properties(clap-plugins-tests PROPERTIES CXX_STANDARD 11)
target_link_libraries(clap-plugins-tests clap-helpers clap Catch2::Catch2WithMain)
target_compile_definitions(clap-plugins-tests PUBLIC -DCATCH_CONFIG_PREFIX_ALL)
add_test(NAME test-clap-plugins COMMAND clap-plugins-tests)
add_dependencies(clap-tests clap-plugins-tests)
add_executable(clap-plugins-tests EXCLUDE_FROM_ALL
tests/value-type-tests.cc)
set_target_properties(clap-plugins-tests PROPERTIES CXX_STANDARD 20)
target_link_libraries(clap-plugins-tests clap-plugins-core clap Catch2::Catch2WithMain)
target_compile_definitions(clap-plugins-tests PUBLIC -DCATCH_CONFIG_PREFIX_ALL)
add_test(NAME test-clap-plugins COMMAND clap-plugins-tests)
add_dependencies(clap-tests clap-plugins-tests)
else()
message(STATUS "Catch2 >= 3 isn't found -> disable clap-plugins unit tests")
endif()
Expand Down
5 changes: 3 additions & 2 deletions plugins/tests/value-type-tests.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "../value-types/decibel-value-type.hh"

#include <catch2/catch_all.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>

namespace {

CATCH_TEST_CASE("value-type - decibel") {
clap::DecibelValueType vt;

CATCH_CHECK(vt.toParam(vt.toEngine(3)) == 3);
CATCH_CHECK_THAT(vt.toParam(vt.toEngine(3)), Catch::Matchers::WithinAbs(3, 1e-6));
}

} // namespace
} // namespace

0 comments on commit a7f24f0

Please sign in to comment.