mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Add more robust tests for sf::Music::setLoopPoints
This commit is contained in:
parent
58085efb29
commit
e21ba4dc95
@ -241,11 +241,42 @@ TEST_CASE("[Audio] sf::Music", runAudioDeviceTests())
|
||||
|
||||
SECTION("setLoopPoints()")
|
||||
{
|
||||
sf::Music music("Audio/killdeer.wav");
|
||||
sf::Music music;
|
||||
|
||||
SECTION("Uninitalized")
|
||||
{
|
||||
music.setLoopPoints({sf::seconds(1), sf::seconds(2)});
|
||||
const auto [offset, length] = music.getLoopPoints();
|
||||
CHECK(offset == sf::seconds(0));
|
||||
CHECK(length == sf::seconds(0));
|
||||
}
|
||||
|
||||
REQUIRE(music.openFromFile("Audio/killdeer.wav"));
|
||||
|
||||
SECTION("Within range")
|
||||
{
|
||||
music.setLoopPoints({sf::seconds(1), sf::seconds(2)});
|
||||
const auto [offset, length] = music.getLoopPoints();
|
||||
CHECK(offset == sf::seconds(1));
|
||||
CHECK(length == sf::seconds(2));
|
||||
}
|
||||
|
||||
SECTION("Duration too long")
|
||||
{
|
||||
music.setLoopPoints({sf::seconds(1), sf::seconds(1'000)});
|
||||
const auto [offset, length] = music.getLoopPoints();
|
||||
CHECK(offset == sf::seconds(1));
|
||||
CHECK(length == sf::microseconds(4'122'040));
|
||||
}
|
||||
|
||||
SECTION("Offset too long")
|
||||
{
|
||||
music.setLoopPoints({sf::seconds(1'000), sf::milliseconds(10)});
|
||||
const auto [offset, length] = music.getLoopPoints();
|
||||
CHECK(offset == sf::seconds(0));
|
||||
CHECK(length == sf::microseconds(5'122'040));
|
||||
}
|
||||
|
||||
CHECK(music.getChannelCount() == 1);
|
||||
CHECK(music.getSampleRate() == 22050);
|
||||
CHECK(music.getStatus() == sf::Music::Status::Stopped);
|
||||
|
Loading…
Reference in New Issue
Block a user