mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Test that music objects can't be used in a way that triggers a crash
This commit is contained in:
parent
fbd8407a5f
commit
8277fe1710
@ -10,8 +10,34 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
struct Singleton
|
||||||
|
{
|
||||||
|
static T& getInstance()
|
||||||
|
{
|
||||||
|
static T instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
TEST_CASE("[Audio] sf::Music", runAudioDeviceTests())
|
TEST_CASE("[Audio] sf::Music", runAudioDeviceTests())
|
||||||
{
|
{
|
||||||
|
// Section must be placed first within this TEST_CASE or else it will always pass
|
||||||
|
SECTION("Construction/destruction order")
|
||||||
|
{
|
||||||
|
struct MusicSingleton : Singleton<MusicSingleton>
|
||||||
|
{
|
||||||
|
std::optional<sf::Music> music;
|
||||||
|
};
|
||||||
|
|
||||||
|
MusicSingleton::getInstance();
|
||||||
|
MusicSingleton::getInstance().music = sf::Music::openFromFile("Audio/ding.flac").value();
|
||||||
|
CHECK(true); // Lack of a crash due to assertion failure signals success
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("Type traits")
|
SECTION("Type traits")
|
||||||
{
|
{
|
||||||
STATIC_CHECK(!std::is_copy_constructible_v<sf::Music>);
|
STATIC_CHECK(!std::is_copy_constructible_v<sf::Music>);
|
||||||
|
Loading…
Reference in New Issue
Block a user