Skip to content

Commit

Permalink
Add more robust tests for sf::Music::setLoopPoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Nov 12, 2024
1 parent 58085ef commit e21ba4d
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions test/Audio/Music.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,42 @@ TEST_CASE("[Audio] sf::Music", runAudioDeviceTests())

SECTION("setLoopPoints()")
{
sf::Music music("Audio/killdeer.wav");
music.setLoopPoints({sf::seconds(1), sf::seconds(2)});
const auto [offset, length] = music.getLoopPoints();
CHECK(offset == sf::seconds(1));
CHECK(length == sf::seconds(2));
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);
Expand Down

0 comments on commit e21ba4d

Please sign in to comment.