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 {
22 
24 
25  t.start();
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();
36 
37  std::this_thread::sleep_for(TEST_DELTA_TIME / 2);
38 
39  // Verify time has not expired yet
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 {
54 
56  t.set_expired();
57  CHECK(t.has_expired());
58 }
const auto TEST_DELTA_TIME
void start() const
Definition: timer.h:24
void set_expired()
Definition: timer.h:36
GLdouble t
TEST_CASE("test timer","[timer]")
Definition: test-timer.cpp:19
bool has_expired() const
Definition: timer.h:30
#define CHECK(condition)
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