SFML/test/Audio/SoundStream.test.cpp

67 lines
1.8 KiB
C++
Raw Permalink Normal View History

#include <SFML/Audio/SoundStream.hpp>
#include <catch2/catch_test_macros.hpp>
2023-04-16 10:50:24 +08:00
#include <AudioUtil.hpp>
#include <SystemUtil.hpp>
#include <type_traits>
2023-04-16 10:50:24 +08:00
namespace
{
class SoundStream : public sf::SoundStream
{
[[nodiscard]] bool onGetData(Chunk& /* data */) override
{
return true;
}
void onSeek(sf::Time /* timeOffset */) override
{
}
};
} // namespace
TEST_CASE("[Audio] sf::SoundStream", runAudioDeviceTests())
{
SECTION("Type traits")
{
STATIC_CHECK(!std::is_constructible_v<sf::SoundStream>);
STATIC_CHECK(!std::is_copy_constructible_v<sf::SoundStream>);
STATIC_CHECK(!std::is_copy_assignable_v<sf::SoundStream>);
STATIC_CHECK(!std::is_nothrow_move_constructible_v<sf::SoundStream>);
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::SoundStream>);
2023-04-16 10:50:24 +08:00
STATIC_CHECK(std::has_virtual_destructor_v<sf::SoundStream>);
}
SECTION("Chunk")
{
const sf::SoundStream::Chunk chunk;
CHECK(chunk.samples == nullptr);
CHECK(chunk.sampleCount == 0);
}
2023-04-16 10:50:24 +08:00
SECTION("Construction")
{
const SoundStream soundStream;
CHECK(soundStream.getChannelCount() == 0);
CHECK(soundStream.getSampleRate() == 0);
CHECK(soundStream.getStatus() == sf::SoundStream::Status::Stopped);
2023-04-16 10:50:24 +08:00
CHECK(soundStream.getPlayingOffset() == sf::Time::Zero);
CHECK(!soundStream.isLooping());
2023-04-16 10:50:24 +08:00
}
SECTION("Set/get playing offset")
{
SoundStream soundStream;
soundStream.setPlayingOffset(sf::milliseconds(100));
CHECK(soundStream.getPlayingOffset() == sf::milliseconds(0));
}
SECTION("Set/get loop")
{
SoundStream soundStream;
soundStream.setLooping(true);
CHECK(soundStream.isLooping());
2023-04-16 10:50:24 +08:00
}
}