Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
timer_test.cc
1 #include <gtest/gtest.h>
2 
3 #include <sstream>
4 
5 #include "utilities/timer.h"
6 
7 TEST(Timer, Short) {
8  Timer timer;
9  EXPECT_FALSE(timer.RunningMoreThan(1.0));
10  sleep(2.0);
11  EXPECT_TRUE(timer.RunningMoreThan(1.0));
12 
13  std::stringstream ss;
14  ss << timer;
15  std::string res = ss.str();
16  EXPECT_EQ(res[0], '2'); // sleep(2) should take between 2 and 3 seconds
17  EXPECT_EQ(*res.rbegin(), 's'); // last character is 's'
18 }
19 
20 #ifndef __NO_MAIN__
21 int main(int argc, char **argv) {
22  ::testing::InitGoogleTest(&argc, argv);
23  return RUN_ALL_TESTS();
24 }
25 #endif
Timer
Elapsed time measurement.
Definition: timer.h:10