2020-01-25 10:04:31 +01:00
|
|
|
// SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
|
2020-01-25 13:13:07 +01:00
|
|
|
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
|
|
|
|
// license. You should have receive a LICENSE.md file along with the code.
|
|
|
|
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
2019-08-30 00:49:58 +02:00
|
|
|
|
2020-01-18 17:35:27 +01:00
|
|
|
#include "sfizz/Region.h"
|
2019-08-25 14:01:03 +02:00
|
|
|
#include "catch2/catch.hpp"
|
2019-07-29 02:13:03 +02:00
|
|
|
using namespace Catch::literals;
|
|
|
|
|
|
|
|
|
|
TEST_CASE("[Opcode] Construction")
|
|
|
|
|
{
|
|
|
|
|
SECTION("Normal construction")
|
|
|
|
|
{
|
2019-08-25 14:01:03 +02:00
|
|
|
sfz::Opcode opcode { "sample", "dummy" };
|
|
|
|
|
REQUIRE(opcode.opcode == "sample");
|
|
|
|
|
REQUIRE(opcode.value == "dummy");
|
|
|
|
|
REQUIRE(!opcode.parameter);
|
2019-07-29 02:13:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SECTION("Normal construction with underscore")
|
|
|
|
|
{
|
2019-08-25 14:01:03 +02:00
|
|
|
sfz::Opcode opcode { "sample_underscore", "dummy" };
|
|
|
|
|
REQUIRE(opcode.opcode == "sample_underscore");
|
|
|
|
|
REQUIRE(opcode.value == "dummy");
|
|
|
|
|
REQUIRE(!opcode.parameter);
|
2019-07-29 02:13:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SECTION("Parameterized opcode")
|
|
|
|
|
{
|
2019-08-25 14:01:03 +02:00
|
|
|
sfz::Opcode opcode { "sample123", "dummy" };
|
|
|
|
|
REQUIRE(opcode.opcode == "sample");
|
|
|
|
|
REQUIRE(opcode.value == "dummy");
|
|
|
|
|
REQUIRE(opcode.parameter);
|
|
|
|
|
REQUIRE(*opcode.parameter == 123);
|
2019-07-29 02:13:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SECTION("Parameterized opcode with underscore")
|
|
|
|
|
{
|
2019-08-25 14:01:03 +02:00
|
|
|
sfz::Opcode opcode { "sample_underscore123", "dummy" };
|
|
|
|
|
REQUIRE(opcode.opcode == "sample_underscore");
|
|
|
|
|
REQUIRE(opcode.value == "dummy");
|
|
|
|
|
REQUIRE(opcode.parameter);
|
|
|
|
|
REQUIRE(*opcode.parameter == 123);
|
2019-07-29 02:13:03 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE("[Opcode] Note values")
|
|
|
|
|
{
|
|
|
|
|
auto noteValue = sfz::readNoteValue("c-1");
|
2019-08-25 14:01:03 +02:00
|
|
|
REQUIRE(noteValue);
|
|
|
|
|
REQUIRE(*noteValue == 0);
|
2019-07-29 02:13:03 +02:00
|
|
|
noteValue = sfz::readNoteValue("C-1");
|
2019-08-25 14:01:03 +02:00
|
|
|
REQUIRE(noteValue);
|
|
|
|
|
REQUIRE(*noteValue == 0);
|
2019-07-29 02:13:03 +02:00
|
|
|
noteValue = sfz::readNoteValue("g9");
|
2019-08-25 14:01:03 +02:00
|
|
|
REQUIRE(noteValue);
|
|
|
|
|
REQUIRE(*noteValue == 127);
|
2019-07-29 02:13:03 +02:00
|
|
|
noteValue = sfz::readNoteValue("G9");
|
2019-08-25 14:01:03 +02:00
|
|
|
REQUIRE(noteValue);
|
|
|
|
|
REQUIRE(*noteValue == 127);
|
2019-07-29 02:13:03 +02:00
|
|
|
noteValue = sfz::readNoteValue("c#4");
|
2019-08-25 14:01:03 +02:00
|
|
|
REQUIRE(noteValue);
|
|
|
|
|
REQUIRE(*noteValue == 61);
|
2019-07-29 02:13:03 +02:00
|
|
|
noteValue = sfz::readNoteValue("C#4");
|
2019-08-25 14:01:03 +02:00
|
|
|
REQUIRE(noteValue);
|
|
|
|
|
REQUIRE(*noteValue == 61);
|
2019-07-29 02:13:03 +02:00
|
|
|
}
|