18#include <catch2/catch.hpp>
29 SECTION(
"returns null if")
31 SECTION(
"there is no loop info")
35 REQUIRE(!actual.has_value());
37 SECTION(
"tempo is set but the distributor isn't whitelisted")
44 {
"foo",
"Distributor Z",
"Distributor Zen 2" });
45 REQUIRE(!actual.has_value());
49 SECTION(
"returns valid info if")
51 SECTION(
"OneShot is set")
56 REQUIRE(actual.has_value());
57 REQUIRE(actual->isOneShot);
59 SECTION(
"Beats is set")
63 constexpr auto numBeats = 20;
65 auto& file = tagger.ReopenInReadMode();
67 REQUIRE(actual.has_value());
69 sf_command(&file, SFC_GET_CURRENT_SF_INFO, &info,
sizeof(SF_INFO));
70 const auto durationAfterClose = 1. * info.frames / info.samplerate;
71 const auto expectedBpm = numBeats * 60 / durationAfterClose;
72 REQUIRE(actual->bpm == Approx(expectedBpm));
73 REQUIRE(actual->isOneShot ==
false);
75 SECTION(
"Tempo is set and the distributor is whitelisted")
82 REQUIRE(actual.has_value());
83 REQUIRE(actual->bpm == 120.);
84 REQUIRE(actual->isOneShot ==
false);
When adding tags, the allocated memory must be preserved until the file is closed....
SNDFILE & ReopenInReadMode()
void AddAcidizerTags(const Test::AcidizerTags &acidTags)
void AddDistributorInfo(const std::string &distributor)
TEST_CASE("GetAcidizerTags")
std::optional< LibFileFormats::AcidizerTags > GetAcidizerTags(SNDFILE &file, const std::vector< std::string > &trustedDistributors)
Get the Acidizer tags from a file if from a trusted distributor.