Skip to content

Commit

Permalink
Add missing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Laguna1989 committed Dec 18, 2023
1 parent 468a563 commit fd26207
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/unit_tests/sound_data_builder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ TEST_CASE("SoundDataBuilder", "[SoundDataBuilder]")
REQUIRE(samples_loaded == samples_expected);
}

SECTION("With Gain Effect")
{
oalpp::effects::utility::Gain gain { 0.5f };
oalpp::SoundData const data
= builder.fromFile("assets/test_mono.mp3").withEffect(gain).create();

REQUIRE(data.getNumberOfChannels() == 1);
REQUIRE(data.getSampleRate() == 44100);

for (auto& s : samples_expected) {
s *= 0.5f;
}
auto const& samples_loaded = data.getSamples();
REQUIRE(samples_loaded == samples_expected);
}

SECTION("Mono To Stereo")
{
oalpp::SoundData const data
Expand Down
27 changes: 27 additions & 0 deletions test/unit_tests/sound_data_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <catch2/catch.hpp>
#include <oalpp/sound_data/sound_data.hpp>

TEST_CASE("SoundData Move constructor", "[SoundData]")
{
oalpp::SoundData data1 { std::vector<float> { 1.0f, 2.0f }, 44100, 2 };
oalpp::SoundData data2 { std::move(data1) };
REQUIRE(data2.getSamples().size() == 2);
REQUIRE(data2.getSamples().at(0) == 1.0f);
REQUIRE(data2.getSamples().at(1) == 2.0f);

REQUIRE(data2.getSampleRate() == 44100);
REQUIRE(data2.getNumberOfChannels() == 2);
}

TEST_CASE("SoundData Move assignment operator", "[SoundData]")
{
oalpp::SoundData data1 { std::vector<float> { 1.0f, 2.0f }, 44100, 2 };
oalpp::SoundData data2 = std::move(data1);

REQUIRE(data2.getSamples().size() == 2);
REQUIRE(data2.getSamples().at(0) == 1.0f);
REQUIRE(data2.getSamples().at(1) == 2.0f);

REQUIRE(data2.getSampleRate() == 44100);
REQUIRE(data2.getNumberOfChannels() == 2);
}

0 comments on commit fd26207

Please sign in to comment.