diff --git a/tests/SynthT.cpp b/tests/SynthT.cpp index e59df54f..112acb0d 100644 --- a/tests/SynthT.cpp +++ b/tests/SynthT.cpp @@ -6,6 +6,7 @@ #include "sfizz/Synth.h" #include "sfizz/SfzHelpers.h" +#include "sfizz/NumericId.h" #include "catch2/catch.hpp" using namespace Catch::literals; using namespace sfz::literals; @@ -462,3 +463,26 @@ TEST_CASE("[Synth] velcurve") REQUIRE( synth.getRegionView(1)->velocityCurve(96_norm) == Approx(0.5f).margin(1e-2) ); REQUIRE( synth.getRegionView(1)->velocityCurve(127_norm) == 0.0_a ); } + +TEST_CASE("[Synth] Region by identifier") +{ + sfz::Synth synth; + synth.loadSfzString("regionByIdentifier.sfz", R"( +sample=*sine +sample=*sine +sample=doesNotExist.wav +sample=*sine +sample=doesNotExist.wav +sample=*sine +)"); + + REQUIRE(synth.getNumRegions() == 4); + REQUIRE(synth.getRegionView(0) == synth.getRegionById(NumericId{0})); + REQUIRE(synth.getRegionView(1) == synth.getRegionById(NumericId{1})); + REQUIRE(nullptr == synth.getRegionById(NumericId{2})); + REQUIRE(synth.getRegionView(2) == synth.getRegionById(NumericId{3})); + REQUIRE(nullptr == synth.getRegionById(NumericId{4})); + REQUIRE(synth.getRegionView(3) == synth.getRegionById(NumericId{5})); + REQUIRE(nullptr == synth.getRegionById(NumericId{6})); + REQUIRE(nullptr == synth.getRegionById(NumericId{})); +}