SFML/test/Audio/OutputSoundFile.test.cpp

44 lines
1.7 KiB
C++
Raw Normal View History

#include <SFML/Audio/OutputSoundFile.hpp>
2025-02-04 15:05:27 -07:00
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <type_traits>
2025-02-04 15:05:27 -07:00
TEST_CASE("[Audio] sf::OutputSoundFile")
{
SECTION("Type traits")
{
STATIC_CHECK(std::is_default_constructible_v<sf::OutputSoundFile>);
STATIC_CHECK(!std::is_copy_constructible_v<sf::OutputSoundFile>);
STATIC_CHECK(!std::is_copy_assignable_v<sf::OutputSoundFile>);
STATIC_CHECK(std::is_nothrow_move_constructible_v<sf::OutputSoundFile>);
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::OutputSoundFile>);
}
const std::u32string stem = GENERATE(U"tmp", U"tmp-ń", U"tmp-🐌");
const std::u32string extension = GENERATE(U".wav", U".ogg"); // , U".flac"); FLAC fails to handle Unicode strings
const auto filename = std::filesystem::temp_directory_path() / std::filesystem::path(stem + extension);
const std::vector<sf::SoundChannel> channelMap{sf::SoundChannel::FrontLeft, sf::SoundChannel::FrontRight};
INFO("Filename: " << reinterpret_cast<const char*>(filename.u8string().c_str()));
SECTION("Construction")
{
{
const sf::OutputSoundFile outputSoundFile(filename, 44'100, static_cast<unsigned int>(channelMap.size()), channelMap);
CHECK(std::filesystem::exists(filename));
}
CHECK(std::filesystem::remove(filename));
}
SECTION("openFromFile()")
{
sf::OutputSoundFile outputSoundFile;
CHECK(outputSoundFile.openFromFile(filename, 44'100, static_cast<unsigned int>(channelMap.size()), channelMap));
CHECK(std::filesystem::exists(filename));
outputSoundFile.close();
CHECK(std::filesystem::remove(filename));
}
}