Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
unit-tests
utilities
time
test-timer.cpp
Go to the documentation of this file.
1
// License: Apache 2.0. See LICENSE file in root directory.
2
// Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3
4
// Unit Test Goals:
5
// Test the timer utility classes: stopwatch, timer, periodic_timer.
6
7
//#cmake:add-file ../../../common/utilities/time/timer.h
8
9
10
#include "
common.h
"
11
#include "../common/utilities/time/timer.h"
12
13
using namespace
utilities::time
;
14
15
// Test description:
16
// > Test the timer main functions
17
// > Verify the timer expired only when the timeout is reached.
18
// > Verify restart process
19
TEST_CASE
(
"test timer"
,
"[timer]"
)
20
{
21
timer
t
(
TEST_DELTA_TIME
);
22
23
CHECK_FALSE
(t.
has_expired
());
24
25
t.
start
();
26
CHECK_FALSE
(t.
has_expired
());
27
28
std::this_thread::sleep_for(
TEST_DELTA_TIME
+ std::chrono::milliseconds(100));
29
30
// test has_expired() function - expect time expiration
31
CHECK
(t.
has_expired
());
32
33
// test start() function and verify expiration behavior
34
t.
start
();
35
CHECK_FALSE
(t.
has_expired
());
36
37
std::this_thread::sleep_for(
TEST_DELTA_TIME
/ 2);
38
39
// Verify time has not expired yet
40
CHECK_FALSE
(t.
has_expired
());
41
42
std::this_thread::sleep_for(
TEST_DELTA_TIME
);
43
44
// Verify time expired
45
CHECK
(t.
has_expired
());
46
47
}
48
49
// Test description:
50
// Verify the we can force the time expiration
51
TEST_CASE
(
"Test force time expiration"
,
"[timer]"
)
52
{
53
timer
t
(
TEST_DELTA_TIME
);
54
55
CHECK_FALSE
(t.
has_expired
());
56
t.
set_expired
();
57
CHECK
(t.
has_expired
());
58
}
TEST_DELTA_TIME
const auto TEST_DELTA_TIME
Definition:
unit-tests/utilities/time/common.h:17
utilities::time::timer::start
void start() const
Definition:
timer.h:24
utilities::time::timer::set_expired
void set_expired()
Definition:
timer.h:36
t
GLdouble t
Definition:
glad/glad/glad.h:1830
TEST_CASE
TEST_CASE("test timer","[timer]")
Definition:
test-timer.cpp:19
utilities::time::timer
Definition:
timer.h:15
utilities::time::timer::has_expired
bool has_expired() const
Definition:
timer.h:30
utilities::time
Definition:
common/utilities/time/common.h:10
common.h
CHECK
#define CHECK(condition)
Definition:
easylogging++.h:4483
CHECK_FALSE
CHECK_FALSE(inverse(inverse(p))==p)
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:50:11