SFML/test/System/Clock.cpp
Chris Thrasher fd3526f742 Use <> for test utilities includes
SFML convention is to only use "" includes when the header is in
the same directory as the file including it. Because these test
util headers are in a separate directory, it makes more sense to
include them via <>.
2022-06-27 00:22:16 +02:00

28 lines
755 B
C++

#include <SFML/System/Clock.hpp>
#include <SFML/System/Time.hpp>
#include <SystemUtil.hpp>
#include <thread>
#include <doctest.h>
TEST_CASE("sf::Clock class - [system]")
{
SUBCASE("getElapsedTime()")
{
const sf::Clock clock;
CHECK(clock.getElapsedTime() >= sf::microseconds(0));
const auto elapsed = clock.getElapsedTime();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
CHECK(clock.getElapsedTime() > elapsed);
}
SUBCASE("restart()")
{
sf::Clock clock;
CHECK(clock.restart() >= sf::microseconds(0));
std::this_thread::sleep_for(std::chrono::milliseconds(1));
const auto elapsed = clock.restart();
CHECK(clock.restart() < elapsed);
}
}