From 743b116f24ae47145f6bd3018e1de0c000076e2b Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Fri, 13 Dec 2019 14:21:27 +0100 Subject: [PATCH] Added tests for d60a851fc00ec3ff2844bfb0294c51ad07e3fdb6 --- tests/EventEnvelopesT.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/EventEnvelopesT.cpp b/tests/EventEnvelopesT.cpp index 9cfe9b37..4213f04a 100644 --- a/tests/EventEnvelopesT.cpp +++ b/tests/EventEnvelopesT.cpp @@ -191,6 +191,22 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps") REQUIRE(output == expected); } +TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and an unquantized out of block step") +{ + sfz::LinearEnvelope envelope; + envelope.registerEvent(2, 1.0); + envelope.registerEvent(6, 3.0); + envelope.registerEvent(10, 4.2); + std::array output; + std::array expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 }; + std::array expected2 { 4.0, 4.0, 4.0,4.0, 4.0, 4.0, 4.0, 4.0 }; + envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); + REQUIRE(output == expected); + envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); + REQUIRE(output == expected2); +} + + TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps") { sfz::LinearEnvelope envelope; @@ -307,6 +323,21 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps") REQUIRE(output == expected); } +TEST_CASE("[MultiplicativeEnvelope] Get quantized with an unquantized out of range step") +{ + sfz::MultiplicativeEnvelope envelope; + envelope.registerEvent(2, 2.0); + envelope.registerEvent(6, 4.0); + envelope.registerEvent(10, 8.2); + std::array output; + std::array expected { 1.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 4.0 }; + std::array expected2 { 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0 }; + envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); + REQUIRE(output == expected); + envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); + REQUIRE(output == expected2); +} + TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps") { sfz::MultiplicativeEnvelope envelope;