Add missing sf::SoundSource tests

This commit is contained in:
Chris Thrasher 2024-11-24 14:21:24 -07:00
parent d78cec0236
commit eec0ece713

View File

@ -52,10 +52,22 @@ TEST_CASE("[Audio] sf::SoundSource", runAudioDeviceTests())
{ {
const SoundSource soundSource; const SoundSource soundSource;
CHECK(soundSource.getPitch() == 0); CHECK(soundSource.getPitch() == 0);
CHECK(soundSource.getPan() == 0);
CHECK(soundSource.getVolume() == 0); CHECK(soundSource.getVolume() == 0);
CHECK(!soundSource.isSpatializationEnabled());
CHECK(soundSource.getPosition() == sf::Vector3f()); CHECK(soundSource.getPosition() == sf::Vector3f());
CHECK(soundSource.getDirection() == sf::Vector3f());
CHECK(soundSource.getCone().innerAngle == sf::degrees(0));
CHECK(soundSource.getCone().innerAngle == sf::degrees(0));
CHECK(soundSource.getCone().outerGain == 0);
CHECK(soundSource.getVelocity() == sf::Vector3f());
CHECK(soundSource.getDopplerFactor() == 0);
CHECK(soundSource.getDirectionalAttenuationFactor() == 0);
CHECK(!soundSource.isRelativeToListener()); CHECK(!soundSource.isRelativeToListener());
CHECK(soundSource.getMinDistance() == 0); CHECK(soundSource.getMinDistance() == 0);
CHECK(soundSource.getMaxDistance() == 0);
CHECK(soundSource.getMinGain() == 0);
CHECK(soundSource.getMaxGain() == 0);
CHECK(soundSource.getAttenuation() == 0); CHECK(soundSource.getAttenuation() == 0);
CHECK(soundSource.getStatus() == sf::SoundSource::Status::Stopped); CHECK(soundSource.getStatus() == sf::SoundSource::Status::Stopped);
} }
@ -68,10 +80,22 @@ TEST_CASE("[Audio] sf::SoundSource", runAudioDeviceTests())
{ {
const SoundSource soundSourceCopy(soundSource); // NOLINT(performance-unnecessary-copy-initialization) const SoundSource soundSourceCopy(soundSource); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(soundSourceCopy.getPitch() == 0); CHECK(soundSourceCopy.getPitch() == 0);
CHECK(soundSourceCopy.getPan() == 0);
CHECK(soundSourceCopy.getVolume() == 0); CHECK(soundSourceCopy.getVolume() == 0);
CHECK(!soundSourceCopy.isSpatializationEnabled());
CHECK(soundSourceCopy.getPosition() == sf::Vector3f()); CHECK(soundSourceCopy.getPosition() == sf::Vector3f());
CHECK(soundSourceCopy.getDirection() == sf::Vector3f());
CHECK(soundSourceCopy.getCone().innerAngle == sf::degrees(0));
CHECK(soundSourceCopy.getCone().innerAngle == sf::degrees(0));
CHECK(soundSourceCopy.getCone().outerGain == 0);
CHECK(soundSourceCopy.getVelocity() == sf::Vector3f());
CHECK(soundSourceCopy.getDopplerFactor() == 0);
CHECK(soundSourceCopy.getDirectionalAttenuationFactor() == 0);
CHECK(!soundSourceCopy.isRelativeToListener()); CHECK(!soundSourceCopy.isRelativeToListener());
CHECK(soundSourceCopy.getMinDistance() == 0); CHECK(soundSourceCopy.getMinDistance() == 0);
CHECK(soundSourceCopy.getMaxDistance() == 0);
CHECK(soundSourceCopy.getMinGain() == 0);
CHECK(soundSourceCopy.getMaxGain() == 0);
CHECK(soundSourceCopy.getAttenuation() == 0); CHECK(soundSourceCopy.getAttenuation() == 0);
CHECK(soundSourceCopy.getStatus() == sf::SoundSource::Status::Stopped); CHECK(soundSourceCopy.getStatus() == sf::SoundSource::Status::Stopped);
} }
@ -81,10 +105,22 @@ TEST_CASE("[Audio] sf::SoundSource", runAudioDeviceTests())
SoundSource soundSourceCopy; SoundSource soundSourceCopy;
soundSourceCopy = soundSource; soundSourceCopy = soundSource;
CHECK(soundSourceCopy.getPitch() == 0); CHECK(soundSourceCopy.getPitch() == 0);
CHECK(soundSourceCopy.getPan() == 0);
CHECK(soundSourceCopy.getVolume() == 0); CHECK(soundSourceCopy.getVolume() == 0);
CHECK(!soundSourceCopy.isSpatializationEnabled());
CHECK(soundSourceCopy.getPosition() == sf::Vector3f()); CHECK(soundSourceCopy.getPosition() == sf::Vector3f());
CHECK(soundSourceCopy.getDirection() == sf::Vector3f());
CHECK(soundSourceCopy.getCone().innerAngle == sf::degrees(0));
CHECK(soundSourceCopy.getCone().innerAngle == sf::degrees(0));
CHECK(soundSourceCopy.getCone().outerGain == 0);
CHECK(soundSourceCopy.getVelocity() == sf::Vector3f());
CHECK(soundSourceCopy.getDopplerFactor() == 0);
CHECK(soundSourceCopy.getDirectionalAttenuationFactor() == 0);
CHECK(!soundSourceCopy.isRelativeToListener()); CHECK(!soundSourceCopy.isRelativeToListener());
CHECK(soundSourceCopy.getMinDistance() == 0); CHECK(soundSourceCopy.getMinDistance() == 0);
CHECK(soundSourceCopy.getMaxDistance() == 0);
CHECK(soundSourceCopy.getMinGain() == 0);
CHECK(soundSourceCopy.getMaxGain() == 0);
CHECK(soundSourceCopy.getAttenuation() == 0); CHECK(soundSourceCopy.getAttenuation() == 0);
CHECK(soundSourceCopy.getStatus() == sf::SoundSource::Status::Stopped); CHECK(soundSourceCopy.getStatus() == sf::SoundSource::Status::Stopped);
} }
@ -97,6 +133,13 @@ TEST_CASE("[Audio] sf::SoundSource", runAudioDeviceTests())
CHECK(soundSource.getPitch() == 0); CHECK(soundSource.getPitch() == 0);
} }
SECTION("Set/get pan")
{
SoundSource soundSource;
soundSource.setPan(1);
CHECK(soundSource.getPan() == 0);
}
SECTION("Set/get volume") SECTION("Set/get volume")
{ {
SoundSource soundSource; SoundSource soundSource;
@ -104,6 +147,13 @@ TEST_CASE("[Audio] sf::SoundSource", runAudioDeviceTests())
CHECK(soundSource.getVolume() == 0); CHECK(soundSource.getVolume() == 0);
} }
SECTION("Set/get spatialization enabled")
{
SoundSource soundSource;
soundSource.setSpatializationEnabled(true);
CHECK(!soundSource.isSpatializationEnabled());
}
SECTION("Set/get position") SECTION("Set/get position")
{ {
SoundSource soundSource; SoundSource soundSource;
@ -111,6 +161,43 @@ TEST_CASE("[Audio] sf::SoundSource", runAudioDeviceTests())
CHECK(soundSource.getPosition() == sf::Vector3f()); CHECK(soundSource.getPosition() == sf::Vector3f());
} }
SECTION("Set/get direction")
{
SoundSource soundSource;
soundSource.setDirection({4, 5, 6});
CHECK(soundSource.getDirection() == sf::Vector3f());
}
SECTION("Set/get cone")
{
SoundSource soundSource;
soundSource.setCone({sf::radians(1), sf::radians(2), 3});
CHECK(soundSource.getCone().innerAngle == sf::degrees(0));
CHECK(soundSource.getCone().outerAngle == sf::degrees(0));
CHECK(soundSource.getCone().outerGain == 0);
}
SECTION("Set/get velocity")
{
SoundSource soundSource;
soundSource.setVelocity({7, 8, 9});
CHECK(soundSource.getVelocity() == sf::Vector3f());
}
SECTION("Set/get doppler factor")
{
SoundSource soundSource;
soundSource.setDopplerFactor(1);
CHECK(soundSource.getDopplerFactor() == 0);
}
SECTION("Set/get directional attenuation factor")
{
SoundSource soundSource;
soundSource.setDirectionalAttenuationFactor(1);
CHECK(soundSource.getDirectionalAttenuationFactor() == 0);
}
SECTION("Set/get relative to listener") SECTION("Set/get relative to listener")
{ {
SoundSource soundSource; SoundSource soundSource;
@ -125,6 +212,27 @@ TEST_CASE("[Audio] sf::SoundSource", runAudioDeviceTests())
CHECK(soundSource.getMinDistance() == 0); CHECK(soundSource.getMinDistance() == 0);
} }
SECTION("Set/get max distance")
{
SoundSource soundSource;
soundSource.setMaxDistance(12.34f);
CHECK(soundSource.getMaxDistance() == 0);
}
SECTION("Set/get min gain")
{
SoundSource soundSource;
soundSource.setMinGain(12.34f);
CHECK(soundSource.getMinGain() == 0);
}
SECTION("Set/get max gain")
{
SoundSource soundSource;
soundSource.setMaxGain(12.34f);
CHECK(soundSource.getMaxGain() == 0);
}
SECTION("Set/get attenuation") SECTION("Set/get attenuation")
{ {
SoundSource soundSource; SoundSource soundSource;