diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3d5b6d504..936fb5d41 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,6 +8,7 @@ target_compile_features(sfml-test-main PRIVATE cxx_std_17) # System is always built SET(SYSTEM_SRC + "${SRCROOT}/System/Clock.cpp" "${SRCROOT}/System/FileInputStream.cpp" "${SRCROOT}/System/Time.cpp" "${SRCROOT}/System/Vector2.cpp" diff --git a/test/System/Clock.cpp b/test/System/Clock.cpp new file mode 100644 index 000000000..69765f79a --- /dev/null +++ b/test/System/Clock.cpp @@ -0,0 +1,26 @@ +#include +#include "SystemUtil.hpp" +#include + +#include + +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); + } +}