-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from Laguna1989/FEATURE_ApprovalTestsWithWav
Run Approval tests with wav files
- Loading branch information
Showing
11 changed files
with
51 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
#include "approval_test_helpers.hpp" | ||
#include <algorithm> | ||
|
||
int ApprovalTestHelpers::asInt(float number, unsigned int digits) | ||
std::vector<int> ApprovalTestHelpers::asInt(std::vector<float> const& numbers, unsigned int digits) | ||
{ | ||
return static_cast<int>(number * digits); | ||
std::vector<int> numbersAsInts; | ||
numbersAsInts.resize(numbers.size()); | ||
std::transform(numbers.cbegin(), numbers.cend(), numbersAsInts.begin(), [digits](float number) | ||
{return static_cast<int>(number * digits);}); | ||
return numbersAsInts; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
|
||
#ifndef OPENALPP_APPROVAL_TEST_HELPERS_HPP | ||
#define OPENALPP_APPROVAL_TEST_HELPERS_HPP | ||
#include <vector> | ||
|
||
struct ApprovalTestHelpers { | ||
static int asInt(float number, unsigned int digits); | ||
static std::vector<int> asInt(std::vector<float> const& number, unsigned int digits); | ||
}; | ||
|
||
#endif // OPENALPP_APPROVAL_TEST_HELPERS_HPP |
4 changes: 2 additions & 2 deletions
4
test/approval_tests/approval_tests/effect_convolution_test.convolution.approved.txt
Git LFS file not shown
4 changes: 2 additions & 2 deletions
4
test/approval_tests/approval_tests/effect_gain_test.gain.1.0.approved.txt
Git LFS file not shown
4 changes: 2 additions & 2 deletions
4
test/approval_tests/approval_tests/effect_gain_test.gain.2.0.approved.txt
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
test/approval_tests/approval_tests/effect_phase_flip_test.phase_flip.approved.txt
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
#include "ApprovalTests/ApprovalTests.hpp" | ||
#include "approval_test_helpers.hpp" | ||
#include "catch2/catch.hpp" | ||
#include "oalpp/effects/utility/convolution.hpp" | ||
#include "oalpp/sound_data.hpp" | ||
#include "approval_test_helpers.hpp" | ||
|
||
TEST_CASE("convolution") | ||
{ | ||
std::string const fileName { "assets/test1.ogg" }; | ||
std::string const fileName { "assets/test1.wav" }; | ||
oalpp::SoundData buffer { fileName }; | ||
oalpp::effects::utility::Convolution convolution { buffer.getSamples() }; | ||
oalpp::SoundDataWithEffect soundWithEffect { buffer, convolution }; | ||
|
||
std::vector<int> values; | ||
values.resize(soundWithEffect.getSamples().size()); | ||
|
||
std::transform(soundWithEffect.getSamples().cbegin(), soundWithEffect.getSamples().cend(), | ||
values.begin(), [](float const value) { return ApprovalTestHelpers::asInt(value, 100); }); | ||
|
||
ApprovalTests::Approvals::verifyAll(values); | ||
// note: Due to platform dependent float behavior, the result needs to be converted to int for | ||
// the approval tests to work. | ||
ApprovalTests::Approvals::verifyAll(ApprovalTestHelpers::asInt(soundWithEffect.getSamples(), 100)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "ApprovalTests/ApprovalTests.hpp" | ||
#include "catch2/catch.hpp" | ||
#include "oalpp/effects/utility/phase_flip.hpp" | ||
#include "oalpp/sound_data.hpp" | ||
|
||
TEST_CASE("phase_flip") | ||
{ | ||
std::string const fileName { "assets/test1.wav" }; | ||
oalpp::SoundData buffer { fileName }; | ||
oalpp::effects::utility::PhaseFlip phaseFlip { }; | ||
oalpp::SoundDataWithEffect soundWithEffect { buffer, phaseFlip }; | ||
|
||
ApprovalTests::Approvals::verifyAll(soundWithEffect.getSamples()); | ||
} |