Audacity 3.2.0
SilenceSegmentTest.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 SilenceSegmentTest.cpp
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#include "SilenceSegment.h"
12#include "AudioContainer.h"
13
14#include <catch2/catch.hpp>
15
16TEST_CASE("SilenceSegment", "behaves as expected")
17{
18 // A quick test of an easy implementation.
19 const auto numChannels = GENERATE(1, 2);
20 constexpr auto silenceSegmentLength = 3u;
21 SilenceSegment sut(numChannels, silenceSegmentLength);
22 REQUIRE(!sut.Empty());
23 AudioContainer container(3u, numChannels);
24 REQUIRE(sut.GetFloats(container.channelPointers.data(), 1) == 1);
25 REQUIRE(!sut.Empty());
26 REQUIRE(sut.GetFloats(container.channelPointers.data(), 3) == 2);
27 REQUIRE(sut.Empty());
28}
TEST_CASE("SilenceSegment", "behaves as expected")
bool Empty() const override
Whether the segment has no more samples to provide.
size_t GetFloats(float *const *buffers, size_t numSamples) override
Fills buffers with as many as numSamples or the number of remaining samples, whichever is smaller.
std::vector< float * > channelPointers