Skip to content

Commit

Permalink
Add approvaltests to linux clang build
Browse files Browse the repository at this point in the history
  • Loading branch information
Laguna1989 committed May 19, 2022
1 parent 3e48025 commit 38987f0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/test_verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,19 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}/build
run: make OpenALpp_UnitTests OpenALpp_Integration -j 4
run: make OpenALpp_UnitTests OpenALpp_Integration OpenALpp_ApprovalTests -j

# - name: Test
# Commented out because one does not simply acquire a sound context
# run: ./OpenALpp_UnitTests --order rand
# working-directory: ${{github.workspace}}/build/bin/

- name: CopyAssets
run: cp -r ${{github.workspace}}/assets ${{github.workspace}}/build/test/approval_tests

- name: ApprovalTest
run: ./OpenALpp_ApprovalTests --order rand
working-directory: ${{github.workspace}}/build/test/approval_tests

Windows:
runs-on: windows-2019
steps:
Expand Down
11 changes: 11 additions & 0 deletions test/approval_tests/approval_test_helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "approval_test_helpers.hpp"
#include <algorithm>

std::vector<int> ApprovalTestHelpers::asInt(std::vector<float> const& numbers, unsigned int 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;
}
9 changes: 9 additions & 0 deletions test/approval_tests/approval_test_helpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef OPENALPP_APPROVAL_TEST_HELPERS_HPP
#define OPENALPP_APPROVAL_TEST_HELPERS_HPP
#include <vector>

struct ApprovalTestHelpers {
static std::vector<int> ApprovalTestHelpers::asInt(std::vector<float> const& number, unsigned int digits);
};

#endif // OPENALPP_APPROVAL_TEST_HELPERS_HPP
Git LFS file not shown

This file was deleted.

5 changes: 4 additions & 1 deletion test/approval_tests/effect_convolution_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "catch2/catch.hpp"
#include "oalpp/effects/utility/convolution.hpp"
#include "oalpp/sound_data.hpp"
#include "approval_test_helpers.hpp"

TEST_CASE("convolution")
{
Expand All @@ -10,5 +11,7 @@ TEST_CASE("convolution")
oalpp::effects::utility::Convolution convolution { buffer.getSamples() };
oalpp::SoundDataWithEffect soundWithEffect { buffer, convolution };

ApprovalTests::Approvals::verifyAll(soundWithEffect.getSamples());
// 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));
}

0 comments on commit 38987f0

Please sign in to comment.