Skip to content

Commit

Permalink
begin unit testing the clap plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
abique committed Dec 14, 2023
1 parent e5d51b6 commit 7ff7498
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion catch2
Submodule catch2 updated 738 files
18 changes: 18 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,21 @@ if(NOT CLAP_PLUGINS_HEADLESS AND NOT CLAP_PLUGINS_EMBED_QML)
DESTINATION "lib/clap-plugins"
PATTERN CMakeLists.txt EXCLUDE)
endif()

# CLAP_BUILD_TESTS is inherited from clap
if (${CLAP_BUILD_TESTS})
enable_testing()
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)
else()
message(STATUS "Catch2 >= 3 isn't found -> disable clap-plugins unit tests")
endif()
endif()
13 changes: 13 additions & 0 deletions plugins/tests/value-type-tests.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "../value-types/decibel-value-type.hh"

#include <catch2/catch_all.hpp>

namespace {

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

CATCH_CHECK(vt.toParam(vt.toEngine(3)) == 3);
}

} // namespace

0 comments on commit 7ff7498

Please sign in to comment.