AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
GameTime.cpp File Reference
#include "GameTime.h"
#include "gtest/gtest.h"
#include <thread>

Go to the source code of this file.

Functions

 TEST (GameTimeTest, Elapsed)
 
 TEST (GameTimeTest, HasElapsedTrue)
 
 TEST (GameTimeTest, HasElapsedFalse)
 
 TEST (GameTimeTest, HasElapsedWithSeconds)
 
 TEST (GameTimeTest, HasElapsedWithMicroseconds)
 

Function Documentation

◆ TEST() [1/5]

TEST ( GameTimeTest  ,
Elapsed   
)
24{
26 auto start = GameTime::Now();
27 std::this_thread::sleep_for(50ms);
29 auto elapsed = GameTime::Elapsed(start);
30 EXPECT_GE(elapsed, 50ms);
31}
void UpdateGameTimers()
Update all timers.
Definition GameTime.cpp:63
TimePoint Now()
Current chrono steady_clock time point.
Definition GameTime.cpp:53
Microseconds Elapsed(TimePoint start)
Uptime since a given time point.
Definition GameTime.h:45

References GameTime::Elapsed(), GameTime::Now(), and GameTime::UpdateGameTimers().

◆ TEST() [2/5]

TEST ( GameTimeTest  ,
HasElapsedFalse   
)
43{
45 auto start = GameTime::Now();
46 EXPECT_FALSE(GameTime::HasElapsed(start, 10s));
47}
bool HasElapsed(TimePoint start, T duration)
Check if a duration has elapsed since a given time point.
Definition GameTime.h:52

References GameTime::HasElapsed(), GameTime::Now(), and GameTime::UpdateGameTimers().

◆ TEST() [3/5]

TEST ( GameTimeTest  ,
HasElapsedTrue   
)
34{
36 auto start = GameTime::Now();
37 std::this_thread::sleep_for(50ms);
39 EXPECT_TRUE(GameTime::HasElapsed(start, 25ms));
40}

References GameTime::HasElapsed(), GameTime::Now(), and GameTime::UpdateGameTimers().

◆ TEST() [4/5]

TEST ( GameTimeTest  ,
HasElapsedWithMicroseconds   
)
57{
59 auto start = GameTime::Now();
60 std::this_thread::sleep_for(100us);
62 EXPECT_TRUE(GameTime::HasElapsed(start, Microseconds(1)));
63}
std::chrono::microseconds Microseconds
Microseconds shorthand typedef.
Definition Duration.h:24

References GameTime::HasElapsed(), GameTime::Now(), and GameTime::UpdateGameTimers().

◆ TEST() [5/5]

TEST ( GameTimeTest  ,
HasElapsedWithSeconds   
)
50{
52 auto start = GameTime::Now();
53 EXPECT_FALSE(GameTime::HasElapsed(start, 1s));
54}

References GameTime::HasElapsed(), GameTime::Now(), and GameTime::UpdateGameTimers().