From f35bb64c2b8dbb72fd15f1880e4d01d263660910 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 6 Dec 2022 13:17:56 +1100 Subject: basic i2s output element --- src/codecs/test/test_mad.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/codecs/test/test_mad.cpp') diff --git a/src/codecs/test/test_mad.cpp b/src/codecs/test/test_mad.cpp index 388efa17..d5522775 100644 --- a/src/codecs/test/test_mad.cpp +++ b/src/codecs/test/test_mad.cpp @@ -1,15 +1,16 @@ #include "mad.hpp" -#include #include +#include -#include "span.hpp" #include "catch2/catch.hpp" +#include "span.hpp" #include "test.mp3.hpp" void load_mp3(cpp::span dest) { - cpp::span src(reinterpret_cast(test_mp3), test_mp3_len); + cpp::span src(reinterpret_cast(test_mp3), + test_mp3_len); std::copy(src.begin(), src.begin() + dest.size(), dest.begin()); } @@ -24,7 +25,7 @@ TEST_CASE("libmad mp3 decoder", "[unit]") { } SECTION("processes streams correctly") { - std::array input; + std::array input; input.fill(std::byte{0}); decoder.ResetForNewStream(); @@ -38,7 +39,7 @@ TEST_CASE("libmad mp3 decoder", "[unit]") { } SECTION("invalid stream fails") { - input.fill(std::byte{0xFF}); + input.fill(std::byte{0x69}); auto result = decoder.ProcessNextFrame(); @@ -65,23 +66,26 @@ TEST_CASE("libmad mp3 decoder", "[unit]") { // Just check that some kind of data was written. We don't care // about what. - REQUIRE(std::to_integer(output[0]) != 0); - REQUIRE(std::to_integer(output[1]) != 0); - REQUIRE(std::to_integer(output[2]) != 0); - REQUIRE(std::to_integer(output[3]) != 0); + bool wrote_something = false; + for (int i = 0; i < output.size(); i++) { + if (std::to_integer(output[0]) != 0) { + wrote_something = true; + break; + } + } + REQUIRE(wrote_something == true); } SECTION("output format correct") { auto format = decoder.GetOutputFormat(); // Matches the test data. - REQUIRE(format.num_channels == 2); + REQUIRE(format.num_channels == 1); REQUIRE(format.sample_rate_hz == 44100); // Matches libmad output REQUIRE(format.bits_per_sample == 24); } } - } } -- cgit v1.2.3