From 69706d3e1d413a410a498cd79b5ff1996c1f27ef Mon Sep 17 00:00:00 2001 From: Simon Weis Date: Tue, 22 Feb 2022 17:28:26 +0100 Subject: [PATCH 1/6] Add test for uncovered branch in update function --- test/unit_tests/sound_test.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/unit_tests/sound_test.cpp b/test/unit_tests/sound_test.cpp index 9bbf2f5..4a9e189 100644 --- a/test/unit_tests/sound_test.cpp +++ b/test/unit_tests/sound_test.cpp @@ -399,6 +399,28 @@ TEST_CASE("Sound getCurrentPosition", "[Sound]") } } } + + SECTION("update with looping sound does not raise exception") + { + fake.m_samples.resize(262144 + 200); + Sound snd { fake }; + snd.setIsLooping(true); + snd.play(); + auto const start = std::chrono::system_clock::now(); + while (snd.isPlaying()) { + snd.update(); + auto const newValue = snd.getCurrentOffsetInSeconds(); + auto const now = std::chrono::system_clock::now(); + float const elapsedSeconds + = std::chrono::duration_cast(now - start).count() + / 1000.0f / 1000.0f; + + if (elapsedSeconds >= 6.0f) { + snd.pause(); + break; + } + } + } } TEST_CASE("Sound Constructor without SoundContext raises exception", "[Sound]") From 22f3a7f054cc6eeb995c43c1ad2a76b53ab80070 Mon Sep 17 00:00:00 2001 From: Thunraz Date: Tue, 22 Feb 2022 17:36:38 +0100 Subject: [PATCH 2/6] Ignore CoverageReports --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 433bc1a..7edeba1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ - +CoverageReport-*/ # Created by https://www.gitignore.io/api/c++,cmake,visualstudio # Edit at https://www.gitignore.io/?templates=c++,cmake,visualstudio From bdf4941b9e0db3bd18949da0be20f1389c773614 Mon Sep 17 00:00:00 2001 From: Thunraz Date: Tue, 22 Feb 2022 17:47:04 +0100 Subject: [PATCH 3/6] Add zero check test for convolution --- test/unit_tests/sound_effects_test.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/unit_tests/sound_effects_test.cpp b/test/unit_tests/sound_effects_test.cpp index 9976c7f..6f89dfe 100644 --- a/test/unit_tests/sound_effects_test.cpp +++ b/test/unit_tests/sound_effects_test.cpp @@ -95,6 +95,21 @@ TEST_CASE("SoundEffect returns zero on zero input", "[SoundEffect]") inputVector.resize(numberOfSamples); REQUIRE(chain.process(inputVector) == inputVector); } + + SECTION("convolution") + { + auto const numberOfSamples = 10000u; + std::vector samples; + samples.resize(numberOfSamples); + oalpp::effects::utility::Convolution convolution { samples }; + + std::vector inputVector; + inputVector.resize(numberOfSamples); + + auto const result = convolution.process(inputVector); + REQUIRE(std::all_of(result.cbegin(), result.cend(), [](float f) { return f == 0.0f; }) + == true); + } } } From 7cdae1816214fa2eabbcaec18ab91460472a6887 Mon Sep 17 00:00:00 2001 From: Thunraz Date: Tue, 22 Feb 2022 17:59:54 +0100 Subject: [PATCH 4/6] Add command for OpenCppCoverage to README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 6ff3717..301e244 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,18 @@ How to build 3. `cmake ..` 4. `cmake --build . --target OpenALpp_Lib` +How to measure Code Coverage with [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage) +----------- + +``` +OpenCppCoverage.exe + --sources \OpenALpp\impl\ + --excluded_sources \OpenALpp\test\ + --excluded_sources \OpenALpp\ext* + --excluded_sources \OpenALpp\cmake-build-debug* + .\path\to\unit_tests\OpenALpp_UnitTests.exe +``` + Code Example ---------- From 8e01f91249b0e04e0324b429ffd5e49a864929d6 Mon Sep 17 00:00:00 2001 From: adkiem Date: Tue, 22 Feb 2022 18:20:14 +0100 Subject: [PATCH 5/6] Fix tests for channel conversion exceptions --- .../sound_data_channel_conversion_test.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/unit_tests/sound_data_channel_conversion_test.cpp b/test/unit_tests/sound_data_channel_conversion_test.cpp index 5bd5316..26533c7 100644 --- a/test/unit_tests/sound_data_channel_conversion_test.cpp +++ b/test/unit_tests/sound_data_channel_conversion_test.cpp @@ -99,8 +99,8 @@ TEST_CASE("SoundDataRightToMono", "[SoundConversion]") SECTION("Raises exception on mono data") { - SoundDataMonoFake fakeStereo {}; - REQUIRE_THROWS(SoundDataLeftToMono { fakeStereo }); + SoundDataMonoFake fakeMono {}; + REQUIRE_THROWS(SoundDataRightToMono { fakeMono }); } } @@ -131,8 +131,8 @@ TEST_CASE("SoundDataMidToMono", "[SoundConversion]") SECTION("Raises exception on mono data") { - SoundDataMonoFake fakeStereo {}; - REQUIRE_THROWS(SoundDataLeftToMono { fakeStereo }); + SoundDataMonoFake fakeMono {}; + REQUIRE_THROWS(SoundDataMidToMono { fakeMono }); } } @@ -163,7 +163,7 @@ TEST_CASE("SoundDataSideToMono", "[SoundConversion]") SECTION("Raises exception on mono data") { - SoundDataMonoFake fakeStereo {}; - REQUIRE_THROWS(SoundDataLeftToMono { fakeStereo }); + SoundDataMonoFake fakeMono {}; + REQUIRE_THROWS(SoundDataSideToMono { fakeMono }); } } From e7d4117e721809574963fb7a460a74c6c14653fd Mon Sep 17 00:00:00 2001 From: Simon Weis Date: Tue, 22 Feb 2022 18:32:08 +0100 Subject: [PATCH 6/6] Switch to windows server 2019 --- .github/workflows/test_verification.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_verification.yml b/.github/workflows/test_verification.yml index a014607..9204f3a 100644 --- a/.github/workflows/test_verification.yml +++ b/.github/workflows/test_verification.yml @@ -86,7 +86,7 @@ jobs: # working-directory: ${{github.workspace}}/build/bin/ Windows: - runs-on: windows-latest + runs-on: windows-2019 steps: - name: Set up cmake uses: jwlawson/actions-setup-cmake@v1.11