blob: a3b1646f63513730678583b621762e2b261898de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#define private public
#define protected public
#include "api/LoopManager.h"
#include "api/LoopTimer.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using namespace std;
using namespace std::chrono_literals;
using namespace crepe;
class LoopTimerTest : public ::testing::Test {
public:
LoopTimer loop_timer = LoopTimer::get_instance();
protected:
void SetUp() override {
loop_timer.start();
}
void TearDown() override {
}
};
TEST_F(LoopTimerTest, TestDeltaTime) {
auto start_time = std::chrono::steady_clock::now();
loop_timer.update();
double delta_time = loop_timer.get_delta_time();
auto elapsed_time = std::chrono::steady_clock::now() - start_time;
EXPECT_LE(delta_time, std::chrono::duration<double>(elapsed_time).count());
}
|