File: test_timer.cpp

package info (click to toggle)
libtcod 1.24.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,728 kB
  • sloc: ansic: 46,186; cpp: 13,523; python: 4,814; makefile: 44; sh: 25
file content (29 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (2)
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
#ifndef NO_SDL
#include <SDL.h>

#include <catch2/catch_all.hpp>
#include <libtcod/timer.hpp>

TEST_CASE("tcod::Timer") {
  REQUIRE(SDL_InitSubSystem(SDL_INIT_TIMER) == 0);
  auto timer = tcod::Timer();

  // Check that getting the FPS with no samples won't crash.
  REQUIRE(timer.get_last_fps() == 0);
  REQUIRE(timer.get_mean_fps() == 0);
  REQUIRE(timer.get_median_fps() == 0);
  REQUIRE(timer.get_min_fps() == 0);
  REQUIRE(timer.get_max_fps() == 0);

  timer.sync(1000);
  timer.sync(0);

  static_cast<void>(timer.get_last_fps());
  static_cast<void>(timer.get_mean_fps());
  static_cast<void>(timer.get_median_fps());
  static_cast<void>(timer.get_min_fps());
  static_cast<void>(timer.get_max_fps());

  SDL_QuitSubSystem(SDL_INIT_TIMER);
}
#endif  // NO_SDL