Skip to content

Commit

Permalink
[tests] Add more midi out unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Sep 29, 2024
1 parent daba896 commit 5b78e34
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
sudo apt update
sudo apt install cmake libboost-dev libasound-dev libjack-jackd2-dev clang libc++-dev
else
curl -L https://github.com/ossia/sdk/releases/download/sdk28/boost_1_82_0.tar.gz > boost.tar.gz
curl -L https://github.com/ossia/sdk/releases/download/sdk31/boost_1_86_0.tar.gz > boost.tar.gz
tar -xzf boost.tar.gz
rm boost.tar.gz
fi
Expand Down
2 changes: 1 addition & 1 deletion examples/echo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <iostream>
#include <thread>

int main(int argc, char**)
int main(int argc, char** argv)
{
libremidi::observer obs;
auto inputs = obs.get_input_ports();
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/midi_in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ TEST_CASE("poly aftertouch", "[midi_in]")
jack_status_t status;
auto jack_client = jack_client_open("libremidi-tester", opt, &status);
int ret = jack_activate(jack_client);
REQUIRE(ret == 0);
if (ret != 0)
return;

std::this_thread::sleep_for(std::chrono::milliseconds(100));
ret = jack_connect(jack_client, "libremidi-test-out:port", "libremidi-test:port");
Expand Down
47 changes: 47 additions & 0 deletions tests/unit/midi_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,53 @@

#include <set>

TEST_CASE("creation", "[midi_out]")
{
GIVEN("A default midi output")
{
libremidi::midi_out out;
THEN("created with the default MIDI 1 api for the platform")
{
REQUIRE(out.get_current_api() == libremidi::midi1::default_api());
}
}

GIVEN("A midi output with an explicitly unspecified API")
{
libremidi::midi_out out({}, libremidi::API::UNSPECIFIED);
THEN("created with the default api")
{
REQUIRE(out.get_current_api() == libremidi::midi1::default_api());
}
}

GIVEN("A midi output with an empty API")
{
libremidi::midi_out out({}, std::any{});
THEN("created with defaultapi")
{
REQUIRE(out.get_current_api() == libremidi::midi1::default_api());
}
}
GIVEN("A midi output with an explicit API")
{
libremidi::midi_out out({}, libremidi::API::JACK_MIDI);
THEN("created with that api")
{
REQUIRE(out.get_current_api() == libremidi::API::JACK_MIDI);
}
}

GIVEN("A midi output with a wrong API")
{
libremidi::midi_out out({}, float(1.23f));
THEN("created with dummy api")
{
REQUIRE(out.get_current_api() == libremidi::API::DUMMY);
}
}
}

TEST_CASE("sending messages with span", "[midi_out]")
{
libremidi::midi_out midi{{}, libremidi::dummy_configuration{}};
Expand Down

0 comments on commit 5b78e34

Please sign in to comment.