Add tests for sf::Clock
This commit is contained in:
parent
4586db91a9
commit
da6a226941
@ -8,6 +8,7 @@ target_compile_features(sfml-test-main PRIVATE cxx_std_17)
|
|||||||
|
|
||||||
# System is always built
|
# System is always built
|
||||||
SET(SYSTEM_SRC
|
SET(SYSTEM_SRC
|
||||||
|
"${SRCROOT}/System/Clock.cpp"
|
||||||
"${SRCROOT}/System/FileInputStream.cpp"
|
"${SRCROOT}/System/FileInputStream.cpp"
|
||||||
"${SRCROOT}/System/Time.cpp"
|
"${SRCROOT}/System/Time.cpp"
|
||||||
"${SRCROOT}/System/Vector2.cpp"
|
"${SRCROOT}/System/Vector2.cpp"
|
||||||
|
26
test/System/Clock.cpp
Normal file
26
test/System/Clock.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <SFML/System/Clock.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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user