Skip to content

Commit

Permalink
Merge pull request #50 from Trinitou/add-host-tests
Browse files Browse the repository at this point in the history
Add tests for clap::helpers::Host
  • Loading branch information
abique authored Jan 19, 2024
2 parents 5206d9e + e61cad1 commit 62824ef
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Prerequisites
# Prerequisites
*.d

# Compiled Object files
Expand Down Expand Up @@ -31,9 +31,10 @@
*.out
*.app

#vs
# Visual Studio
.vs
out
.vscode

#clion
.idea
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ if (${CLAP_HELPERS_BUILD_TESTS})
endif()

add_executable(${PROJECT_NAME}-tests EXCLUDE_FROM_ALL
tests/create-an-actual-host.cc
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
Expand Down
36 changes: 36 additions & 0 deletions tests/create-an-actual-host.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Actually use host.hh / host.hxx to create a host. Assert that it is constructable
*/

#include "clap/helpers/host.hh"
#include "clap/helpers/host.hxx"

#include <type_traits>

#include <catch2/catch_all.hpp>

struct test_host : clap::helpers::Host<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Maximal>
{
test_host() : clap::helpers::Host<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Maximal>(
"Test Case Host",
"Free Audio",
"http://cleveraudio.org",
"1.0.0") {}

bool threadCheckIsMainThread() const noexcept override { return true; };
bool threadCheckIsAudioThread() const noexcept override { return false; };

void requestRestart() noexcept override {};
void requestProcess() noexcept override {};
void requestCallback() noexcept override {};
};

CATCH_TEST_CASE("Create an Actual Host")
{
CATCH_SECTION("Test Host is Creatable")
{
CATCH_REQUIRE(std::is_constructible<test_host>::value);
}
}
34 changes: 34 additions & 0 deletions tests/host.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <clap/helpers/plugin-proxy.hxx>
#include <clap/helpers/host.hh>
#include <clap/helpers/host.hxx>

#include <catch2/catch_all.hpp>

template class clap::helpers::Host<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Maximal>;
template class clap::helpers::Host<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Minimal>;
template class clap::helpers::Host<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::None>;
template class clap::helpers::Host<clap::helpers::MisbehaviourHandler::Ignore,
clap::helpers::CheckingLevel::Maximal>;

template class clap::helpers::PluginProxy<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Maximal>;
template class clap::helpers::PluginProxy<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Minimal>;
template class clap::helpers::PluginProxy<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::None>;
template class clap::helpers::PluginProxy<clap::helpers::MisbehaviourHandler::Ignore,
clap::helpers::CheckingLevel::Maximal>;

CATCH_TEST_CASE("Host - Link") {
clap::helpers::Host<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Maximal> *h0 = nullptr;
clap::helpers::Host<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Minimal> *h1 = nullptr;
clap::helpers::Host<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::None> *h2 = nullptr;
clap::helpers::Host<clap::helpers::MisbehaviourHandler::Ignore,
clap::helpers::CheckingLevel::Maximal> *h3 = nullptr;
}

0 comments on commit 62824ef

Please sign in to comment.