test-stopwatch.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/stopwatch.h
8 
9 
10 #include "common.h"
11 #include "../common/utilities/time/stopwatch.h"
12 
13 using namespace utilities::time;
14 
15 // Test description:
16 // Test the stopwatch main functions
17 TEST_CASE( "test stopwatch", "[stopwatch]" )
18 {
19  stopwatch sw;
20 
21  // Verify constructor set the time.
22  CHECK(sw.get_start().time_since_epoch().count() > 0);
23 
24  auto current_time = clock::now();
25 
26  // Verify calling order force time count order
27  CHECK(sw.get_start() <= current_time);
28 
29  // Test elapsed() function
31 
32  // Sleep for verifying progress of time
33  std::this_thread::sleep_for(TEST_DELTA_TIME);
34 
35  // Check elapsed() function
37 
38  // Check elapsed_ms() function
40 
41  // Check reset() function
42  sw.reset();
43 
44  // Verify reset cause the elapsed time to be smaller
47 
48 }
const auto TEST_DELTA_TIME
long long current_time()
clock::time_point get_start() const
Definition: stopwatch.h:42
void reset(clock::time_point start_time=clock::now()) const
Definition: stopwatch.h:24
double get_elapsed_ms() const
Definition: stopwatch.h:30
TEST_CASE("test stopwatch","[stopwatch]")
#define CHECK(condition)
clock::duration get_elapsed() const
Definition: stopwatch.h:36
const auto TEST_DELTA_TIME_MS


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11