Skip to content

Commit

Permalink
fix: testing timer
Browse files Browse the repository at this point in the history
Signed-off-by: slowy07 <[email protected]>
  • Loading branch information
slowy07 committed Aug 8, 2023
1 parent bda75ac commit 365ae9b
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions clara_test/tests/classFunction/timer_testing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,16 @@

using namespace clara;

const double TOLERANCE = 1e-6;

class TimerTest : public ::testing::Test {
protected:
void sleep_for(int milliseconds) {
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
}
};

TEST_F(TimerTest, BasicFunctionallyTest) {
Timer<std::chrono::milliseconds> timer;
sleep_for(100);
timer.toc();
EXPECT_NEAR(timer.tics(), 100.0, TOLERANCE);
TEST(clara_timer_test, DefaultConstructor) {
Timer<> timer;
EXPECT_GE(timer.tics(), 0);
}

TEST(clara_timer, AllTests) {
using namespace std::chrono;

Timer<> t;
std::this_thread::sleep_for(milliseconds(100));
t.tic();
t.toc();
EXPECT_NEAR(t.tics(), 0, 0.05);
TEST(clara_timer_test, TicToc) {
Timer<> timer;
timer.tic();
std::this_thread::sleep_for(std::chrono::seconds(2));
timer.toc();
auto duration = timer.get_duration();
EXPECT_GE(duration.count(), 2);
}

0 comments on commit 365ae9b

Please sign in to comment.