mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-09 10:40:28 +00:00
feat(Core/LFG): Implement dungeon selection cooldown to prevent repeat assignme… (#24916)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
63
src/test/server/game/Time/GameTime.cpp
Normal file
63
src/test/server/game/Time/GameTime.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "GameTime.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
TEST(GameTimeTest, Elapsed)
|
||||
{
|
||||
GameTime::UpdateGameTimers();
|
||||
auto start = GameTime::Now();
|
||||
std::this_thread::sleep_for(50ms);
|
||||
GameTime::UpdateGameTimers();
|
||||
auto elapsed = GameTime::Elapsed(start);
|
||||
EXPECT_GE(elapsed, 50ms);
|
||||
}
|
||||
|
||||
TEST(GameTimeTest, HasElapsedTrue)
|
||||
{
|
||||
GameTime::UpdateGameTimers();
|
||||
auto start = GameTime::Now();
|
||||
std::this_thread::sleep_for(50ms);
|
||||
GameTime::UpdateGameTimers();
|
||||
EXPECT_TRUE(GameTime::HasElapsed(start, 25ms));
|
||||
}
|
||||
|
||||
TEST(GameTimeTest, HasElapsedFalse)
|
||||
{
|
||||
GameTime::UpdateGameTimers();
|
||||
auto start = GameTime::Now();
|
||||
EXPECT_FALSE(GameTime::HasElapsed(start, 10s));
|
||||
}
|
||||
|
||||
TEST(GameTimeTest, HasElapsedWithSeconds)
|
||||
{
|
||||
GameTime::UpdateGameTimers();
|
||||
auto start = GameTime::Now();
|
||||
EXPECT_FALSE(GameTime::HasElapsed(start, 1s));
|
||||
}
|
||||
|
||||
TEST(GameTimeTest, HasElapsedWithMicroseconds)
|
||||
{
|
||||
GameTime::UpdateGameTimers();
|
||||
auto start = GameTime::Now();
|
||||
std::this_thread::sleep_for(100us);
|
||||
GameTime::UpdateGameTimers();
|
||||
EXPECT_TRUE(GameTime::HasElapsed(start, Microseconds(1)));
|
||||
}
|
||||
Reference in New Issue
Block a user