Skip to content

Commit

Permalink
GetTimerBehavior and associated test.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheweshleman committed Oct 16, 2024
1 parent 6244432 commit 4d6a153
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/FakeTimers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ class FakeTimers
return timer.period;
}

/**
* Get the timer's behavior setting.
* @param handle
* @return
* @note: Reference FreeRTOS xTimerGetReloadMode
*/
TimerBehavior GetTimerBehavior(TimerHandle handle) const
{
const Timer& timer = mTimers.at(handle - 1);
assert(timer.handle == handle);
assert(timer.allocated);

return timer.behavior;
}

/**
* Check if a timer is currently active or not
* @param handle - the timer handle
Expand Down
7 changes: 7 additions & 0 deletions tests/FakeTimersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ TEST(FakeTimersTests, access_timer_period_via_handle)
CHECK_TRUE(1s == period);
}

TEST(FakeTimersTests, access_timer_behavior_via_handle)
{
auto handle = Create();
auto behavior = mUnderTest->GetTimerBehavior(handle);
CHECK_TRUE(TimerBehavior::SingleShot == behavior);
}

TEST(FakeTimersTests, is_timer_active_method_works_as_expected)
{
auto handle = Create();
Expand Down

0 comments on commit 4d6a153

Please sign in to comment.