Move ComputeTest,GraphicsTest,RenderTest and Std140Debug to the tests folder
Also renamed NazaraUnitTests to UnitTests
This commit is contained in:
51
tests/UnitTests/Engine/Core/ClockTest.cpp
Normal file
51
tests/UnitTests/Engine/Core/ClockTest.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
SCENARIO("Clock", "[CORE][CLOCK]")
|
||||
{
|
||||
GIVEN("A clock paused")
|
||||
{
|
||||
Nz::UInt64 initialTime = 100;
|
||||
Nz::Clock clock(initialTime, true);
|
||||
|
||||
WHEN("We get time since it is paused")
|
||||
{
|
||||
THEN("Time must be the initialTime")
|
||||
{
|
||||
CHECK(clock.GetMicroseconds() == initialTime);
|
||||
CHECK(clock.IsPaused());
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("We unpause it")
|
||||
{
|
||||
clock.Unpause();
|
||||
REQUIRE(!clock.IsPaused());
|
||||
|
||||
THEN("Time must not be the initialTime")
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
Nz::UInt64 microSeconds = clock.GetMicroseconds();
|
||||
CHECK(microSeconds != initialTime);
|
||||
CHECK(microSeconds / 1000 <= clock.GetMilliseconds());
|
||||
CHECK(microSeconds / (1000.f * 1000.f) <= clock.GetSeconds());
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("We restart it")
|
||||
{
|
||||
clock.Restart();
|
||||
|
||||
THEN("It is unpaused and we can pause it")
|
||||
{
|
||||
CHECK(!clock.IsPaused());
|
||||
clock.Pause();
|
||||
CHECK(clock.IsPaused());
|
||||
CHECK(clock.GetMicroseconds() != initialTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user