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 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 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 ---------- 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 }); } } 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); + } } } 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]")