From a47eb1c9ecd059d8580683b3b5b580146ad873ed Mon Sep 17 00:00:00 2001 From: trinitou Date: Fri, 19 Jan 2024 00:45:01 +0100 Subject: [PATCH] Add build test for clap::helpers::Host --- .gitignore | 5 +++-- CMakeLists.txt | 1 + include/clap/helpers/host.hxx | 4 ++-- include/clap/helpers/macros.hh | 6 ++++++ tests/host.cc | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 tests/host.cc diff --git a/.gitignore b/.gitignore index acf32bf..4ee5684 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Prerequisites +# Prerequisites *.d # Compiled Object files @@ -31,9 +31,10 @@ *.out *.app -#vs +# Visual Studio .vs out +.vscode #clion .idea diff --git a/CMakeLists.txt b/CMakeLists.txt index a0aee8d..3ff468e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ if (${CLAP_HELPERS_BUILD_TESTS}) add_executable(${PROJECT_NAME}-tests EXCLUDE_FROM_ALL tests/create-an-actual-plugin.cc tests/hex-encoder.cc + tests/host.cc tests/plugin.cc tests/param-queue-tests.cc tests/event-list-tests.cc diff --git a/include/clap/helpers/host.hxx b/include/clap/helpers/host.hxx index 280aa5e..54a5b76 100644 --- a/include/clap/helpers/host.hxx +++ b/include/clap/helpers/host.hxx @@ -428,7 +428,7 @@ namespace clap { namespace helpers { /////////////// template Host &Host::from(const clap_host *host) noexcept { - if constexpr (l >= CheckingLevel::Minimal) { + CLAP_IF_CONSTEXPR (l >= CheckingLevel::Minimal) { if (!host) CLAP_HELPERS_UNLIKELY { std::cerr << "Passed an null host pointer" << std::endl; std::terminate(); @@ -436,7 +436,7 @@ namespace clap { namespace helpers { } auto self = static_cast(host->host_data); - if constexpr (l >= CheckingLevel::Minimal) { + CLAP_IF_CONSTEXPR (l >= CheckingLevel::Minimal) { if (!self) CLAP_HELPERS_UNLIKELY { std::cerr << "Passed an invalid host pointer because the host_data is null" << std::endl; diff --git a/include/clap/helpers/macros.hh b/include/clap/helpers/macros.hh index 6c3ead4..d835368 100644 --- a/include/clap/helpers/macros.hh +++ b/include/clap/helpers/macros.hh @@ -1,5 +1,11 @@ #pragma once +#if defined(__cplusplus) && __cplusplus >= 201703L +# define CLAP_IF_CONSTEXPR if constexpr +#else +# define CLAP_IF_CONSTEXPR if +#endif + #if defined(__cplusplus) && __cplusplus >= 202002L # define CLAP_HELPERS_UNLIKELY [[unlikely]] #else diff --git a/tests/host.cc b/tests/host.cc new file mode 100644 index 0000000..33f80d7 --- /dev/null +++ b/tests/host.cc @@ -0,0 +1,34 @@ +#include +#include +#include + +#include + +template class clap::helpers::Host; +template class clap::helpers::Host; +template class clap::helpers::Host; +template class clap::helpers::Host; + +template class clap::helpers::PluginProxy; +template class clap::helpers::PluginProxy; +template class clap::helpers::PluginProxy; +template class clap::helpers::PluginProxy; + +CATCH_TEST_CASE("Host - Link") { + clap::helpers::Host *h0 = nullptr; + clap::helpers::Host *h1 = nullptr; + clap::helpers::Host *h2 = nullptr; + clap::helpers::Host *h3 = nullptr; +}