* Core/Bitset: Fix TestAll method * Fix documentation * Fix color and their conversions * Core/ByteStream: Fix return of Write * Fix compiler warnings * Math/Algorithm: Fix angle normalization * Math/BoundingVolume: Fix lerp * Math: Fix relation between Matrix4 and Quaternion * More tests * X11/Window: Fix mouse moved event generated when doing Mouse::SetPosition * Update ChangeLog * Should fix compilation on Windows * Should fix compilation on Windows Forgot to include array for Windows
50 lines
1.0 KiB
C++
50 lines
1.0 KiB
C++
#include <Nazara/Core/Clock.hpp>
|
|
#include <Nazara/Core/Thread.hpp>
|
|
#include <Catch/catch.hpp>
|
|
|
|
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")
|
|
{
|
|
Nz::Thread::Sleep(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);
|
|
}
|
|
}
|
|
}
|
|
}
|