6#include "matchers/hart_matcher.hpp"
23template<
typename SampleType>
38 m_matcherFunctionForInputAndOutput (std::move (matcherFunction)),
51 m_matcherFunctionForOutputOnly (std::move (matcherFunction)),
58 if (m_matcherFunctionForOutputOnly !=
nullptr)
59 return m_matcherFunctionForOutputOnly (observedOutputAudio);
61 if (m_matcherFunctionForInputAndOutput !=
nullptr)
62 return m_matcherFunctionForInputAndOutput (inputAudio, observedOutputAudio);
72 details
.description =
"Matcher function (" + (m_label.empty() ?
"no label" : m_label) +
") has returned false";
76 void represent (std::ostream& stream)
const override
78 stream <<
"MatcherFunction (<function>, \"" << m_label <<
"\")";
82 void prepare (
double , size_t , size_t )
override {}
85 const std::function <
bool (
const AudioBuffer<SampleType>&,
const AudioBuffer<SampleType>&)> m_matcherFunctionForInputAndOutput =
nullptr;
86 const std::function <
bool (
const AudioBuffer<SampleType>&)> m_matcherFunctionForOutputOnly =
nullptr;
87 const std::string m_label;
Container for audio data.
Matcher defined by a user-provided function.
MatcherFunction(std::function< bool(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={})
Constructs a matcher from a function that inspects only the output.
void represent(std::ostream &stream) const override
Makes a text representation of this Matcher for test failure outputs.
MatcherFunction(std::function< bool(const AudioBuffer< SampleType > &, const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={})
Creates a matcher from a function that compares input and output.
bool canOperatePerBlock() const override
Tells the host if it can operate on a block-by-block basis.
bool match(const AudioBuffer< SampleType > &inputAudio, const AudioBuffer< SampleType > &observedOutputAudio) override
Tells the host if the piece of audio satisfies Matcher's condition or not.
virtual MatcherFailureDetails getFailureDetails() const override
Returns a description of why the match has failed.
void prepare(double, size_t, size_t) override
Prepare for processing It is guaranteed that all subsequent process() calls will be in line with the ...
Thrown when a nullptr could be handled gracefully.
#define HART_THROW_OR_RETURN(ExceptionType, message, returnValue)
Throws an exception if HART_DO_NOT_THROW_EXCEPTIONS is set, prints a message and returns a specified ...
#define HART_MATCHER_DECLARE_ALIASES_FOR(ClassName)
Details about matcher failure.
size_t channel
Index of channel at which the failure was detected.
std::string description
Readable description of why the match has failed.
size_t frame
Index of frame at which the match has failed.