Skip to content

Commit

Permalink
Add a basic test case for Patternal
Browse files Browse the repository at this point in the history
  • Loading branch information
aalex committed Dec 13, 2024
1 parent a28f61b commit 6712d52
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/avendish.tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ if(BUILD_TESTING)
avnd_add_executable_test(test_introspection_many tests/test_introspection_many.cpp)

avnd_add_catch_test(test_gain tests/objects/gain.cpp)
avnd_add_catch_test(test_patternal tests/objects/patternal.cpp)
endif()

27 changes: 27 additions & 0 deletions tests/objects/patternal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <catch2/catch_all.hpp>

#include <examples/Advanced/Patternal/Patternal.hpp>

// Tests for the Patternal object
TEST_CASE("Test Patternal patterns", "[advanced][patternal]")
{
SECTION("The input pattern is stored correctly") {
// Instanciate the object:
patternal::Processor patternalProcessor;

// Create the input pattern:
patternalProcessor.inputs.patterns.value = {
(patternal::Pattern) {42, {127, 127, 127, 127}}, // hi-hat
(patternal::Pattern) {38, {0, 127, 0, 127}}, // snare
(patternal::Pattern) {35, {127, 0, 127, 0}}, // bass drum
};

// Check that the input pattern is stored correctly:
REQUIRE(patternalProcessor.inputs.patterns.value[0].note == 42);
REQUIRE(patternalProcessor.inputs.patterns.value[0].pattern[0] == 127);
REQUIRE(patternalProcessor.inputs.patterns.value[1].note == 38);
REQUIRE(patternalProcessor.inputs.patterns.value[1].pattern[0] == 0);
REQUIRE(patternalProcessor.inputs.patterns.value[2].note == 35);
REQUIRE(patternalProcessor.inputs.patterns.value[2].pattern[0] == 127);
}
}

0 comments on commit 6712d52

Please sign in to comment.