Skip to content

Commit

Permalink
Reduce Stopwatch test sleep times
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Dec 21, 2021
1 parent 3c96971 commit 0b7481b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Stopwatch_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ void runTimer(math::Stopwatch &_time)
_time.ElapsedStopTime());

// Wait for some time...
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::this_thread::sleep_for(std::chrono::milliseconds(50));
// Now the elapsed time should be greater than or equal to the time slept.
EXPECT_GE(_time.ElapsedRunTime() + handleSteadyClock,
std::chrono::milliseconds(1000));
std::chrono::milliseconds(50));

// Stop the timer.
EXPECT_TRUE(_time.Stop());
Expand All @@ -59,17 +59,17 @@ void runTimer(math::Stopwatch &_time)
EXPECT_GT(_time.StopTime(), _time.StartTime());
// The elapsed time should still be greater than the time slept.
EXPECT_GE(_time.ElapsedRunTime() + handleSteadyClock,
std::chrono::milliseconds(1000));
std::chrono::milliseconds(50));

// Save the elapsed time.
auto elapsedTime = _time.ElapsedRunTime();

// The timer is now stopped, let's sleep some more.
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::this_thread::sleep_for(std::chrono::milliseconds(50));
// The elapsed stop time should be greater than or equal to the time
// slept.
EXPECT_GE(_time.ElapsedStopTime() + handleSteadyClock,
std::chrono::milliseconds(1000));
std::chrono::milliseconds(50));
// The elapsed time should be the same.
EXPECT_EQ(elapsedTime, _time.ElapsedRunTime());

Expand All @@ -80,15 +80,15 @@ void runTimer(math::Stopwatch &_time)
// The timer should be running.
EXPECT_TRUE(_time.Running());
// Sleep for some time.
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::this_thread::sleep_for(std::chrono::milliseconds(50));
// The elapsed stop time should remain the same
EXPECT_EQ(elapsedStopTime, _time.ElapsedStopTime());
// The elapsed time should be greater than the previous elapsed time.
EXPECT_GT(_time.ElapsedRunTime(), elapsedTime);
// The elapsed time should be greater than or equal to the the previous
// two sleep times.
EXPECT_GE(_time.ElapsedRunTime() + handleSteadyClock,
std::chrono::milliseconds(2000));
std::chrono::milliseconds(100));
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit 0b7481b

Please sign in to comment.