File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 6
6
# include < util/optional.h>
7
7
# include < util/piped_process.h>
8
8
# include < util/string_utils.h>
9
+ // Used for testing destructor/timing
10
+ #include < chrono>
9
11
10
12
TEST_CASE (
11
13
" Creating a sub process and reading its output." ,
@@ -75,14 +77,16 @@ TEST_CASE(
75
77
std::vector<std::string> commands;
76
78
#ifdef _WIN32
77
79
commands.push_back (" cmd /c ping 127.0.0.1 -n 6 > nul" );
78
- SYSTEMTIME st;
79
- GetSystemTime (&st);
80
- WORD calc = 3600 * st.wHour + 60 * st.wMinute + st.wSecond ;
80
+ std::chrono::steady_clock::time_point start_time =
81
+ std::chrono::steady_clock::now ();
81
82
piped_processt process (commands);
82
83
process.~piped_processt ();
83
- GetSystemTime (&st);
84
- // New time minus old time, could go wrong at midnight
85
- calc = 3600 * st.wHour + 60 * st.wMinute + st.wSecond - calc;
84
+ std::chrono::steady_clock::time_point end_time =
85
+ std::chrono::steady_clock::now ();
86
+ std::chrono::duration<double > time_span =
87
+ std::chrono::duration_cast<std::chrono::duration<double >>(
88
+ end_time - start_time);
89
+ size_t calc = time_span.count ();
86
90
#else
87
91
// Currently not working under Linxu/MacOS?!
88
92
// commands.push_back("sleep 6");
You can’t perform that action at this time.
0 commit comments