TestVorbisDecode.cpp 829 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibMedia/Audio/Loader.h>
  7. #include <LibTest/TestCase.h>
  8. static void run_test(StringView file_name, int const num_samples, int const channels, u32 const rate)
  9. {
  10. constexpr auto format = "Ogg Vorbis (.ogg)";
  11. constexpr int bits = 32;
  12. ByteString in_path = ByteString::formatted("vorbis/{}", file_name);
  13. auto loader = TRY_OR_FAIL(Audio::Loader::create(in_path));
  14. EXPECT_EQ(loader->format_name(), format);
  15. EXPECT_EQ(loader->sample_rate(), rate);
  16. EXPECT_EQ(loader->num_channels(), channels);
  17. EXPECT_EQ(loader->bits_per_sample(), bits);
  18. EXPECT_EQ(loader->total_samples(), num_samples);
  19. }
  20. TEST_CASE(44_1Khz_stereo)
  21. {
  22. run_test("44_1Khz_stereo.ogg"sv, 352800, 2, 44100);
  23. }