13#include <catch2/catch.hpp>
15TEST_CASE(
"AudioSegmentSampleView",
"Copy returns expected values when")
17 SECTION(
"AudioSegmentSampleView is silent")
20 std::vector<float> buffer(4);
21 std::fill(buffer.begin(), buffer.end(), 1.f);
22 SECTION(
"and asked MORE values than it holds.")
24 sut.Copy(buffer.data(), 4u);
25 REQUIRE(buffer == std::vector<float> { 0.f, 0.f, 0.f, 0.f });
27 SECTION(
"and asked FEWER values than it holds.")
29 sut.Copy(buffer.data(), 2u);
30 REQUIRE(buffer == std::vector<float> { 0.f, 0.f, 1.f, 1.f });
34 SECTION(
"AudioSegmentSampleView is NOT silent")
36 const auto segment1 = std::make_shared<std::vector<float>>(
37 std::vector<float> { 1.f, 2.f, 3.f });
38 const auto segment2 = std::make_shared<std::vector<float>>(
39 std::vector<float> { 4.f, 5.f, 6.f });
40 constexpr auto start = 2u;
41 constexpr auto length = 3u;
44 SECTION(
"and asked MORE values than it holds.")
46 std::vector<float> out(4u);
47 std::fill(out.begin(), out.end(), 123.f);
48 sut.Copy(out.data(), out.size());
49 REQUIRE(out == std::vector<float> { 3.f, 4.f, 5.f, 0.f });
51 SECTION(
"and asked FEWER values than it holds.")
53 std::vector<float> out(2u);
54 sut.Copy(out.data(), out.size());
55 REQUIRE(out == std::vector<float> { 3.f, 4.f });
An audio segment is either a whole clip or the silence between clips. Views allow shared references t...
TEST_CASE("AudioSegmentSampleView", "Copy returns expected values when")